]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/3.8.7/grsecurity-2.9.1-3.8.7-201304122027.patch
Auto commit, grsecurity-3.1-4.9.13-201703052141.patch added.
[thirdparty/grsecurity-scrape.git] / test / 3.8.7 / grsecurity-2.9.1-3.8.7-201304122027.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 85204da..9d99250 100644
263 --- a/Makefile
264 +++ b/Makefile
265 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
266
267 HOSTCC = gcc
268 HOSTCXX = g++
269 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
270 -HOSTCXXFLAGS = -O2
271 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
272 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
273 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
274
275 # Decide whether to build built-in, modular, or both.
276 # Normally, just do built-in.
277 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
278 # Rules shared between *config targets and build targets
279
280 # Basic helpers built in scripts/
281 -PHONY += scripts_basic
282 -scripts_basic:
283 +PHONY += scripts_basic gcc-plugins
284 +scripts_basic: gcc-plugins
285 $(Q)$(MAKE) $(build)=scripts/basic
286 $(Q)rm -f .tmp_quiet_recordmcount
287
288 @@ -575,6 +576,65 @@ else
289 KBUILD_CFLAGS += -O2
290 endif
291
292 +ifndef DISABLE_PAX_PLUGINS
293 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
294 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
295 +else
296 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
297 +endif
298 +ifneq ($(PLUGINCC),)
299 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
300 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
301 +endif
302 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
303 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
304 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
305 +endif
306 +ifdef CONFIG_KALLOCSTAT_PLUGIN
307 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
308 +endif
309 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
310 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
311 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
312 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
313 +endif
314 +ifdef CONFIG_CHECKER_PLUGIN
315 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
316 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
317 +endif
318 +endif
319 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
320 +ifdef CONFIG_PAX_SIZE_OVERFLOW
321 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
322 +endif
323 +ifdef CONFIG_PAX_LATENT_ENTROPY
324 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
325 +endif
326 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
327 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
328 +endif
329 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
330 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
331 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
332 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
333 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
334 +ifeq ($(KBUILD_EXTMOD),)
335 +gcc-plugins:
336 + $(Q)$(MAKE) $(build)=tools/gcc
337 +else
338 +gcc-plugins: ;
339 +endif
340 +else
341 +gcc-plugins:
342 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
343 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
344 +else
345 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
346 +endif
347 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
348 +endif
349 +endif
350 +
351 include $(srctree)/arch/$(SRCARCH)/Makefile
352
353 ifdef CONFIG_READABLE_ASM
354 @@ -731,7 +791,7 @@ export mod_sign_cmd
355
356
357 ifeq ($(KBUILD_EXTMOD),)
358 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
359 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
360
361 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
362 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
363 @@ -778,6 +838,8 @@ endif
364
365 # The actual objects are generated when descending,
366 # make sure no implicit rule kicks in
367 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
368 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
369 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
370
371 # Handle descending into subdirectories listed in $(vmlinux-dirs)
372 @@ -787,7 +849,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
373 # Error messages still appears in the original language
374
375 PHONY += $(vmlinux-dirs)
376 -$(vmlinux-dirs): prepare scripts
377 +$(vmlinux-dirs): gcc-plugins prepare scripts
378 $(Q)$(MAKE) $(build)=$@
379
380 # Store (new) KERNELRELASE string in include/config/kernel.release
381 @@ -831,6 +893,7 @@ prepare0: archprepare FORCE
382 $(Q)$(MAKE) $(build)=.
383
384 # All the preparing..
385 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
386 prepare: prepare0
387
388 # Generate some files
389 @@ -938,6 +1001,8 @@ all: modules
390 # using awk while concatenating to the final file.
391
392 PHONY += modules
393 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
394 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
395 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
396 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
397 @$(kecho) ' Building modules, stage 2.';
398 @@ -953,7 +1018,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
399
400 # Target to prepare building external modules
401 PHONY += modules_prepare
402 -modules_prepare: prepare scripts
403 +modules_prepare: gcc-plugins prepare scripts
404
405 # Target to install modules
406 PHONY += modules_install
407 @@ -1019,7 +1084,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
408 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
409 signing_key.priv signing_key.x509 x509.genkey \
410 extra_certificates signing_key.x509.keyid \
411 - signing_key.x509.signer
412 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
413
414 # clean - Delete most, but leave enough to build external modules
415 #
416 @@ -1059,6 +1124,7 @@ distclean: mrproper
417 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
418 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
419 -o -name '.*.rej' \
420 + -o -name '.*.rej' -o -name '*.so' \
421 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
422 -type f -print | xargs rm -f
423
424 @@ -1219,6 +1285,8 @@ PHONY += $(module-dirs) modules
425 $(module-dirs): crmodverdir $(objtree)/Module.symvers
426 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
427
428 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
429 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
430 modules: $(module-dirs)
431 @$(kecho) ' Building modules, stage 2.';
432 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
433 @@ -1355,17 +1423,21 @@ else
434 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
435 endif
436
437 -%.s: %.c prepare scripts FORCE
438 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
439 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
440 +%.s: %.c gcc-plugins prepare scripts FORCE
441 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
442 %.i: %.c prepare scripts FORCE
443 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
444 -%.o: %.c prepare scripts FORCE
445 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
446 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
447 +%.o: %.c gcc-plugins prepare scripts FORCE
448 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
449 %.lst: %.c prepare scripts FORCE
450 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
451 -%.s: %.S prepare scripts FORCE
452 +%.s: %.S gcc-plugins prepare scripts FORCE
453 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
454 -%.o: %.S prepare scripts FORCE
455 +%.o: %.S gcc-plugins prepare scripts FORCE
456 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
457 %.symtypes: %.c prepare scripts FORCE
458 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
459 @@ -1375,11 +1447,15 @@ endif
460 $(cmd_crmodverdir)
461 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
462 $(build)=$(build-dir)
463 -%/: prepare scripts FORCE
464 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
465 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
466 +%/: gcc-plugins prepare scripts FORCE
467 $(cmd_crmodverdir)
468 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
469 $(build)=$(build-dir)
470 -%.ko: prepare scripts FORCE
471 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
472 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
473 +%.ko: gcc-plugins prepare scripts FORCE
474 $(cmd_crmodverdir)
475 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
476 $(build)=$(build-dir) $(@:.ko=.o)
477 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
478 index c2cbe4f..f7264b4 100644
479 --- a/arch/alpha/include/asm/atomic.h
480 +++ b/arch/alpha/include/asm/atomic.h
481 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
482 #define atomic_dec(v) atomic_sub(1,(v))
483 #define atomic64_dec(v) atomic64_sub(1,(v))
484
485 +#define atomic64_read_unchecked(v) atomic64_read(v)
486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
494 +
495 #define smp_mb__before_atomic_dec() smp_mb()
496 #define smp_mb__after_atomic_dec() smp_mb()
497 #define smp_mb__before_atomic_inc() smp_mb()
498 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
499 index ad368a9..fbe0f25 100644
500 --- a/arch/alpha/include/asm/cache.h
501 +++ b/arch/alpha/include/asm/cache.h
502 @@ -4,19 +4,19 @@
503 #ifndef __ARCH_ALPHA_CACHE_H
504 #define __ARCH_ALPHA_CACHE_H
505
506 +#include <linux/const.h>
507
508 /* Bytes per L1 (data) cache line. */
509 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
510 -# define L1_CACHE_BYTES 64
511 # define L1_CACHE_SHIFT 6
512 #else
513 /* Both EV4 and EV5 are write-through, read-allocate,
514 direct-mapped, physical.
515 */
516 -# define L1_CACHE_BYTES 32
517 # define L1_CACHE_SHIFT 5
518 #endif
519
520 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
521 #define SMP_CACHE_BYTES L1_CACHE_BYTES
522
523 #endif
524 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
525 index 968d999..d36b2df 100644
526 --- a/arch/alpha/include/asm/elf.h
527 +++ b/arch/alpha/include/asm/elf.h
528 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
529
530 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
531
532 +#ifdef CONFIG_PAX_ASLR
533 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
534 +
535 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
536 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
537 +#endif
538 +
539 /* $0 is set by ld.so to a pointer to a function which might be
540 registered using atexit. This provides a mean for the dynamic
541 linker to call DT_FINI functions for shared libraries that have
542 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
543 index bc2a0da..8ad11ee 100644
544 --- a/arch/alpha/include/asm/pgalloc.h
545 +++ b/arch/alpha/include/asm/pgalloc.h
546 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
547 pgd_set(pgd, pmd);
548 }
549
550 +static inline void
551 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
552 +{
553 + pgd_populate(mm, pgd, pmd);
554 +}
555 +
556 extern pgd_t *pgd_alloc(struct mm_struct *mm);
557
558 static inline void
559 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
560 index 81a4342..348b927 100644
561 --- a/arch/alpha/include/asm/pgtable.h
562 +++ b/arch/alpha/include/asm/pgtable.h
563 @@ -102,6 +102,17 @@ struct vm_area_struct;
564 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
565 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
566 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
567 +
568 +#ifdef CONFIG_PAX_PAGEEXEC
569 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
570 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
571 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
572 +#else
573 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
574 +# define PAGE_COPY_NOEXEC PAGE_COPY
575 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
576 +#endif
577 +
578 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
579
580 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
581 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
582 index 2fd00b7..cfd5069 100644
583 --- a/arch/alpha/kernel/module.c
584 +++ b/arch/alpha/kernel/module.c
585 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
586
587 /* The small sections were sorted to the end of the segment.
588 The following should definitely cover them. */
589 - gp = (u64)me->module_core + me->core_size - 0x8000;
590 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
591 got = sechdrs[me->arch.gotsecindex].sh_addr;
592
593 for (i = 0; i < n; i++) {
594 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
595 index 14db93e..47bed62 100644
596 --- a/arch/alpha/kernel/osf_sys.c
597 +++ b/arch/alpha/kernel/osf_sys.c
598 @@ -1295,16 +1295,16 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
599 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
600
601 static unsigned long
602 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
603 - unsigned long limit)
604 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
605 + unsigned long limit, unsigned long flags)
606 {
607 struct vm_area_struct *vma = find_vma(current->mm, addr);
608 -
609 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
610 while (1) {
611 /* At this point: (!vma || addr < vma->vm_end). */
612 if (limit - len < addr)
613 return -ENOMEM;
614 - if (!vma || addr + len <= vma->vm_start)
615 + if (check_heap_stack_gap(vma, addr, len, offset))
616 return addr;
617 addr = vma->vm_end;
618 vma = vma->vm_next;
619 @@ -1340,20 +1340,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
620 merely specific addresses, but regions of memory -- perhaps
621 this feature should be incorporated into all ports? */
622
623 +#ifdef CONFIG_PAX_RANDMMAP
624 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
625 +#endif
626 +
627 if (addr) {
628 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
629 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
630 if (addr != (unsigned long) -ENOMEM)
631 return addr;
632 }
633
634 /* Next, try allocating at TASK_UNMAPPED_BASE. */
635 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
636 - len, limit);
637 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
638 +
639 if (addr != (unsigned long) -ENOMEM)
640 return addr;
641
642 /* Finally, try allocating in low memory. */
643 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
644 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
645
646 return addr;
647 }
648 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
649 index 0c4132d..88f0d53 100644
650 --- a/arch/alpha/mm/fault.c
651 +++ b/arch/alpha/mm/fault.c
652 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
653 __reload_thread(pcb);
654 }
655
656 +#ifdef CONFIG_PAX_PAGEEXEC
657 +/*
658 + * PaX: decide what to do with offenders (regs->pc = fault address)
659 + *
660 + * returns 1 when task should be killed
661 + * 2 when patched PLT trampoline was detected
662 + * 3 when unpatched PLT trampoline was detected
663 + */
664 +static int pax_handle_fetch_fault(struct pt_regs *regs)
665 +{
666 +
667 +#ifdef CONFIG_PAX_EMUPLT
668 + int err;
669 +
670 + do { /* PaX: patched PLT emulation #1 */
671 + unsigned int ldah, ldq, jmp;
672 +
673 + err = get_user(ldah, (unsigned int *)regs->pc);
674 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
675 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
676 +
677 + if (err)
678 + break;
679 +
680 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
681 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
682 + jmp == 0x6BFB0000U)
683 + {
684 + unsigned long r27, addr;
685 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
686 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
687 +
688 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
689 + err = get_user(r27, (unsigned long *)addr);
690 + if (err)
691 + break;
692 +
693 + regs->r27 = r27;
694 + regs->pc = r27;
695 + return 2;
696 + }
697 + } while (0);
698 +
699 + do { /* PaX: patched PLT emulation #2 */
700 + unsigned int ldah, lda, br;
701 +
702 + err = get_user(ldah, (unsigned int *)regs->pc);
703 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
704 + err |= get_user(br, (unsigned int *)(regs->pc+8));
705 +
706 + if (err)
707 + break;
708 +
709 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
710 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
711 + (br & 0xFFE00000U) == 0xC3E00000U)
712 + {
713 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
714 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
715 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
716 +
717 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
718 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
719 + return 2;
720 + }
721 + } while (0);
722 +
723 + do { /* PaX: unpatched PLT emulation */
724 + unsigned int br;
725 +
726 + err = get_user(br, (unsigned int *)regs->pc);
727 +
728 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
729 + unsigned int br2, ldq, nop, jmp;
730 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
731 +
732 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
733 + err = get_user(br2, (unsigned int *)addr);
734 + err |= get_user(ldq, (unsigned int *)(addr+4));
735 + err |= get_user(nop, (unsigned int *)(addr+8));
736 + err |= get_user(jmp, (unsigned int *)(addr+12));
737 + err |= get_user(resolver, (unsigned long *)(addr+16));
738 +
739 + if (err)
740 + break;
741 +
742 + if (br2 == 0xC3600000U &&
743 + ldq == 0xA77B000CU &&
744 + nop == 0x47FF041FU &&
745 + jmp == 0x6B7B0000U)
746 + {
747 + regs->r28 = regs->pc+4;
748 + regs->r27 = addr+16;
749 + regs->pc = resolver;
750 + return 3;
751 + }
752 + }
753 + } while (0);
754 +#endif
755 +
756 + return 1;
757 +}
758 +
759 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
760 +{
761 + unsigned long i;
762 +
763 + printk(KERN_ERR "PAX: bytes at PC: ");
764 + for (i = 0; i < 5; i++) {
765 + unsigned int c;
766 + if (get_user(c, (unsigned int *)pc+i))
767 + printk(KERN_CONT "???????? ");
768 + else
769 + printk(KERN_CONT "%08x ", c);
770 + }
771 + printk("\n");
772 +}
773 +#endif
774
775 /*
776 * This routine handles page faults. It determines the address,
777 @@ -133,8 +251,29 @@ retry:
778 good_area:
779 si_code = SEGV_ACCERR;
780 if (cause < 0) {
781 - if (!(vma->vm_flags & VM_EXEC))
782 + if (!(vma->vm_flags & VM_EXEC)) {
783 +
784 +#ifdef CONFIG_PAX_PAGEEXEC
785 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
786 + goto bad_area;
787 +
788 + up_read(&mm->mmap_sem);
789 + switch (pax_handle_fetch_fault(regs)) {
790 +
791 +#ifdef CONFIG_PAX_EMUPLT
792 + case 2:
793 + case 3:
794 + return;
795 +#endif
796 +
797 + }
798 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
799 + do_group_exit(SIGKILL);
800 +#else
801 goto bad_area;
802 +#endif
803 +
804 + }
805 } else if (!cause) {
806 /* Allow reads even for write-only mappings */
807 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
808 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
809 index 67874b8..9aa2d62 100644
810 --- a/arch/arm/Kconfig
811 +++ b/arch/arm/Kconfig
812 @@ -1427,6 +1427,16 @@ config ARM_ERRATA_775420
813 to deadlock. This workaround puts DSB before executing ISB if
814 an abort may occur on cache maintenance.
815
816 +config ARM_ERRATA_798181
817 + bool "ARM errata: TLBI/DSB failure on Cortex-A15"
818 + depends on CPU_V7 && SMP
819 + help
820 + On Cortex-A15 (r0p0..r3p2) the TLBI*IS/DSB operations are not
821 + adequately shooting down all use of the old entries. This
822 + option enables the Linux kernel workaround for this erratum
823 + which sends an IPI to the CPUs that are running the same ASID
824 + as the one being invalidated.
825 +
826 endmenu
827
828 source "arch/arm/common/Kconfig"
829 @@ -1813,7 +1823,7 @@ config ALIGNMENT_TRAP
830
831 config UACCESS_WITH_MEMCPY
832 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
833 - depends on MMU
834 + depends on MMU && !PAX_MEMORY_UDEREF
835 default y if CPU_FEROCEON
836 help
837 Implement faster copy_to_user and clear_user methods for CPU
838 diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
839 index 87dfa902..3a523fc 100644
840 --- a/arch/arm/common/gic.c
841 +++ b/arch/arm/common/gic.c
842 @@ -81,7 +81,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
843 * Supported arch specific GIC irq extension.
844 * Default make them NULL.
845 */
846 -struct irq_chip gic_arch_extn = {
847 +irq_chip_no_const gic_arch_extn __read_only = {
848 .irq_eoi = NULL,
849 .irq_mask = NULL,
850 .irq_unmask = NULL,
851 @@ -329,7 +329,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
852 chained_irq_exit(chip, desc);
853 }
854
855 -static struct irq_chip gic_chip = {
856 +static irq_chip_no_const gic_chip __read_only = {
857 .name = "GIC",
858 .irq_mask = gic_mask_irq,
859 .irq_unmask = gic_unmask_irq,
860 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
861 index c79f61f..9ac0642 100644
862 --- a/arch/arm/include/asm/atomic.h
863 +++ b/arch/arm/include/asm/atomic.h
864 @@ -17,17 +17,35 @@
865 #include <asm/barrier.h>
866 #include <asm/cmpxchg.h>
867
868 +#ifdef CONFIG_GENERIC_ATOMIC64
869 +#include <asm-generic/atomic64.h>
870 +#endif
871 +
872 #define ATOMIC_INIT(i) { (i) }
873
874 #ifdef __KERNEL__
875
876 +#define _ASM_EXTABLE(from, to) \
877 +" .pushsection __ex_table,\"a\"\n"\
878 +" .align 3\n" \
879 +" .long " #from ", " #to"\n" \
880 +" .popsection"
881 +
882 /*
883 * On ARM, ordinary assignment (str instruction) doesn't clear the local
884 * strex/ldrex monitor on some implementations. The reason we can use it for
885 * atomic_set() is the clrex or dummy strex done on every exception return.
886 */
887 #define atomic_read(v) (*(volatile int *)&(v)->counter)
888 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
889 +{
890 + return v->counter;
891 +}
892 #define atomic_set(v,i) (((v)->counter) = (i))
893 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
894 +{
895 + v->counter = i;
896 +}
897
898 #if __LINUX_ARM_ARCH__ >= 6
899
900 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
901 int result;
902
903 __asm__ __volatile__("@ atomic_add\n"
904 +"1: ldrex %1, [%3]\n"
905 +" adds %0, %1, %4\n"
906 +
907 +#ifdef CONFIG_PAX_REFCOUNT
908 +" bvc 3f\n"
909 +"2: bkpt 0xf103\n"
910 +"3:\n"
911 +#endif
912 +
913 +" strex %1, %0, [%3]\n"
914 +" teq %1, #0\n"
915 +" bne 1b"
916 +
917 +#ifdef CONFIG_PAX_REFCOUNT
918 +"\n4:\n"
919 + _ASM_EXTABLE(2b, 4b)
920 +#endif
921 +
922 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
923 + : "r" (&v->counter), "Ir" (i)
924 + : "cc");
925 +}
926 +
927 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
928 +{
929 + unsigned long tmp;
930 + int result;
931 +
932 + __asm__ __volatile__("@ atomic_add_unchecked\n"
933 "1: ldrex %0, [%3]\n"
934 " add %0, %0, %4\n"
935 " strex %1, %0, [%3]\n"
936 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
937 smp_mb();
938
939 __asm__ __volatile__("@ atomic_add_return\n"
940 +"1: ldrex %1, [%3]\n"
941 +" adds %0, %1, %4\n"
942 +
943 +#ifdef CONFIG_PAX_REFCOUNT
944 +" bvc 3f\n"
945 +" mov %0, %1\n"
946 +"2: bkpt 0xf103\n"
947 +"3:\n"
948 +#endif
949 +
950 +" strex %1, %0, [%3]\n"
951 +" teq %1, #0\n"
952 +" bne 1b"
953 +
954 +#ifdef CONFIG_PAX_REFCOUNT
955 +"\n4:\n"
956 + _ASM_EXTABLE(2b, 4b)
957 +#endif
958 +
959 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
960 + : "r" (&v->counter), "Ir" (i)
961 + : "cc");
962 +
963 + smp_mb();
964 +
965 + return result;
966 +}
967 +
968 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
969 +{
970 + unsigned long tmp;
971 + int result;
972 +
973 + smp_mb();
974 +
975 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
976 "1: ldrex %0, [%3]\n"
977 " add %0, %0, %4\n"
978 " strex %1, %0, [%3]\n"
979 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
980 int result;
981
982 __asm__ __volatile__("@ atomic_sub\n"
983 +"1: ldrex %1, [%3]\n"
984 +" subs %0, %1, %4\n"
985 +
986 +#ifdef CONFIG_PAX_REFCOUNT
987 +" bvc 3f\n"
988 +"2: bkpt 0xf103\n"
989 +"3:\n"
990 +#endif
991 +
992 +" strex %1, %0, [%3]\n"
993 +" teq %1, #0\n"
994 +" bne 1b"
995 +
996 +#ifdef CONFIG_PAX_REFCOUNT
997 +"\n4:\n"
998 + _ASM_EXTABLE(2b, 4b)
999 +#endif
1000 +
1001 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1002 + : "r" (&v->counter), "Ir" (i)
1003 + : "cc");
1004 +}
1005 +
1006 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1007 +{
1008 + unsigned long tmp;
1009 + int result;
1010 +
1011 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
1012 "1: ldrex %0, [%3]\n"
1013 " sub %0, %0, %4\n"
1014 " strex %1, %0, [%3]\n"
1015 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1016 smp_mb();
1017
1018 __asm__ __volatile__("@ atomic_sub_return\n"
1019 -"1: ldrex %0, [%3]\n"
1020 -" sub %0, %0, %4\n"
1021 +"1: ldrex %1, [%3]\n"
1022 +" subs %0, %1, %4\n"
1023 +
1024 +#ifdef CONFIG_PAX_REFCOUNT
1025 +" bvc 3f\n"
1026 +" mov %0, %1\n"
1027 +"2: bkpt 0xf103\n"
1028 +"3:\n"
1029 +#endif
1030 +
1031 " strex %1, %0, [%3]\n"
1032 " teq %1, #0\n"
1033 " bne 1b"
1034 +
1035 +#ifdef CONFIG_PAX_REFCOUNT
1036 +"\n4:\n"
1037 + _ASM_EXTABLE(2b, 4b)
1038 +#endif
1039 +
1040 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1041 : "r" (&v->counter), "Ir" (i)
1042 : "cc");
1043 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1044 return oldval;
1045 }
1046
1047 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1048 +{
1049 + unsigned long oldval, res;
1050 +
1051 + smp_mb();
1052 +
1053 + do {
1054 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1055 + "ldrex %1, [%3]\n"
1056 + "mov %0, #0\n"
1057 + "teq %1, %4\n"
1058 + "strexeq %0, %5, [%3]\n"
1059 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1060 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1061 + : "cc");
1062 + } while (res);
1063 +
1064 + smp_mb();
1065 +
1066 + return oldval;
1067 +}
1068 +
1069 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1070 {
1071 unsigned long tmp, tmp2;
1072 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1073
1074 return val;
1075 }
1076 +
1077 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1078 +{
1079 + return atomic_add_return(i, v);
1080 +}
1081 +
1082 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1083 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1084 +{
1085 + (void) atomic_add_return(i, v);
1086 +}
1087
1088 static inline int atomic_sub_return(int i, atomic_t *v)
1089 {
1090 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1091 return val;
1092 }
1093 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1094 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1095 +{
1096 + (void) atomic_sub_return(i, v);
1097 +}
1098
1099 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1100 {
1101 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1102 return ret;
1103 }
1104
1105 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1106 +{
1107 + return atomic_cmpxchg(v, old, new);
1108 +}
1109 +
1110 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1111 {
1112 unsigned long flags;
1113 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1114 #endif /* __LINUX_ARM_ARCH__ */
1115
1116 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1117 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1118 +{
1119 + return xchg(&v->counter, new);
1120 +}
1121
1122 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1123 {
1124 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1125 }
1126
1127 #define atomic_inc(v) atomic_add(1, v)
1128 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1129 +{
1130 + atomic_add_unchecked(1, v);
1131 +}
1132 #define atomic_dec(v) atomic_sub(1, v)
1133 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1134 +{
1135 + atomic_sub_unchecked(1, v);
1136 +}
1137
1138 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1139 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1140 +{
1141 + return atomic_add_return_unchecked(1, v) == 0;
1142 +}
1143 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1144 #define atomic_inc_return(v) (atomic_add_return(1, v))
1145 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1146 +{
1147 + return atomic_add_return_unchecked(1, v);
1148 +}
1149 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1150 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1151
1152 @@ -241,6 +428,14 @@ typedef struct {
1153 u64 __aligned(8) counter;
1154 } atomic64_t;
1155
1156 +#ifdef CONFIG_PAX_REFCOUNT
1157 +typedef struct {
1158 + u64 __aligned(8) counter;
1159 +} atomic64_unchecked_t;
1160 +#else
1161 +typedef atomic64_t atomic64_unchecked_t;
1162 +#endif
1163 +
1164 #define ATOMIC64_INIT(i) { (i) }
1165
1166 static inline u64 atomic64_read(const atomic64_t *v)
1167 @@ -256,6 +451,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1168 return result;
1169 }
1170
1171 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1172 +{
1173 + u64 result;
1174 +
1175 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1176 +" ldrexd %0, %H0, [%1]"
1177 + : "=&r" (result)
1178 + : "r" (&v->counter), "Qo" (v->counter)
1179 + );
1180 +
1181 + return result;
1182 +}
1183 +
1184 static inline void atomic64_set(atomic64_t *v, u64 i)
1185 {
1186 u64 tmp;
1187 @@ -270,6 +478,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1188 : "cc");
1189 }
1190
1191 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1192 +{
1193 + u64 tmp;
1194 +
1195 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1196 +"1: ldrexd %0, %H0, [%2]\n"
1197 +" strexd %0, %3, %H3, [%2]\n"
1198 +" teq %0, #0\n"
1199 +" bne 1b"
1200 + : "=&r" (tmp), "=Qo" (v->counter)
1201 + : "r" (&v->counter), "r" (i)
1202 + : "cc");
1203 +}
1204 +
1205 static inline void atomic64_add(u64 i, atomic64_t *v)
1206 {
1207 u64 result;
1208 @@ -278,6 +500,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1209 __asm__ __volatile__("@ atomic64_add\n"
1210 "1: ldrexd %0, %H0, [%3]\n"
1211 " adds %0, %0, %4\n"
1212 +" adcs %H0, %H0, %H4\n"
1213 +
1214 +#ifdef CONFIG_PAX_REFCOUNT
1215 +" bvc 3f\n"
1216 +"2: bkpt 0xf103\n"
1217 +"3:\n"
1218 +#endif
1219 +
1220 +" strexd %1, %0, %H0, [%3]\n"
1221 +" teq %1, #0\n"
1222 +" bne 1b"
1223 +
1224 +#ifdef CONFIG_PAX_REFCOUNT
1225 +"\n4:\n"
1226 + _ASM_EXTABLE(2b, 4b)
1227 +#endif
1228 +
1229 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1230 + : "r" (&v->counter), "r" (i)
1231 + : "cc");
1232 +}
1233 +
1234 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1235 +{
1236 + u64 result;
1237 + unsigned long tmp;
1238 +
1239 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1240 +"1: ldrexd %0, %H0, [%3]\n"
1241 +" adds %0, %0, %4\n"
1242 " adc %H0, %H0, %H4\n"
1243 " strexd %1, %0, %H0, [%3]\n"
1244 " teq %1, #0\n"
1245 @@ -289,12 +541,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1246
1247 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1248 {
1249 - u64 result;
1250 - unsigned long tmp;
1251 + u64 result, tmp;
1252
1253 smp_mb();
1254
1255 __asm__ __volatile__("@ atomic64_add_return\n"
1256 +"1: ldrexd %1, %H1, [%3]\n"
1257 +" adds %0, %1, %4\n"
1258 +" adcs %H0, %H1, %H4\n"
1259 +
1260 +#ifdef CONFIG_PAX_REFCOUNT
1261 +" bvc 3f\n"
1262 +" mov %0, %1\n"
1263 +" mov %H0, %H1\n"
1264 +"2: bkpt 0xf103\n"
1265 +"3:\n"
1266 +#endif
1267 +
1268 +" strexd %1, %0, %H0, [%3]\n"
1269 +" teq %1, #0\n"
1270 +" bne 1b"
1271 +
1272 +#ifdef CONFIG_PAX_REFCOUNT
1273 +"\n4:\n"
1274 + _ASM_EXTABLE(2b, 4b)
1275 +#endif
1276 +
1277 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1278 + : "r" (&v->counter), "r" (i)
1279 + : "cc");
1280 +
1281 + smp_mb();
1282 +
1283 + return result;
1284 +}
1285 +
1286 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1287 +{
1288 + u64 result;
1289 + unsigned long tmp;
1290 +
1291 + smp_mb();
1292 +
1293 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1294 "1: ldrexd %0, %H0, [%3]\n"
1295 " adds %0, %0, %4\n"
1296 " adc %H0, %H0, %H4\n"
1297 @@ -318,6 +607,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1298 __asm__ __volatile__("@ atomic64_sub\n"
1299 "1: ldrexd %0, %H0, [%3]\n"
1300 " subs %0, %0, %4\n"
1301 +" sbcs %H0, %H0, %H4\n"
1302 +
1303 +#ifdef CONFIG_PAX_REFCOUNT
1304 +" bvc 3f\n"
1305 +"2: bkpt 0xf103\n"
1306 +"3:\n"
1307 +#endif
1308 +
1309 +" strexd %1, %0, %H0, [%3]\n"
1310 +" teq %1, #0\n"
1311 +" bne 1b"
1312 +
1313 +#ifdef CONFIG_PAX_REFCOUNT
1314 +"\n4:\n"
1315 + _ASM_EXTABLE(2b, 4b)
1316 +#endif
1317 +
1318 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1319 + : "r" (&v->counter), "r" (i)
1320 + : "cc");
1321 +}
1322 +
1323 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1324 +{
1325 + u64 result;
1326 + unsigned long tmp;
1327 +
1328 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1329 +"1: ldrexd %0, %H0, [%3]\n"
1330 +" subs %0, %0, %4\n"
1331 " sbc %H0, %H0, %H4\n"
1332 " strexd %1, %0, %H0, [%3]\n"
1333 " teq %1, #0\n"
1334 @@ -329,18 +648,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1335
1336 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1337 {
1338 - u64 result;
1339 - unsigned long tmp;
1340 + u64 result, tmp;
1341
1342 smp_mb();
1343
1344 __asm__ __volatile__("@ atomic64_sub_return\n"
1345 -"1: ldrexd %0, %H0, [%3]\n"
1346 -" subs %0, %0, %4\n"
1347 -" sbc %H0, %H0, %H4\n"
1348 +"1: ldrexd %1, %H1, [%3]\n"
1349 +" subs %0, %1, %4\n"
1350 +" sbcs %H0, %H1, %H4\n"
1351 +
1352 +#ifdef CONFIG_PAX_REFCOUNT
1353 +" bvc 3f\n"
1354 +" mov %0, %1\n"
1355 +" mov %H0, %H1\n"
1356 +"2: bkpt 0xf103\n"
1357 +"3:\n"
1358 +#endif
1359 +
1360 " strexd %1, %0, %H0, [%3]\n"
1361 " teq %1, #0\n"
1362 " bne 1b"
1363 +
1364 +#ifdef CONFIG_PAX_REFCOUNT
1365 +"\n4:\n"
1366 + _ASM_EXTABLE(2b, 4b)
1367 +#endif
1368 +
1369 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1370 : "r" (&v->counter), "r" (i)
1371 : "cc");
1372 @@ -374,6 +707,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1373 return oldval;
1374 }
1375
1376 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1377 +{
1378 + u64 oldval;
1379 + unsigned long res;
1380 +
1381 + smp_mb();
1382 +
1383 + do {
1384 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1385 + "ldrexd %1, %H1, [%3]\n"
1386 + "mov %0, #0\n"
1387 + "teq %1, %4\n"
1388 + "teqeq %H1, %H4\n"
1389 + "strexdeq %0, %5, %H5, [%3]"
1390 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1391 + : "r" (&ptr->counter), "r" (old), "r" (new)
1392 + : "cc");
1393 + } while (res);
1394 +
1395 + smp_mb();
1396 +
1397 + return oldval;
1398 +}
1399 +
1400 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1401 {
1402 u64 result;
1403 @@ -397,21 +754,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1404
1405 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1406 {
1407 - u64 result;
1408 - unsigned long tmp;
1409 + u64 result, tmp;
1410
1411 smp_mb();
1412
1413 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1414 -"1: ldrexd %0, %H0, [%3]\n"
1415 -" subs %0, %0, #1\n"
1416 -" sbc %H0, %H0, #0\n"
1417 +"1: ldrexd %1, %H1, [%3]\n"
1418 +" subs %0, %1, #1\n"
1419 +" sbcs %H0, %H1, #0\n"
1420 +
1421 +#ifdef CONFIG_PAX_REFCOUNT
1422 +" bvc 3f\n"
1423 +" mov %0, %1\n"
1424 +" mov %H0, %H1\n"
1425 +"2: bkpt 0xf103\n"
1426 +"3:\n"
1427 +#endif
1428 +
1429 " teq %H0, #0\n"
1430 -" bmi 2f\n"
1431 +" bmi 4f\n"
1432 " strexd %1, %0, %H0, [%3]\n"
1433 " teq %1, #0\n"
1434 " bne 1b\n"
1435 -"2:"
1436 +"4:\n"
1437 +
1438 +#ifdef CONFIG_PAX_REFCOUNT
1439 + _ASM_EXTABLE(2b, 4b)
1440 +#endif
1441 +
1442 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1443 : "r" (&v->counter)
1444 : "cc");
1445 @@ -434,13 +804,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1446 " teq %0, %5\n"
1447 " teqeq %H0, %H5\n"
1448 " moveq %1, #0\n"
1449 -" beq 2f\n"
1450 +" beq 4f\n"
1451 " adds %0, %0, %6\n"
1452 -" adc %H0, %H0, %H6\n"
1453 +" adcs %H0, %H0, %H6\n"
1454 +
1455 +#ifdef CONFIG_PAX_REFCOUNT
1456 +" bvc 3f\n"
1457 +"2: bkpt 0xf103\n"
1458 +"3:\n"
1459 +#endif
1460 +
1461 " strexd %2, %0, %H0, [%4]\n"
1462 " teq %2, #0\n"
1463 " bne 1b\n"
1464 -"2:"
1465 +"4:\n"
1466 +
1467 +#ifdef CONFIG_PAX_REFCOUNT
1468 + _ASM_EXTABLE(2b, 4b)
1469 +#endif
1470 +
1471 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1472 : "r" (&v->counter), "r" (u), "r" (a)
1473 : "cc");
1474 @@ -453,10 +835,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1475
1476 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1477 #define atomic64_inc(v) atomic64_add(1LL, (v))
1478 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1479 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1480 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1481 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1482 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1483 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1484 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1485 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1486 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1487 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1488 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1489 index 75fe66b..ba3dee4 100644
1490 --- a/arch/arm/include/asm/cache.h
1491 +++ b/arch/arm/include/asm/cache.h
1492 @@ -4,8 +4,10 @@
1493 #ifndef __ASMARM_CACHE_H
1494 #define __ASMARM_CACHE_H
1495
1496 +#include <linux/const.h>
1497 +
1498 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1499 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1500 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1501
1502 /*
1503 * Memory returned by kmalloc() may be used for DMA, so we must make
1504 @@ -24,5 +26,6 @@
1505 #endif
1506
1507 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1508 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1509
1510 #endif
1511 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1512 index e1489c5..d418304 100644
1513 --- a/arch/arm/include/asm/cacheflush.h
1514 +++ b/arch/arm/include/asm/cacheflush.h
1515 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1516 void (*dma_unmap_area)(const void *, size_t, int);
1517
1518 void (*dma_flush_range)(const void *, const void *);
1519 -};
1520 +} __no_const;
1521
1522 /*
1523 * Select the calling method
1524 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1525 index 6dcc164..b14d917 100644
1526 --- a/arch/arm/include/asm/checksum.h
1527 +++ b/arch/arm/include/asm/checksum.h
1528 @@ -37,7 +37,19 @@ __wsum
1529 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1530
1531 __wsum
1532 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1533 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1534 +
1535 +static inline __wsum
1536 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1537 +{
1538 + __wsum ret;
1539 + pax_open_userland();
1540 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1541 + pax_close_userland();
1542 + return ret;
1543 +}
1544 +
1545 +
1546
1547 /*
1548 * Fold a partial checksum without adding pseudo headers
1549 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1550 index 7eb18c1..e38b6d2 100644
1551 --- a/arch/arm/include/asm/cmpxchg.h
1552 +++ b/arch/arm/include/asm/cmpxchg.h
1553 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1554
1555 #define xchg(ptr,x) \
1556 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1557 +#define xchg_unchecked(ptr,x) \
1558 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1559
1560 #include <asm-generic/cmpxchg-local.h>
1561
1562 diff --git a/arch/arm/include/asm/delay.h b/arch/arm/include/asm/delay.h
1563 index 720799f..2f67631 100644
1564 --- a/arch/arm/include/asm/delay.h
1565 +++ b/arch/arm/include/asm/delay.h
1566 @@ -25,9 +25,9 @@ extern struct arm_delay_ops {
1567 void (*const_udelay)(unsigned long);
1568 void (*udelay)(unsigned long);
1569 bool const_clock;
1570 -} arm_delay_ops;
1571 +} *arm_delay_ops;
1572
1573 -#define __delay(n) arm_delay_ops.delay(n)
1574 +#define __delay(n) arm_delay_ops->delay(n)
1575
1576 /*
1577 * This function intentionally does not exist; if you see references to
1578 @@ -48,8 +48,8 @@ extern void __bad_udelay(void);
1579 * first constant multiplications gets optimized away if the delay is
1580 * a constant)
1581 */
1582 -#define __udelay(n) arm_delay_ops.udelay(n)
1583 -#define __const_udelay(n) arm_delay_ops.const_udelay(n)
1584 +#define __udelay(n) arm_delay_ops->udelay(n)
1585 +#define __const_udelay(n) arm_delay_ops->const_udelay(n)
1586
1587 #define udelay(n) \
1588 (__builtin_constant_p(n) ? \
1589 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1590 index 6ddbe44..b5e38b1 100644
1591 --- a/arch/arm/include/asm/domain.h
1592 +++ b/arch/arm/include/asm/domain.h
1593 @@ -48,18 +48,37 @@
1594 * Domain types
1595 */
1596 #define DOMAIN_NOACCESS 0
1597 -#define DOMAIN_CLIENT 1
1598 #ifdef CONFIG_CPU_USE_DOMAINS
1599 +#define DOMAIN_USERCLIENT 1
1600 +#define DOMAIN_KERNELCLIENT 1
1601 #define DOMAIN_MANAGER 3
1602 +#define DOMAIN_VECTORS DOMAIN_USER
1603 #else
1604 +
1605 +#ifdef CONFIG_PAX_KERNEXEC
1606 #define DOMAIN_MANAGER 1
1607 +#define DOMAIN_KERNEXEC 3
1608 +#else
1609 +#define DOMAIN_MANAGER 1
1610 +#endif
1611 +
1612 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1613 +#define DOMAIN_USERCLIENT 0
1614 +#define DOMAIN_UDEREF 1
1615 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1616 +#else
1617 +#define DOMAIN_USERCLIENT 1
1618 +#define DOMAIN_VECTORS DOMAIN_USER
1619 +#endif
1620 +#define DOMAIN_KERNELCLIENT 1
1621 +
1622 #endif
1623
1624 #define domain_val(dom,type) ((type) << (2*(dom)))
1625
1626 #ifndef __ASSEMBLY__
1627
1628 -#ifdef CONFIG_CPU_USE_DOMAINS
1629 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1630 static inline void set_domain(unsigned val)
1631 {
1632 asm volatile(
1633 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1634 isb();
1635 }
1636
1637 -#define modify_domain(dom,type) \
1638 - do { \
1639 - struct thread_info *thread = current_thread_info(); \
1640 - unsigned int domain = thread->cpu_domain; \
1641 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1642 - thread->cpu_domain = domain | domain_val(dom, type); \
1643 - set_domain(thread->cpu_domain); \
1644 - } while (0)
1645 -
1646 +extern void modify_domain(unsigned int dom, unsigned int type);
1647 #else
1648 static inline void set_domain(unsigned val) { }
1649 static inline void modify_domain(unsigned dom, unsigned type) { }
1650 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1651 index 38050b1..9d90e8b 100644
1652 --- a/arch/arm/include/asm/elf.h
1653 +++ b/arch/arm/include/asm/elf.h
1654 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1655 the loader. We need to make sure that it is out of the way of the program
1656 that it will "exec", and that there is sufficient room for the brk. */
1657
1658 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1659 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1660 +
1661 +#ifdef CONFIG_PAX_ASLR
1662 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1663 +
1664 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1665 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1666 +#endif
1667
1668 /* When the program starts, a1 contains a pointer to a function to be
1669 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1670 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1671 extern void elf_set_personality(const struct elf32_hdr *);
1672 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1673
1674 -struct mm_struct;
1675 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1676 -#define arch_randomize_brk arch_randomize_brk
1677 -
1678 #endif
1679 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1680 index de53547..52b9a28 100644
1681 --- a/arch/arm/include/asm/fncpy.h
1682 +++ b/arch/arm/include/asm/fncpy.h
1683 @@ -81,7 +81,9 @@
1684 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1685 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1686 \
1687 + pax_open_kernel(); \
1688 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1689 + pax_close_kernel(); \
1690 flush_icache_range((unsigned long)(dest_buf), \
1691 (unsigned long)(dest_buf) + (size)); \
1692 \
1693 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1694 index e42cf59..7b94b8f 100644
1695 --- a/arch/arm/include/asm/futex.h
1696 +++ b/arch/arm/include/asm/futex.h
1697 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1698 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1699 return -EFAULT;
1700
1701 + pax_open_userland();
1702 +
1703 smp_mb();
1704 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1705 "1: ldrex %1, [%4]\n"
1706 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1707 : "cc", "memory");
1708 smp_mb();
1709
1710 + pax_close_userland();
1711 +
1712 *uval = val;
1713 return ret;
1714 }
1715 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1716 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1717 return -EFAULT;
1718
1719 + pax_open_userland();
1720 +
1721 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1722 "1: " TUSER(ldr) " %1, [%4]\n"
1723 " teq %1, %2\n"
1724 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1725 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1726 : "cc", "memory");
1727
1728 + pax_close_userland();
1729 +
1730 *uval = val;
1731 return ret;
1732 }
1733 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1734 return -EFAULT;
1735
1736 pagefault_disable(); /* implies preempt_disable() */
1737 + pax_open_userland();
1738
1739 switch (op) {
1740 case FUTEX_OP_SET:
1741 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1742 ret = -ENOSYS;
1743 }
1744
1745 + pax_close_userland();
1746 pagefault_enable(); /* subsumes preempt_enable() */
1747
1748 if (!ret) {
1749 diff --git a/arch/arm/include/asm/hardware/gic.h b/arch/arm/include/asm/hardware/gic.h
1750 index 4b1ce6c..bea3f73 100644
1751 --- a/arch/arm/include/asm/hardware/gic.h
1752 +++ b/arch/arm/include/asm/hardware/gic.h
1753 @@ -34,9 +34,10 @@
1754
1755 #ifndef __ASSEMBLY__
1756 #include <linux/irqdomain.h>
1757 +#include <linux/irq.h>
1758 struct device_node;
1759
1760 -extern struct irq_chip gic_arch_extn;
1761 +extern irq_chip_no_const gic_arch_extn;
1762
1763 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
1764 u32 offset, struct device_node *);
1765 diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h
1766 index 8c5e828..91b99ab 100644
1767 --- a/arch/arm/include/asm/highmem.h
1768 +++ b/arch/arm/include/asm/highmem.h
1769 @@ -41,6 +41,13 @@ extern void kunmap_high(struct page *page);
1770 #endif
1771 #endif
1772
1773 +/*
1774 + * Needed to be able to broadcast the TLB invalidation for kmap.
1775 + */
1776 +#ifdef CONFIG_ARM_ERRATA_798181
1777 +#undef ARCH_NEEDS_KMAP_HIGH_GET
1778 +#endif
1779 +
1780 #ifdef ARCH_NEEDS_KMAP_HIGH_GET
1781 extern void *kmap_high_get(struct page *page);
1782 #else
1783 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1784 index 83eb2f7..ed77159 100644
1785 --- a/arch/arm/include/asm/kmap_types.h
1786 +++ b/arch/arm/include/asm/kmap_types.h
1787 @@ -4,6 +4,6 @@
1788 /*
1789 * This is the "bare minimum". AIO seems to require this.
1790 */
1791 -#define KM_TYPE_NR 16
1792 +#define KM_TYPE_NR 17
1793
1794 #endif
1795 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1796 index 9e614a1..3302cca 100644
1797 --- a/arch/arm/include/asm/mach/dma.h
1798 +++ b/arch/arm/include/asm/mach/dma.h
1799 @@ -22,7 +22,7 @@ struct dma_ops {
1800 int (*residue)(unsigned int, dma_t *); /* optional */
1801 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1802 const char *type;
1803 -};
1804 +} __do_const;
1805
1806 struct dma_struct {
1807 void *addr; /* single DMA address */
1808 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1809 index 2fe141f..192dc01 100644
1810 --- a/arch/arm/include/asm/mach/map.h
1811 +++ b/arch/arm/include/asm/mach/map.h
1812 @@ -27,13 +27,16 @@ struct map_desc {
1813 #define MT_MINICLEAN 6
1814 #define MT_LOW_VECTORS 7
1815 #define MT_HIGH_VECTORS 8
1816 -#define MT_MEMORY 9
1817 +#define MT_MEMORY_RWX 9
1818 #define MT_ROM 10
1819 -#define MT_MEMORY_NONCACHED 11
1820 +#define MT_MEMORY_NONCACHED_RX 11
1821 #define MT_MEMORY_DTCM 12
1822 #define MT_MEMORY_ITCM 13
1823 #define MT_MEMORY_SO 14
1824 #define MT_MEMORY_DMA_READY 15
1825 +#define MT_MEMORY_RW 16
1826 +#define MT_MEMORY_RX 17
1827 +#define MT_MEMORY_NONCACHED_RW 18
1828
1829 #ifdef CONFIG_MMU
1830 extern void iotable_init(struct map_desc *, int);
1831 diff --git a/arch/arm/include/asm/mmu_context.h b/arch/arm/include/asm/mmu_context.h
1832 index 863a661..a7b85e0 100644
1833 --- a/arch/arm/include/asm/mmu_context.h
1834 +++ b/arch/arm/include/asm/mmu_context.h
1835 @@ -27,6 +27,8 @@ void __check_vmalloc_seq(struct mm_struct *mm);
1836 void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk);
1837 #define init_new_context(tsk,mm) ({ atomic64_set(&mm->context.id, 0); 0; })
1838
1839 +DECLARE_PER_CPU(atomic64_t, active_asids);
1840 +
1841 #else /* !CONFIG_CPU_HAS_ASID */
1842
1843 #ifdef CONFIG_MMU
1844 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1845 index 53426c6..c7baff3 100644
1846 --- a/arch/arm/include/asm/outercache.h
1847 +++ b/arch/arm/include/asm/outercache.h
1848 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1849 #endif
1850 void (*set_debug)(unsigned long);
1851 void (*resume)(void);
1852 -};
1853 +} __no_const;
1854
1855 #ifdef CONFIG_OUTER_CACHE
1856
1857 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1858 index 812a494..71fc0b6 100644
1859 --- a/arch/arm/include/asm/page.h
1860 +++ b/arch/arm/include/asm/page.h
1861 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1862 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1863 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1864 unsigned long vaddr, struct vm_area_struct *vma);
1865 -};
1866 +} __no_const;
1867
1868 #ifdef MULTI_USER
1869 extern struct cpu_user_fns cpu_user;
1870 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1871 index 943504f..c37a730 100644
1872 --- a/arch/arm/include/asm/pgalloc.h
1873 +++ b/arch/arm/include/asm/pgalloc.h
1874 @@ -17,6 +17,7 @@
1875 #include <asm/processor.h>
1876 #include <asm/cacheflush.h>
1877 #include <asm/tlbflush.h>
1878 +#include <asm/system_info.h>
1879
1880 #define check_pgt_cache() do { } while (0)
1881
1882 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1883 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1884 }
1885
1886 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1887 +{
1888 + pud_populate(mm, pud, pmd);
1889 +}
1890 +
1891 #else /* !CONFIG_ARM_LPAE */
1892
1893 /*
1894 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1895 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1896 #define pmd_free(mm, pmd) do { } while (0)
1897 #define pud_populate(mm,pmd,pte) BUG()
1898 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1899
1900 #endif /* CONFIG_ARM_LPAE */
1901
1902 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1903 __free_page(pte);
1904 }
1905
1906 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1907 +{
1908 +#ifdef CONFIG_ARM_LPAE
1909 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1910 +#else
1911 + if (addr & SECTION_SIZE)
1912 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1913 + else
1914 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1915 +#endif
1916 + flush_pmd_entry(pmdp);
1917 +}
1918 +
1919 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1920 pmdval_t prot)
1921 {
1922 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1923 static inline void
1924 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1925 {
1926 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1927 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1928 }
1929 #define pmd_pgtable(pmd) pmd_page(pmd)
1930
1931 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1932 index 5cfba15..f415e1a 100644
1933 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1934 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1935 @@ -20,12 +20,15 @@
1936 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1937 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1938 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1939 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1940 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1941 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1942 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1943 +
1944 /*
1945 * - section
1946 */
1947 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1948 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1949 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1950 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1951 @@ -37,6 +40,7 @@
1952 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1953 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1954 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1955 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1956
1957 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1958 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1959 @@ -66,6 +70,7 @@
1960 * - extended small page/tiny page
1961 */
1962 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1963 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1964 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1965 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1966 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1967 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1968 index f97ee02..07f1be5 100644
1969 --- a/arch/arm/include/asm/pgtable-2level.h
1970 +++ b/arch/arm/include/asm/pgtable-2level.h
1971 @@ -125,6 +125,7 @@
1972 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1973 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1974 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1975 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1976
1977 /*
1978 * These are the memory types, defined to be compatible with
1979 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1980 index d795282..a43ea90 100644
1981 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1982 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1983 @@ -32,15 +32,18 @@
1984 #define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0)
1985 #define PMD_BIT4 (_AT(pmdval_t, 0))
1986 #define PMD_DOMAIN(x) (_AT(pmdval_t, 0))
1987 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 59) /* PXNTable */
1988
1989 /*
1990 * - section
1991 */
1992 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1993 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1994 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1995 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1996 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1997 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1998 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 53)
1999 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 54)
2000 #define PMD_SECT_AP_WRITE (_AT(pmdval_t, 0))
2001 #define PMD_SECT_AP_READ (_AT(pmdval_t, 0))
2002 @@ -66,6 +69,7 @@
2003 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2004 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
2005 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
2006 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2007 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
2008
2009 /*
2010 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
2011 index a3f3792..7b932a6 100644
2012 --- a/arch/arm/include/asm/pgtable-3level.h
2013 +++ b/arch/arm/include/asm/pgtable-3level.h
2014 @@ -74,6 +74,7 @@
2015 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
2016 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2017 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
2018 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2019 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
2020 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
2021 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
2022 @@ -82,6 +83,7 @@
2023 /*
2024 * To be used in assembly code with the upper page attributes.
2025 */
2026 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
2027 #define L_PTE_XN_HIGH (1 << (54 - 32))
2028 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
2029
2030 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
2031 index c094749..a6ff605 100644
2032 --- a/arch/arm/include/asm/pgtable.h
2033 +++ b/arch/arm/include/asm/pgtable.h
2034 @@ -30,6 +30,9 @@
2035 #include <asm/pgtable-2level.h>
2036 #endif
2037
2038 +#define ktla_ktva(addr) (addr)
2039 +#define ktva_ktla(addr) (addr)
2040 +
2041 /*
2042 * Just any arbitrary offset to the start of the vmalloc VM area: the
2043 * current 8MB value just means that there will be a 8MB "hole" after the
2044 @@ -45,6 +48,9 @@
2045 #define LIBRARY_TEXT_START 0x0c000000
2046
2047 #ifndef __ASSEMBLY__
2048 +extern pteval_t __supported_pte_mask;
2049 +extern pmdval_t __supported_pmd_mask;
2050 +
2051 extern void __pte_error(const char *file, int line, pte_t);
2052 extern void __pmd_error(const char *file, int line, pmd_t);
2053 extern void __pgd_error(const char *file, int line, pgd_t);
2054 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2055 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2056 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2057
2058 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
2059 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2060 +
2061 +#ifdef CONFIG_PAX_KERNEXEC
2062 +#include <asm/domain.h>
2063 +#include <linux/thread_info.h>
2064 +#include <linux/preempt.h>
2065 +#endif
2066 +
2067 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2068 +static inline int test_domain(int domain, int domaintype)
2069 +{
2070 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2071 +}
2072 +#endif
2073 +
2074 +#ifdef CONFIG_PAX_KERNEXEC
2075 +static inline unsigned long pax_open_kernel(void) {
2076 +#ifdef CONFIG_ARM_LPAE
2077 + /* TODO */
2078 +#else
2079 + preempt_disable();
2080 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2081 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2082 +#endif
2083 + return 0;
2084 +}
2085 +
2086 +static inline unsigned long pax_close_kernel(void) {
2087 +#ifdef CONFIG_ARM_LPAE
2088 + /* TODO */
2089 +#else
2090 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2091 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2092 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2093 + preempt_enable_no_resched();
2094 +#endif
2095 + return 0;
2096 +}
2097 +#else
2098 +static inline unsigned long pax_open_kernel(void) { return 0; }
2099 +static inline unsigned long pax_close_kernel(void) { return 0; }
2100 +#endif
2101 +
2102 /*
2103 * This is the lowest virtual address we can permit any user space
2104 * mapping to be mapped at. This is particularly important for
2105 @@ -63,8 +113,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2106 /*
2107 * The pgprot_* and protection_map entries will be fixed up in runtime
2108 * to include the cachable and bufferable bits based on memory policy,
2109 - * as well as any architecture dependent bits like global/ASID and SMP
2110 - * shared mapping bits.
2111 + * as well as any architecture dependent bits like global/ASID, PXN,
2112 + * and SMP shared mapping bits.
2113 */
2114 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2115
2116 @@ -241,7 +291,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2117 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2118 {
2119 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2120 - L_PTE_NONE | L_PTE_VALID;
2121 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2122 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2123 return pte;
2124 }
2125 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2126 index f3628fb..a0672dd 100644
2127 --- a/arch/arm/include/asm/proc-fns.h
2128 +++ b/arch/arm/include/asm/proc-fns.h
2129 @@ -75,7 +75,7 @@ extern struct processor {
2130 unsigned int suspend_size;
2131 void (*do_suspend)(void *);
2132 void (*do_resume)(void *);
2133 -} processor;
2134 +} __do_const processor;
2135
2136 #ifndef MULTI_CPU
2137 extern void cpu_proc_init(void);
2138 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2139 index 06e7d50..8a8e251 100644
2140 --- a/arch/arm/include/asm/processor.h
2141 +++ b/arch/arm/include/asm/processor.h
2142 @@ -65,9 +65,8 @@ struct thread_struct {
2143 regs->ARM_cpsr |= PSR_ENDSTATE; \
2144 regs->ARM_pc = pc & ~1; /* pc */ \
2145 regs->ARM_sp = sp; /* sp */ \
2146 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2147 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2148 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2149 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2150 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2151 nommu_start_thread(regs); \
2152 })
2153
2154 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2155 index d3a22be..3a69ad5 100644
2156 --- a/arch/arm/include/asm/smp.h
2157 +++ b/arch/arm/include/asm/smp.h
2158 @@ -107,7 +107,7 @@ struct smp_operations {
2159 int (*cpu_disable)(unsigned int cpu);
2160 #endif
2161 #endif
2162 -};
2163 +} __no_const;
2164
2165 /*
2166 * set platform specific SMP operations
2167 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2168 index cddda1f..ff357f7 100644
2169 --- a/arch/arm/include/asm/thread_info.h
2170 +++ b/arch/arm/include/asm/thread_info.h
2171 @@ -77,9 +77,9 @@ struct thread_info {
2172 .flags = 0, \
2173 .preempt_count = INIT_PREEMPT_COUNT, \
2174 .addr_limit = KERNEL_DS, \
2175 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2176 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2177 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2178 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2179 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2180 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2181 .restart_block = { \
2182 .fn = do_no_restart_syscall, \
2183 }, \
2184 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2185 #define TIF_SYSCALL_AUDIT 9
2186 #define TIF_SYSCALL_TRACEPOINT 10
2187 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2188 +
2189 +/* within 8 bits of TIF_SYSCALL_TRACE
2190 + * to meet flexible second operand requirements
2191 + */
2192 +#define TIF_GRSEC_SETXID 12
2193 +
2194 #define TIF_USING_IWMMXT 17
2195 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2196 #define TIF_RESTORE_SIGMASK 20
2197 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2198 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2199 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2200 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2201 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2202
2203 /* Checks for any syscall work in entry-common.S */
2204 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2205 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2206 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2207
2208 /*
2209 * Change these and you break ASM code in entry-common.S
2210 diff --git a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h
2211 index 6e924d3..a9f3ddf 100644
2212 --- a/arch/arm/include/asm/tlbflush.h
2213 +++ b/arch/arm/include/asm/tlbflush.h
2214 @@ -430,6 +430,21 @@ static inline void local_flush_tlb_kernel_page(unsigned long kaddr)
2215 }
2216 }
2217
2218 +#ifdef CONFIG_ARM_ERRATA_798181
2219 +static inline void dummy_flush_tlb_a15_erratum(void)
2220 +{
2221 + /*
2222 + * Dummy TLBIMVAIS. Using the unmapped address 0 and ASID 0.
2223 + */
2224 + asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (0));
2225 + dsb();
2226 +}
2227 +#else
2228 +static inline void dummy_flush_tlb_a15_erratum(void)
2229 +{
2230 +}
2231 +#endif
2232 +
2233 /*
2234 * flush_pmd_entry
2235 *
2236 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2237 index 7e1f760..752fcb7 100644
2238 --- a/arch/arm/include/asm/uaccess.h
2239 +++ b/arch/arm/include/asm/uaccess.h
2240 @@ -18,6 +18,7 @@
2241 #include <asm/domain.h>
2242 #include <asm/unified.h>
2243 #include <asm/compiler.h>
2244 +#include <asm/pgtable.h>
2245
2246 #define VERIFY_READ 0
2247 #define VERIFY_WRITE 1
2248 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2249 #define USER_DS TASK_SIZE
2250 #define get_fs() (current_thread_info()->addr_limit)
2251
2252 +static inline void pax_open_userland(void)
2253 +{
2254 +
2255 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2256 + if (get_fs() == USER_DS) {
2257 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2258 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2259 + }
2260 +#endif
2261 +
2262 +}
2263 +
2264 +static inline void pax_close_userland(void)
2265 +{
2266 +
2267 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2268 + if (get_fs() == USER_DS) {
2269 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2270 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2271 + }
2272 +#endif
2273 +
2274 +}
2275 +
2276 static inline void set_fs(mm_segment_t fs)
2277 {
2278 current_thread_info()->addr_limit = fs;
2279 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2280 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2281 }
2282
2283 #define segment_eq(a,b) ((a) == (b))
2284 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2285
2286 #define get_user(x,p) \
2287 ({ \
2288 + int __e; \
2289 might_fault(); \
2290 - __get_user_check(x,p); \
2291 + pax_open_userland(); \
2292 + __e = __get_user_check(x,p); \
2293 + pax_close_userland(); \
2294 + __e; \
2295 })
2296
2297 extern int __put_user_1(void *, unsigned int);
2298 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2299
2300 #define put_user(x,p) \
2301 ({ \
2302 + int __e; \
2303 might_fault(); \
2304 - __put_user_check(x,p); \
2305 + pax_open_userland(); \
2306 + __e = __put_user_check(x,p); \
2307 + pax_close_userland(); \
2308 + __e; \
2309 })
2310
2311 #else /* CONFIG_MMU */
2312 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2313 #define __get_user(x,ptr) \
2314 ({ \
2315 long __gu_err = 0; \
2316 + pax_open_userland(); \
2317 __get_user_err((x),(ptr),__gu_err); \
2318 + pax_close_userland(); \
2319 __gu_err; \
2320 })
2321
2322 #define __get_user_error(x,ptr,err) \
2323 ({ \
2324 + pax_open_userland(); \
2325 __get_user_err((x),(ptr),err); \
2326 + pax_close_userland(); \
2327 (void) 0; \
2328 })
2329
2330 @@ -312,13 +349,17 @@ do { \
2331 #define __put_user(x,ptr) \
2332 ({ \
2333 long __pu_err = 0; \
2334 + pax_open_userland(); \
2335 __put_user_err((x),(ptr),__pu_err); \
2336 + pax_close_userland(); \
2337 __pu_err; \
2338 })
2339
2340 #define __put_user_error(x,ptr,err) \
2341 ({ \
2342 + pax_open_userland(); \
2343 __put_user_err((x),(ptr),err); \
2344 + pax_close_userland(); \
2345 (void) 0; \
2346 })
2347
2348 @@ -418,11 +459,44 @@ do { \
2349
2350
2351 #ifdef CONFIG_MMU
2352 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2353 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2354 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2355 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2356 +
2357 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2358 +{
2359 + unsigned long ret;
2360 +
2361 + check_object_size(to, n, false);
2362 + pax_open_userland();
2363 + ret = ___copy_from_user(to, from, n);
2364 + pax_close_userland();
2365 + return ret;
2366 +}
2367 +
2368 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2369 +{
2370 + unsigned long ret;
2371 +
2372 + check_object_size(from, n, true);
2373 + pax_open_userland();
2374 + ret = ___copy_to_user(to, from, n);
2375 + pax_close_userland();
2376 + return ret;
2377 +}
2378 +
2379 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2380 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2381 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2382 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2383 +
2384 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2385 +{
2386 + unsigned long ret;
2387 + pax_open_userland();
2388 + ret = ___clear_user(addr, n);
2389 + pax_close_userland();
2390 + return ret;
2391 +}
2392 +
2393 #else
2394 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2395 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2396 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2397
2398 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2399 {
2400 + if ((long)n < 0)
2401 + return n;
2402 +
2403 if (access_ok(VERIFY_READ, from, n))
2404 n = __copy_from_user(to, from, n);
2405 else /* security hole - plug it */
2406 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2407
2408 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2409 {
2410 + if ((long)n < 0)
2411 + return n;
2412 +
2413 if (access_ok(VERIFY_WRITE, to, n))
2414 n = __copy_to_user(to, from, n);
2415 return n;
2416 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2417 index 96ee092..37f1844 100644
2418 --- a/arch/arm/include/uapi/asm/ptrace.h
2419 +++ b/arch/arm/include/uapi/asm/ptrace.h
2420 @@ -73,7 +73,7 @@
2421 * ARMv7 groups of PSR bits
2422 */
2423 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2424 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2425 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2426 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2427 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2428
2429 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2430 index 60d3b73..d27ee09 100644
2431 --- a/arch/arm/kernel/armksyms.c
2432 +++ b/arch/arm/kernel/armksyms.c
2433 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2434 #ifdef CONFIG_MMU
2435 EXPORT_SYMBOL(copy_page);
2436
2437 -EXPORT_SYMBOL(__copy_from_user);
2438 -EXPORT_SYMBOL(__copy_to_user);
2439 -EXPORT_SYMBOL(__clear_user);
2440 +EXPORT_SYMBOL(___copy_from_user);
2441 +EXPORT_SYMBOL(___copy_to_user);
2442 +EXPORT_SYMBOL(___clear_user);
2443
2444 EXPORT_SYMBOL(__get_user_1);
2445 EXPORT_SYMBOL(__get_user_2);
2446 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2447 index 0f82098..3dbd3ee 100644
2448 --- a/arch/arm/kernel/entry-armv.S
2449 +++ b/arch/arm/kernel/entry-armv.S
2450 @@ -47,6 +47,87 @@
2451 9997:
2452 .endm
2453
2454 + .macro pax_enter_kernel
2455 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2456 + @ make aligned space for saved DACR
2457 + sub sp, sp, #8
2458 + @ save regs
2459 + stmdb sp!, {r1, r2}
2460 + @ read DACR from cpu_domain into r1
2461 + mov r2, sp
2462 + @ assume 8K pages, since we have to split the immediate in two
2463 + bic r2, r2, #(0x1fc0)
2464 + bic r2, r2, #(0x3f)
2465 + ldr r1, [r2, #TI_CPU_DOMAIN]
2466 + @ store old DACR on stack
2467 + str r1, [sp, #8]
2468 +#ifdef CONFIG_PAX_KERNEXEC
2469 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2470 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2471 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2472 +#endif
2473 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2474 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2475 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2476 +#endif
2477 + @ write r1 to current_thread_info()->cpu_domain
2478 + str r1, [r2, #TI_CPU_DOMAIN]
2479 + @ write r1 to DACR
2480 + mcr p15, 0, r1, c3, c0, 0
2481 + @ instruction sync
2482 + instr_sync
2483 + @ restore regs
2484 + ldmia sp!, {r1, r2}
2485 +#endif
2486 + .endm
2487 +
2488 + .macro pax_open_userland
2489 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2490 + @ save regs
2491 + stmdb sp!, {r0, r1}
2492 + @ read DACR from cpu_domain into r1
2493 + mov r0, sp
2494 + @ assume 8K pages, since we have to split the immediate in two
2495 + bic r0, r0, #(0x1fc0)
2496 + bic r0, r0, #(0x3f)
2497 + ldr r1, [r0, #TI_CPU_DOMAIN]
2498 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2499 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2500 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2501 + @ write r1 to current_thread_info()->cpu_domain
2502 + str r1, [r0, #TI_CPU_DOMAIN]
2503 + @ write r1 to DACR
2504 + mcr p15, 0, r1, c3, c0, 0
2505 + @ instruction sync
2506 + instr_sync
2507 + @ restore regs
2508 + ldmia sp!, {r0, r1}
2509 +#endif
2510 + .endm
2511 +
2512 + .macro pax_close_userland
2513 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2514 + @ save regs
2515 + stmdb sp!, {r0, r1}
2516 + @ read DACR from cpu_domain into r1
2517 + mov r0, sp
2518 + @ assume 8K pages, since we have to split the immediate in two
2519 + bic r0, r0, #(0x1fc0)
2520 + bic r0, r0, #(0x3f)
2521 + ldr r1, [r0, #TI_CPU_DOMAIN]
2522 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2523 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2524 + @ write r1 to current_thread_info()->cpu_domain
2525 + str r1, [r0, #TI_CPU_DOMAIN]
2526 + @ write r1 to DACR
2527 + mcr p15, 0, r1, c3, c0, 0
2528 + @ instruction sync
2529 + instr_sync
2530 + @ restore regs
2531 + ldmia sp!, {r0, r1}
2532 +#endif
2533 + .endm
2534 +
2535 .macro pabt_helper
2536 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2537 #ifdef MULTI_PABORT
2538 @@ -89,11 +170,15 @@
2539 * Invalid mode handlers
2540 */
2541 .macro inv_entry, reason
2542 +
2543 + pax_enter_kernel
2544 +
2545 sub sp, sp, #S_FRAME_SIZE
2546 ARM( stmib sp, {r1 - lr} )
2547 THUMB( stmia sp, {r0 - r12} )
2548 THUMB( str sp, [sp, #S_SP] )
2549 THUMB( str lr, [sp, #S_LR] )
2550 +
2551 mov r1, #\reason
2552 .endm
2553
2554 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2555 .macro svc_entry, stack_hole=0
2556 UNWIND(.fnstart )
2557 UNWIND(.save {r0 - pc} )
2558 +
2559 + pax_enter_kernel
2560 +
2561 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2562 +
2563 #ifdef CONFIG_THUMB2_KERNEL
2564 SPFIX( str r0, [sp] ) @ temporarily saved
2565 SPFIX( mov r0, sp )
2566 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2567 ldmia r0, {r3 - r5}
2568 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2569 mov r6, #-1 @ "" "" "" ""
2570 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2571 + @ offset sp by 8 as done in pax_enter_kernel
2572 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2573 +#else
2574 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2575 +#endif
2576 SPFIX( addeq r2, r2, #4 )
2577 str r3, [sp, #-4]! @ save the "real" r0 copied
2578 @ from the exception stack
2579 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2580 .macro usr_entry
2581 UNWIND(.fnstart )
2582 UNWIND(.cantunwind ) @ don't unwind the user space
2583 +
2584 + pax_enter_kernel_user
2585 +
2586 sub sp, sp, #S_FRAME_SIZE
2587 ARM( stmib sp, {r1 - r12} )
2588 THUMB( stmia sp, {r0 - r12} )
2589 @@ -456,7 +553,9 @@ __und_usr:
2590 tst r3, #PSR_T_BIT @ Thumb mode?
2591 bne __und_usr_thumb
2592 sub r4, r2, #4 @ ARM instr at LR - 4
2593 + pax_open_userland
2594 1: ldrt r0, [r4]
2595 + pax_close_userland
2596 #ifdef CONFIG_CPU_ENDIAN_BE8
2597 rev r0, r0 @ little endian instruction
2598 #endif
2599 @@ -491,10 +590,14 @@ __und_usr_thumb:
2600 */
2601 .arch armv6t2
2602 #endif
2603 + pax_open_userland
2604 2: ldrht r5, [r4]
2605 + pax_close_userland
2606 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2607 blo __und_usr_fault_16 @ 16bit undefined instruction
2608 + pax_open_userland
2609 3: ldrht r0, [r2]
2610 + pax_close_userland
2611 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2612 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2613 orr r0, r0, r5, lsl #16
2614 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2615 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2616 THUMB( str sp, [ip], #4 )
2617 THUMB( str lr, [ip], #4 )
2618 -#ifdef CONFIG_CPU_USE_DOMAINS
2619 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2620 ldr r6, [r2, #TI_CPU_DOMAIN]
2621 #endif
2622 set_tls r3, r4, r5
2623 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2624 ldr r8, =__stack_chk_guard
2625 ldr r7, [r7, #TSK_STACK_CANARY]
2626 #endif
2627 -#ifdef CONFIG_CPU_USE_DOMAINS
2628 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2629 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2630 #endif
2631 mov r5, r0
2632 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2633 index a6c301e..908821b 100644
2634 --- a/arch/arm/kernel/entry-common.S
2635 +++ b/arch/arm/kernel/entry-common.S
2636 @@ -10,18 +10,46 @@
2637
2638 #include <asm/unistd.h>
2639 #include <asm/ftrace.h>
2640 +#include <asm/domain.h>
2641 #include <asm/unwind.h>
2642
2643 +#include "entry-header.S"
2644 +
2645 #ifdef CONFIG_NEED_RET_TO_USER
2646 #include <mach/entry-macro.S>
2647 #else
2648 .macro arch_ret_to_user, tmp1, tmp2
2649 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2650 + @ save regs
2651 + stmdb sp!, {r1, r2}
2652 + @ read DACR from cpu_domain into r1
2653 + mov r2, sp
2654 + @ assume 8K pages, since we have to split the immediate in two
2655 + bic r2, r2, #(0x1fc0)
2656 + bic r2, r2, #(0x3f)
2657 + ldr r1, [r2, #TI_CPU_DOMAIN]
2658 +#ifdef CONFIG_PAX_KERNEXEC
2659 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2660 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2661 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2662 +#endif
2663 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2664 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2665 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2666 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2667 +#endif
2668 + @ write r1 to current_thread_info()->cpu_domain
2669 + str r1, [r2, #TI_CPU_DOMAIN]
2670 + @ write r1 to DACR
2671 + mcr p15, 0, r1, c3, c0, 0
2672 + @ instruction sync
2673 + instr_sync
2674 + @ restore regs
2675 + ldmia sp!, {r1, r2}
2676 +#endif
2677 .endm
2678 #endif
2679
2680 -#include "entry-header.S"
2681 -
2682 -
2683 .align 5
2684 /*
2685 * This is the fast syscall return path. We do as little as
2686 @@ -339,6 +367,7 @@ ENDPROC(ftrace_stub)
2687
2688 .align 5
2689 ENTRY(vector_swi)
2690 +
2691 sub sp, sp, #S_FRAME_SIZE
2692 stmia sp, {r0 - r12} @ Calling r0 - r12
2693 ARM( add r8, sp, #S_PC )
2694 @@ -388,6 +417,12 @@ ENTRY(vector_swi)
2695 ldr scno, [lr, #-4] @ get SWI instruction
2696 #endif
2697
2698 + /*
2699 + * do this here to avoid a performance hit of wrapping the code above
2700 + * that directly dereferences userland to parse the SWI instruction
2701 + */
2702 + pax_enter_kernel_user
2703 +
2704 #ifdef CONFIG_ALIGNMENT_TRAP
2705 ldr ip, __cr_alignment
2706 ldr ip, [ip]
2707 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2708 index 9a8531e..812e287 100644
2709 --- a/arch/arm/kernel/entry-header.S
2710 +++ b/arch/arm/kernel/entry-header.S
2711 @@ -73,9 +73,66 @@
2712 msr cpsr_c, \rtemp @ switch back to the SVC mode
2713 .endm
2714
2715 + .macro pax_enter_kernel_user
2716 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2717 + @ save regs
2718 + stmdb sp!, {r0, r1}
2719 + @ read DACR from cpu_domain into r1
2720 + mov r0, sp
2721 + @ assume 8K pages, since we have to split the immediate in two
2722 + bic r0, r0, #(0x1fc0)
2723 + bic r0, r0, #(0x3f)
2724 + ldr r1, [r0, #TI_CPU_DOMAIN]
2725 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2726 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2727 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2728 +#endif
2729 +#ifdef CONFIG_PAX_KERNEXEC
2730 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2731 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2732 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2733 +#endif
2734 + @ write r1 to current_thread_info()->cpu_domain
2735 + str r1, [r0, #TI_CPU_DOMAIN]
2736 + @ write r1 to DACR
2737 + mcr p15, 0, r1, c3, c0, 0
2738 + @ instruction sync
2739 + instr_sync
2740 + @ restore regs
2741 + ldmia sp!, {r0, r1}
2742 +#endif
2743 + .endm
2744 +
2745 + .macro pax_exit_kernel
2746 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2747 + @ save regs
2748 + stmdb sp!, {r0, r1}
2749 + @ read old DACR from stack into r1
2750 + ldr r1, [sp, #(8 + S_SP)]
2751 + sub r1, r1, #8
2752 + ldr r1, [r1]
2753 +
2754 + @ write r1 to current_thread_info()->cpu_domain
2755 + mov r0, sp
2756 + @ assume 8K pages, since we have to split the immediate in two
2757 + bic r0, r0, #(0x1fc0)
2758 + bic r0, r0, #(0x3f)
2759 + str r1, [r0, #TI_CPU_DOMAIN]
2760 + @ write r1 to DACR
2761 + mcr p15, 0, r1, c3, c0, 0
2762 + @ instruction sync
2763 + instr_sync
2764 + @ restore regs
2765 + ldmia sp!, {r0, r1}
2766 +#endif
2767 + .endm
2768 +
2769 #ifndef CONFIG_THUMB2_KERNEL
2770 .macro svc_exit, rpsr
2771 msr spsr_cxsf, \rpsr
2772 +
2773 + pax_exit_kernel
2774 +
2775 #if defined(CONFIG_CPU_V6)
2776 ldr r0, [sp]
2777 strex r1, r2, [sp] @ clear the exclusive monitor
2778 @@ -121,6 +178,9 @@
2779 .endm
2780 #else /* CONFIG_THUMB2_KERNEL */
2781 .macro svc_exit, rpsr
2782 +
2783 + pax_exit_kernel
2784 +
2785 ldr lr, [sp, #S_SP] @ top of the stack
2786 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2787 clrex @ clear the exclusive monitor
2788 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2789 index 2adda11..7fbe958 100644
2790 --- a/arch/arm/kernel/fiq.c
2791 +++ b/arch/arm/kernel/fiq.c
2792 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2793 #if defined(CONFIG_CPU_USE_DOMAINS)
2794 memcpy((void *)0xffff001c, start, length);
2795 #else
2796 + pax_open_kernel();
2797 memcpy(vectors_page + 0x1c, start, length);
2798 + pax_close_kernel();
2799 #endif
2800 flush_icache_range(0xffff001c, 0xffff001c + length);
2801 if (!vectors_high())
2802 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2803 index e0eb9a1..caee108 100644
2804 --- a/arch/arm/kernel/head.S
2805 +++ b/arch/arm/kernel/head.S
2806 @@ -52,7 +52,9 @@
2807 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2808
2809 .macro pgtbl, rd, phys
2810 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2811 + mov \rd, #TEXT_OFFSET
2812 + sub \rd, #PG_DIR_SIZE
2813 + add \rd, \rd, \phys
2814 .endm
2815
2816 /*
2817 @@ -267,7 +269,7 @@ __create_page_tables:
2818 addne r6, r6, #1 << SECTION_SHIFT
2819 strne r6, [r3]
2820
2821 -#if defined(CONFIG_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2822 +#if defined(CONFIG_ARM_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2823 sub r4, r4, #4 @ Fixup page table pointer
2824 @ for 64-bit descriptors
2825 #endif
2826 @@ -434,7 +436,7 @@ __enable_mmu:
2827 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2828 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2829 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2830 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2831 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2832 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2833 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2834 #endif
2835 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2836 index 5ff2e77..556d030 100644
2837 --- a/arch/arm/kernel/hw_breakpoint.c
2838 +++ b/arch/arm/kernel/hw_breakpoint.c
2839 @@ -1011,7 +1011,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2840 return NOTIFY_OK;
2841 }
2842
2843 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2844 +static struct notifier_block dbg_reset_nb = {
2845 .notifier_call = dbg_reset_notify,
2846 };
2847
2848 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2849 index 1e9be5d..03edbc2 100644
2850 --- a/arch/arm/kernel/module.c
2851 +++ b/arch/arm/kernel/module.c
2852 @@ -37,12 +37,37 @@
2853 #endif
2854
2855 #ifdef CONFIG_MMU
2856 -void *module_alloc(unsigned long size)
2857 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2858 {
2859 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2860 + return NULL;
2861 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2862 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2863 + GFP_KERNEL, prot, -1,
2864 __builtin_return_address(0));
2865 }
2866 +
2867 +void *module_alloc(unsigned long size)
2868 +{
2869 +
2870 +#ifdef CONFIG_PAX_KERNEXEC
2871 + return __module_alloc(size, PAGE_KERNEL);
2872 +#else
2873 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2874 +#endif
2875 +
2876 +}
2877 +
2878 +#ifdef CONFIG_PAX_KERNEXEC
2879 +void module_free_exec(struct module *mod, void *module_region)
2880 +{
2881 + module_free(mod, module_region);
2882 +}
2883 +
2884 +void *module_alloc_exec(unsigned long size)
2885 +{
2886 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2887 +}
2888 +#endif
2889 #endif
2890
2891 int
2892 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2893 index 07314af..c46655c 100644
2894 --- a/arch/arm/kernel/patch.c
2895 +++ b/arch/arm/kernel/patch.c
2896 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2897 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2898 int size;
2899
2900 + pax_open_kernel();
2901 if (thumb2 && __opcode_is_thumb16(insn)) {
2902 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2903 size = sizeof(u16);
2904 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2905 *(u32 *)addr = insn;
2906 size = sizeof(u32);
2907 }
2908 + pax_close_kernel();
2909
2910 flush_icache_range((uintptr_t)(addr),
2911 (uintptr_t)(addr) + size);
2912 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2913 index 5f66206..dce492f 100644
2914 --- a/arch/arm/kernel/perf_event_cpu.c
2915 +++ b/arch/arm/kernel/perf_event_cpu.c
2916 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2917 return NOTIFY_OK;
2918 }
2919
2920 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2921 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2922 .notifier_call = cpu_pmu_notify,
2923 };
2924
2925 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2926 index c6dec5f..e0fddd1 100644
2927 --- a/arch/arm/kernel/process.c
2928 +++ b/arch/arm/kernel/process.c
2929 @@ -28,7 +28,6 @@
2930 #include <linux/tick.h>
2931 #include <linux/utsname.h>
2932 #include <linux/uaccess.h>
2933 -#include <linux/random.h>
2934 #include <linux/hw_breakpoint.h>
2935 #include <linux/cpuidle.h>
2936 #include <linux/leds.h>
2937 @@ -256,9 +255,10 @@ void machine_power_off(void)
2938 machine_shutdown();
2939 if (pm_power_off)
2940 pm_power_off();
2941 + BUG();
2942 }
2943
2944 -void machine_restart(char *cmd)
2945 +__noreturn void machine_restart(char *cmd)
2946 {
2947 machine_shutdown();
2948
2949 @@ -283,8 +283,8 @@ void __show_regs(struct pt_regs *regs)
2950 init_utsname()->release,
2951 (int)strcspn(init_utsname()->version, " "),
2952 init_utsname()->version);
2953 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2954 - print_symbol("LR is at %s\n", regs->ARM_lr);
2955 + printk("PC is at %pA\n", instruction_pointer(regs));
2956 + printk("LR is at %pA\n", regs->ARM_lr);
2957 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2958 "sp : %08lx ip : %08lx fp : %08lx\n",
2959 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2960 @@ -452,12 +452,6 @@ unsigned long get_wchan(struct task_struct *p)
2961 return 0;
2962 }
2963
2964 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2965 -{
2966 - unsigned long range_end = mm->brk + 0x02000000;
2967 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2968 -}
2969 -
2970 #ifdef CONFIG_MMU
2971 /*
2972 * The vectors page is always readable from user space for the
2973 @@ -470,9 +464,8 @@ static int __init gate_vma_init(void)
2974 {
2975 gate_vma.vm_start = 0xffff0000;
2976 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2977 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2978 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2979 - VM_MAYREAD | VM_MAYEXEC;
2980 + gate_vma.vm_flags = VM_NONE;
2981 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2982 return 0;
2983 }
2984 arch_initcall(gate_vma_init);
2985 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2986 index 03deeff..741ce88 100644
2987 --- a/arch/arm/kernel/ptrace.c
2988 +++ b/arch/arm/kernel/ptrace.c
2989 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2990 return current_thread_info()->syscall;
2991 }
2992
2993 +#ifdef CONFIG_GRKERNSEC_SETXID
2994 +extern void gr_delayed_cred_worker(void);
2995 +#endif
2996 +
2997 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2998 {
2999 current_thread_info()->syscall = scno;
3000
3001 +#ifdef CONFIG_GRKERNSEC_SETXID
3002 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
3003 + gr_delayed_cred_worker();
3004 +#endif
3005 +
3006 /* Do the secure computing check first; failures should be fast. */
3007 if (secure_computing(scno) == -1)
3008 return -1;
3009 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
3010 index 3f6cbb2..39305c7 100644
3011 --- a/arch/arm/kernel/setup.c
3012 +++ b/arch/arm/kernel/setup.c
3013 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
3014 unsigned int elf_hwcap __read_mostly;
3015 EXPORT_SYMBOL(elf_hwcap);
3016
3017 +pteval_t __supported_pte_mask __read_only;
3018 +pmdval_t __supported_pmd_mask __read_only;
3019
3020 #ifdef MULTI_CPU
3021 -struct processor processor __read_mostly;
3022 +struct processor processor;
3023 #endif
3024 #ifdef MULTI_TLB
3025 -struct cpu_tlb_fns cpu_tlb __read_mostly;
3026 +struct cpu_tlb_fns cpu_tlb __read_only;
3027 #endif
3028 #ifdef MULTI_USER
3029 -struct cpu_user_fns cpu_user __read_mostly;
3030 +struct cpu_user_fns cpu_user __read_only;
3031 #endif
3032 #ifdef MULTI_CACHE
3033 -struct cpu_cache_fns cpu_cache __read_mostly;
3034 +struct cpu_cache_fns cpu_cache __read_only;
3035 #endif
3036 #ifdef CONFIG_OUTER_CACHE
3037 -struct outer_cache_fns outer_cache __read_mostly;
3038 +struct outer_cache_fns outer_cache __read_only;
3039 EXPORT_SYMBOL(outer_cache);
3040 #endif
3041
3042 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
3043 asm("mrc p15, 0, %0, c0, c1, 4"
3044 : "=r" (mmfr0));
3045 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3046 - (mmfr0 & 0x000000f0) >= 0x00000030)
3047 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3048 cpu_arch = CPU_ARCH_ARMv7;
3049 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3050 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3051 + __supported_pte_mask |= L_PTE_PXN;
3052 + __supported_pmd_mask |= PMD_PXNTABLE;
3053 + }
3054 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3055 (mmfr0 & 0x000000f0) == 0x00000020)
3056 cpu_arch = CPU_ARCH_ARMv6;
3057 else
3058 @@ -462,7 +468,7 @@ static void __init setup_processor(void)
3059 __cpu_architecture = __get_cpu_architecture();
3060
3061 #ifdef MULTI_CPU
3062 - processor = *list->proc;
3063 + memcpy((void *)&processor, list->proc, sizeof processor);
3064 #endif
3065 #ifdef MULTI_TLB
3066 cpu_tlb = *list->tlb;
3067 @@ -524,7 +530,7 @@ int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
3068 size -= start & ~PAGE_MASK;
3069 bank->start = PAGE_ALIGN(start);
3070
3071 -#ifndef CONFIG_LPAE
3072 +#ifndef CONFIG_ARM_LPAE
3073 if (bank->start + size < bank->start) {
3074 printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
3075 "32-bit physical address space\n", (long long)start);
3076 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3077 index 56f72d2..6924200 100644
3078 --- a/arch/arm/kernel/signal.c
3079 +++ b/arch/arm/kernel/signal.c
3080 @@ -433,22 +433,14 @@ setup_return(struct pt_regs *regs, struct k_sigaction *ka,
3081 __put_user(sigreturn_codes[idx+1], rc+1))
3082 return 1;
3083
3084 - if (cpsr & MODE32_BIT) {
3085 - /*
3086 - * 32-bit code can use the new high-page
3087 - * signal return code support.
3088 - */
3089 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
3090 - } else {
3091 - /*
3092 - * Ensure that the instruction cache sees
3093 - * the return code written onto the stack.
3094 - */
3095 - flush_icache_range((unsigned long)rc,
3096 - (unsigned long)(rc + 2));
3097 + /*
3098 + * Ensure that the instruction cache sees
3099 + * the return code written onto the stack.
3100 + */
3101 + flush_icache_range((unsigned long)rc,
3102 + (unsigned long)(rc + 2));
3103
3104 - retcode = ((unsigned long)rc) + thumb;
3105 - }
3106 + retcode = ((unsigned long)rc) + thumb;
3107 }
3108
3109 regs->ARM_r0 = usig;
3110 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3111 index 58af91c..343ce99 100644
3112 --- a/arch/arm/kernel/smp.c
3113 +++ b/arch/arm/kernel/smp.c
3114 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3115
3116 static DECLARE_COMPLETION(cpu_running);
3117
3118 -static struct smp_operations smp_ops;
3119 +static struct smp_operations smp_ops __read_only;
3120
3121 void __init smp_set_ops(struct smp_operations *ops)
3122 {
3123 diff --git a/arch/arm/kernel/smp_tlb.c b/arch/arm/kernel/smp_tlb.c
3124 index 02c5d2c..e5695ad 100644
3125 --- a/arch/arm/kernel/smp_tlb.c
3126 +++ b/arch/arm/kernel/smp_tlb.c
3127 @@ -12,6 +12,7 @@
3128
3129 #include <asm/smp_plat.h>
3130 #include <asm/tlbflush.h>
3131 +#include <asm/mmu_context.h>
3132
3133 /**********************************************************************/
3134
3135 @@ -64,12 +65,72 @@ static inline void ipi_flush_tlb_kernel_range(void *arg)
3136 local_flush_tlb_kernel_range(ta->ta_start, ta->ta_end);
3137 }
3138
3139 +#ifdef CONFIG_ARM_ERRATA_798181
3140 +static int erratum_a15_798181(void)
3141 +{
3142 + unsigned int midr = read_cpuid_id();
3143 +
3144 + /* Cortex-A15 r0p0..r3p2 affected */
3145 + if ((midr & 0xff0ffff0) != 0x410fc0f0 || midr > 0x413fc0f2)
3146 + return 0;
3147 + return 1;
3148 +}
3149 +#else
3150 +static int erratum_a15_798181(void)
3151 +{
3152 + return 0;
3153 +}
3154 +#endif
3155 +
3156 +static void ipi_flush_tlb_a15_erratum(void *arg)
3157 +{
3158 + dmb();
3159 +}
3160 +
3161 +static void broadcast_tlb_a15_erratum(void)
3162 +{
3163 + if (!erratum_a15_798181())
3164 + return;
3165 +
3166 + dummy_flush_tlb_a15_erratum();
3167 + smp_call_function_many(cpu_online_mask, ipi_flush_tlb_a15_erratum,
3168 + NULL, 1);
3169 +}
3170 +
3171 +static void broadcast_tlb_mm_a15_erratum(struct mm_struct *mm)
3172 +{
3173 + int cpu;
3174 + cpumask_t mask = { CPU_BITS_NONE };
3175 +
3176 + if (!erratum_a15_798181())
3177 + return;
3178 +
3179 + dummy_flush_tlb_a15_erratum();
3180 + for_each_online_cpu(cpu) {
3181 + if (cpu == smp_processor_id())
3182 + continue;
3183 + /*
3184 + * We only need to send an IPI if the other CPUs are running
3185 + * the same ASID as the one being invalidated. There is no
3186 + * need for locking around the active_asids check since the
3187 + * switch_mm() function has at least one dmb() (as required by
3188 + * this workaround) in case a context switch happens on
3189 + * another CPU after the condition below.
3190 + */
3191 + if (atomic64_read(&mm->context.id) ==
3192 + atomic64_read(&per_cpu(active_asids, cpu)))
3193 + cpumask_set_cpu(cpu, &mask);
3194 + }
3195 + smp_call_function_many(&mask, ipi_flush_tlb_a15_erratum, NULL, 1);
3196 +}
3197 +
3198 void flush_tlb_all(void)
3199 {
3200 if (tlb_ops_need_broadcast())
3201 on_each_cpu(ipi_flush_tlb_all, NULL, 1);
3202 else
3203 local_flush_tlb_all();
3204 + broadcast_tlb_a15_erratum();
3205 }
3206
3207 void flush_tlb_mm(struct mm_struct *mm)
3208 @@ -78,6 +139,7 @@ void flush_tlb_mm(struct mm_struct *mm)
3209 on_each_cpu_mask(mm_cpumask(mm), ipi_flush_tlb_mm, mm, 1);
3210 else
3211 local_flush_tlb_mm(mm);
3212 + broadcast_tlb_mm_a15_erratum(mm);
3213 }
3214
3215 void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3216 @@ -90,6 +152,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3217 &ta, 1);
3218 } else
3219 local_flush_tlb_page(vma, uaddr);
3220 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3221 }
3222
3223 void flush_tlb_kernel_page(unsigned long kaddr)
3224 @@ -100,6 +163,7 @@ void flush_tlb_kernel_page(unsigned long kaddr)
3225 on_each_cpu(ipi_flush_tlb_kernel_page, &ta, 1);
3226 } else
3227 local_flush_tlb_kernel_page(kaddr);
3228 + broadcast_tlb_a15_erratum();
3229 }
3230
3231 void flush_tlb_range(struct vm_area_struct *vma,
3232 @@ -114,6 +178,7 @@ void flush_tlb_range(struct vm_area_struct *vma,
3233 &ta, 1);
3234 } else
3235 local_flush_tlb_range(vma, start, end);
3236 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3237 }
3238
3239 void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3240 @@ -125,5 +190,6 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3241 on_each_cpu(ipi_flush_tlb_kernel_range, &ta, 1);
3242 } else
3243 local_flush_tlb_kernel_range(start, end);
3244 + broadcast_tlb_a15_erratum();
3245 }
3246
3247 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3248 index b0179b8..829510e 100644
3249 --- a/arch/arm/kernel/traps.c
3250 +++ b/arch/arm/kernel/traps.c
3251 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3252 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3253 {
3254 #ifdef CONFIG_KALLSYMS
3255 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3256 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3257 #else
3258 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3259 #endif
3260 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3261 static int die_owner = -1;
3262 static unsigned int die_nest_count;
3263
3264 +extern void gr_handle_kernel_exploit(void);
3265 +
3266 static unsigned long oops_begin(void)
3267 {
3268 int cpu;
3269 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3270 panic("Fatal exception in interrupt");
3271 if (panic_on_oops)
3272 panic("Fatal exception");
3273 +
3274 + gr_handle_kernel_exploit();
3275 +
3276 if (signr)
3277 do_exit(signr);
3278 }
3279 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3280 * The user helper at 0xffff0fe0 must be used instead.
3281 * (see entry-armv.S for details)
3282 */
3283 + pax_open_kernel();
3284 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3285 + pax_close_kernel();
3286 }
3287 return 0;
3288
3289 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3290 */
3291 kuser_get_tls_init(vectors);
3292
3293 - /*
3294 - * Copy signal return handlers into the vector page, and
3295 - * set sigreturn to be a pointer to these.
3296 - */
3297 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3298 - sigreturn_codes, sizeof(sigreturn_codes));
3299 -
3300 flush_icache_range(vectors, vectors + PAGE_SIZE);
3301 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3302 +
3303 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3304 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3305 +#endif
3306 +
3307 }
3308 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3309 index 11c1785..c67d54c 100644
3310 --- a/arch/arm/kernel/vmlinux.lds.S
3311 +++ b/arch/arm/kernel/vmlinux.lds.S
3312 @@ -8,7 +8,11 @@
3313 #include <asm/thread_info.h>
3314 #include <asm/memory.h>
3315 #include <asm/page.h>
3316 -
3317 +
3318 +#ifdef CONFIG_PAX_KERNEXEC
3319 +#include <asm/pgtable.h>
3320 +#endif
3321 +
3322 #define PROC_INFO \
3323 . = ALIGN(4); \
3324 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3325 @@ -90,6 +94,11 @@ SECTIONS
3326 _text = .;
3327 HEAD_TEXT
3328 }
3329 +
3330 +#ifdef CONFIG_PAX_KERNEXEC
3331 + . = ALIGN(1<<SECTION_SHIFT);
3332 +#endif
3333 +
3334 .text : { /* Real text segment */
3335 _stext = .; /* Text and read-only data */
3336 __exception_text_start = .;
3337 @@ -144,6 +153,10 @@ SECTIONS
3338
3339 _etext = .; /* End of text and rodata section */
3340
3341 +#ifdef CONFIG_PAX_KERNEXEC
3342 + . = ALIGN(1<<SECTION_SHIFT);
3343 +#endif
3344 +
3345 #ifndef CONFIG_XIP_KERNEL
3346 . = ALIGN(PAGE_SIZE);
3347 __init_begin = .;
3348 @@ -203,6 +216,11 @@ SECTIONS
3349 . = PAGE_OFFSET + TEXT_OFFSET;
3350 #else
3351 __init_end = .;
3352 +
3353 +#ifdef CONFIG_PAX_KERNEXEC
3354 + . = ALIGN(1<<SECTION_SHIFT);
3355 +#endif
3356 +
3357 . = ALIGN(THREAD_SIZE);
3358 __data_loc = .;
3359 #endif
3360 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3361 index 14a0d98..7771a7d 100644
3362 --- a/arch/arm/lib/clear_user.S
3363 +++ b/arch/arm/lib/clear_user.S
3364 @@ -12,14 +12,14 @@
3365
3366 .text
3367
3368 -/* Prototype: int __clear_user(void *addr, size_t sz)
3369 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3370 * Purpose : clear some user memory
3371 * Params : addr - user memory address to clear
3372 * : sz - number of bytes to clear
3373 * Returns : number of bytes NOT cleared
3374 */
3375 ENTRY(__clear_user_std)
3376 -WEAK(__clear_user)
3377 +WEAK(___clear_user)
3378 stmfd sp!, {r1, lr}
3379 mov r2, #0
3380 cmp r1, #4
3381 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3382 USER( strnebt r2, [r0])
3383 mov r0, #0
3384 ldmfd sp!, {r1, pc}
3385 -ENDPROC(__clear_user)
3386 +ENDPROC(___clear_user)
3387 ENDPROC(__clear_user_std)
3388
3389 .pushsection .fixup,"ax"
3390 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3391 index 66a477a..bee61d3 100644
3392 --- a/arch/arm/lib/copy_from_user.S
3393 +++ b/arch/arm/lib/copy_from_user.S
3394 @@ -16,7 +16,7 @@
3395 /*
3396 * Prototype:
3397 *
3398 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3399 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3400 *
3401 * Purpose:
3402 *
3403 @@ -84,11 +84,11 @@
3404
3405 .text
3406
3407 -ENTRY(__copy_from_user)
3408 +ENTRY(___copy_from_user)
3409
3410 #include "copy_template.S"
3411
3412 -ENDPROC(__copy_from_user)
3413 +ENDPROC(___copy_from_user)
3414
3415 .pushsection .fixup,"ax"
3416 .align 0
3417 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3418 index 6ee2f67..d1cce76 100644
3419 --- a/arch/arm/lib/copy_page.S
3420 +++ b/arch/arm/lib/copy_page.S
3421 @@ -10,6 +10,7 @@
3422 * ASM optimised string functions
3423 */
3424 #include <linux/linkage.h>
3425 +#include <linux/const.h>
3426 #include <asm/assembler.h>
3427 #include <asm/asm-offsets.h>
3428 #include <asm/cache.h>
3429 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3430 index d066df6..df28194 100644
3431 --- a/arch/arm/lib/copy_to_user.S
3432 +++ b/arch/arm/lib/copy_to_user.S
3433 @@ -16,7 +16,7 @@
3434 /*
3435 * Prototype:
3436 *
3437 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3438 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3439 *
3440 * Purpose:
3441 *
3442 @@ -88,11 +88,11 @@
3443 .text
3444
3445 ENTRY(__copy_to_user_std)
3446 -WEAK(__copy_to_user)
3447 +WEAK(___copy_to_user)
3448
3449 #include "copy_template.S"
3450
3451 -ENDPROC(__copy_to_user)
3452 +ENDPROC(___copy_to_user)
3453 ENDPROC(__copy_to_user_std)
3454
3455 .pushsection .fixup,"ax"
3456 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3457 index 7d08b43..f7ca7ea 100644
3458 --- a/arch/arm/lib/csumpartialcopyuser.S
3459 +++ b/arch/arm/lib/csumpartialcopyuser.S
3460 @@ -57,8 +57,8 @@
3461 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3462 */
3463
3464 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3465 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3466 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3467 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3468
3469 #include "csumpartialcopygeneric.S"
3470
3471 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3472 index 6b93f6a..1aa92d0 100644
3473 --- a/arch/arm/lib/delay.c
3474 +++ b/arch/arm/lib/delay.c
3475 @@ -28,12 +28,15 @@
3476 /*
3477 * Default to the loop-based delay implementation.
3478 */
3479 -struct arm_delay_ops arm_delay_ops = {
3480 +static struct arm_delay_ops arm_loop_delay_ops = {
3481 .delay = __loop_delay,
3482 .const_udelay = __loop_const_udelay,
3483 .udelay = __loop_udelay,
3484 + .const_clock = false,
3485 };
3486
3487 +struct arm_delay_ops *arm_delay_ops __read_only = &arm_loop_delay_ops;
3488 +
3489 static const struct delay_timer *delay_timer;
3490 static bool delay_calibrated;
3491
3492 @@ -67,6 +70,13 @@ static void __timer_udelay(unsigned long usecs)
3493 __timer_const_udelay(usecs * UDELAY_MULT);
3494 }
3495
3496 +static struct arm_delay_ops arm_timer_delay_ops = {
3497 + .delay = __timer_delay,
3498 + .const_udelay = __timer_const_udelay,
3499 + .udelay = __timer_udelay,
3500 + .const_clock = true,
3501 +};
3502 +
3503 void __init register_current_timer_delay(const struct delay_timer *timer)
3504 {
3505 if (!delay_calibrated) {
3506 @@ -74,10 +84,7 @@ void __init register_current_timer_delay(const struct delay_timer *timer)
3507 delay_timer = timer;
3508 lpj_fine = timer->freq / HZ;
3509 loops_per_jiffy = lpj_fine;
3510 - arm_delay_ops.delay = __timer_delay;
3511 - arm_delay_ops.const_udelay = __timer_const_udelay;
3512 - arm_delay_ops.udelay = __timer_udelay;
3513 - arm_delay_ops.const_clock = true;
3514 + arm_delay_ops = &arm_timer_delay_ops;
3515 delay_calibrated = true;
3516 } else {
3517 pr_info("Ignoring duplicate/late registration of read_current_timer delay\n");
3518 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3519 index 025f742..8432b08 100644
3520 --- a/arch/arm/lib/uaccess_with_memcpy.c
3521 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3522 @@ -104,7 +104,7 @@ out:
3523 }
3524
3525 unsigned long
3526 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3527 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3528 {
3529 /*
3530 * This test is stubbed out of the main function above to keep
3531 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3532 index bac21a5..b67ef8e 100644
3533 --- a/arch/arm/mach-kirkwood/common.c
3534 +++ b/arch/arm/mach-kirkwood/common.c
3535 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3536 clk_gate_ops.disable(hw);
3537 }
3538
3539 -static struct clk_ops clk_gate_fn_ops;
3540 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3541 +{
3542 + return clk_gate_ops.is_enabled(hw);
3543 +}
3544 +
3545 +static struct clk_ops clk_gate_fn_ops = {
3546 + .enable = clk_gate_fn_enable,
3547 + .disable = clk_gate_fn_disable,
3548 + .is_enabled = clk_gate_fn_is_enabled,
3549 +};
3550
3551 static struct clk __init *clk_register_gate_fn(struct device *dev,
3552 const char *name,
3553 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3554 gate_fn->fn_en = fn_en;
3555 gate_fn->fn_dis = fn_dis;
3556
3557 - /* ops is the gate ops, but with our enable/disable functions */
3558 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3559 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3560 - clk_gate_fn_ops = clk_gate_ops;
3561 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3562 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3563 - }
3564 -
3565 clk = clk_register(dev, &gate_fn->gate.hw);
3566
3567 if (IS_ERR(clk))
3568 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3569 index 0abb30f..54064da 100644
3570 --- a/arch/arm/mach-omap2/board-n8x0.c
3571 +++ b/arch/arm/mach-omap2/board-n8x0.c
3572 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3573 }
3574 #endif
3575
3576 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3577 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3578 .late_init = n8x0_menelaus_late_init,
3579 };
3580
3581 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3582 index 8033cb7..2f7cb62 100644
3583 --- a/arch/arm/mach-omap2/gpmc.c
3584 +++ b/arch/arm/mach-omap2/gpmc.c
3585 @@ -139,7 +139,6 @@ struct omap3_gpmc_regs {
3586 };
3587
3588 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3589 -static struct irq_chip gpmc_irq_chip;
3590 static unsigned gpmc_irq_start;
3591
3592 static struct resource gpmc_mem_root;
3593 @@ -700,6 +699,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3594
3595 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3596
3597 +static struct irq_chip gpmc_irq_chip = {
3598 + .name = "gpmc",
3599 + .irq_startup = gpmc_irq_noop_ret,
3600 + .irq_enable = gpmc_irq_enable,
3601 + .irq_disable = gpmc_irq_disable,
3602 + .irq_shutdown = gpmc_irq_noop,
3603 + .irq_ack = gpmc_irq_noop,
3604 + .irq_mask = gpmc_irq_noop,
3605 + .irq_unmask = gpmc_irq_noop,
3606 +
3607 +};
3608 +
3609 static int gpmc_setup_irq(void)
3610 {
3611 int i;
3612 @@ -714,15 +725,6 @@ static int gpmc_setup_irq(void)
3613 return gpmc_irq_start;
3614 }
3615
3616 - gpmc_irq_chip.name = "gpmc";
3617 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3618 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3619 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3620 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3621 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3622 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3623 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3624 -
3625 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3626 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3627
3628 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3629 index 5d3b4f4..ddba3c0 100644
3630 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3631 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3632 @@ -340,7 +340,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3633 return NOTIFY_OK;
3634 }
3635
3636 -static struct notifier_block __refdata irq_hotplug_notifier = {
3637 +static struct notifier_block irq_hotplug_notifier = {
3638 .notifier_call = irq_cpu_hotplug_notify,
3639 };
3640
3641 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3642 index e065daa..7b1ad9b 100644
3643 --- a/arch/arm/mach-omap2/omap_device.c
3644 +++ b/arch/arm/mach-omap2/omap_device.c
3645 @@ -686,7 +686,7 @@ void omap_device_delete(struct omap_device *od)
3646 * passes along the return value of omap_device_build_ss().
3647 */
3648 struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id,
3649 - struct omap_hwmod *oh, void *pdata,
3650 + struct omap_hwmod *oh, const void *pdata,
3651 int pdata_len,
3652 struct omap_device_pm_latency *pm_lats,
3653 int pm_lats_cnt, int is_early_device)
3654 @@ -720,7 +720,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev
3655 */
3656 struct platform_device __init *omap_device_build_ss(const char *pdev_name, int pdev_id,
3657 struct omap_hwmod **ohs, int oh_cnt,
3658 - void *pdata, int pdata_len,
3659 + const void *pdata, int pdata_len,
3660 struct omap_device_pm_latency *pm_lats,
3661 int pm_lats_cnt, int is_early_device)
3662 {
3663 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3664 index 0933c59..42b8e2d 100644
3665 --- a/arch/arm/mach-omap2/omap_device.h
3666 +++ b/arch/arm/mach-omap2/omap_device.h
3667 @@ -91,14 +91,14 @@ int omap_device_shutdown(struct platform_device *pdev);
3668 /* Core code interface */
3669
3670 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3671 - struct omap_hwmod *oh, void *pdata,
3672 + struct omap_hwmod *oh, const void *pdata,
3673 int pdata_len,
3674 struct omap_device_pm_latency *pm_lats,
3675 int pm_lats_cnt, int is_early_device);
3676
3677 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3678 struct omap_hwmod **oh, int oh_cnt,
3679 - void *pdata, int pdata_len,
3680 + const void *pdata, int pdata_len,
3681 struct omap_device_pm_latency *pm_lats,
3682 int pm_lats_cnt, int is_early_device);
3683
3684 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3685 index 4653efb..8c60bf7 100644
3686 --- a/arch/arm/mach-omap2/omap_hwmod.c
3687 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3688 @@ -189,10 +189,10 @@ struct omap_hwmod_soc_ops {
3689 int (*init_clkdm)(struct omap_hwmod *oh);
3690 void (*update_context_lost)(struct omap_hwmod *oh);
3691 int (*get_context_lost)(struct omap_hwmod *oh);
3692 -};
3693 +} __no_const;
3694
3695 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3696 -static struct omap_hwmod_soc_ops soc_ops;
3697 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3698
3699 /* omap_hwmod_list contains all registered struct omap_hwmods */
3700 static LIST_HEAD(omap_hwmod_list);
3701 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3702 index 7c2b4ed..b2ea51f 100644
3703 --- a/arch/arm/mach-omap2/wd_timer.c
3704 +++ b/arch/arm/mach-omap2/wd_timer.c
3705 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3706 struct omap_hwmod *oh;
3707 char *oh_name = "wd_timer2";
3708 char *dev_name = "omap_wdt";
3709 - struct omap_wd_timer_platform_data pdata;
3710 + static struct omap_wd_timer_platform_data pdata = {
3711 + .read_reset_sources = prm_read_reset_sources
3712 + };
3713
3714 if (!cpu_class_is_omap2() || of_have_populated_dt())
3715 return 0;
3716 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3717 return -EINVAL;
3718 }
3719
3720 - pdata.read_reset_sources = prm_read_reset_sources;
3721 -
3722 pdev = omap_device_build(dev_name, id, oh, &pdata,
3723 sizeof(struct omap_wd_timer_platform_data),
3724 NULL, 0, 0);
3725 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3726 index 6be4c4d..32ac32a 100644
3727 --- a/arch/arm/mach-ux500/include/mach/setup.h
3728 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3729 @@ -38,13 +38,6 @@ extern struct sys_timer ux500_timer;
3730 .type = MT_DEVICE, \
3731 }
3732
3733 -#define __MEM_DEV_DESC(x, sz) { \
3734 - .virtual = IO_ADDRESS(x), \
3735 - .pfn = __phys_to_pfn(x), \
3736 - .length = sz, \
3737 - .type = MT_MEMORY, \
3738 -}
3739 -
3740 extern struct smp_operations ux500_smp_ops;
3741 extern void ux500_cpu_die(unsigned int cpu);
3742
3743 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3744 index 3fd629d..8b1aca9 100644
3745 --- a/arch/arm/mm/Kconfig
3746 +++ b/arch/arm/mm/Kconfig
3747 @@ -425,7 +425,7 @@ config CPU_32v5
3748
3749 config CPU_32v6
3750 bool
3751 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3752 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3753 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3754
3755 config CPU_32v6K
3756 @@ -577,6 +577,7 @@ config CPU_CP15_MPU
3757
3758 config CPU_USE_DOMAINS
3759 bool
3760 + depends on !ARM_LPAE && !PAX_KERNEXEC
3761 help
3762 This option enables or disables the use of domain switching
3763 via the set_fs() function.
3764 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3765 index db26e2e..ee44569 100644
3766 --- a/arch/arm/mm/alignment.c
3767 +++ b/arch/arm/mm/alignment.c
3768 @@ -211,10 +211,12 @@ union offset_union {
3769 #define __get16_unaligned_check(ins,val,addr) \
3770 do { \
3771 unsigned int err = 0, v, a = addr; \
3772 + pax_open_userland(); \
3773 __get8_unaligned_check(ins,v,a,err); \
3774 val = v << ((BE) ? 8 : 0); \
3775 __get8_unaligned_check(ins,v,a,err); \
3776 val |= v << ((BE) ? 0 : 8); \
3777 + pax_close_userland(); \
3778 if (err) \
3779 goto fault; \
3780 } while (0)
3781 @@ -228,6 +230,7 @@ union offset_union {
3782 #define __get32_unaligned_check(ins,val,addr) \
3783 do { \
3784 unsigned int err = 0, v, a = addr; \
3785 + pax_open_userland(); \
3786 __get8_unaligned_check(ins,v,a,err); \
3787 val = v << ((BE) ? 24 : 0); \
3788 __get8_unaligned_check(ins,v,a,err); \
3789 @@ -236,6 +239,7 @@ union offset_union {
3790 val |= v << ((BE) ? 8 : 16); \
3791 __get8_unaligned_check(ins,v,a,err); \
3792 val |= v << ((BE) ? 0 : 24); \
3793 + pax_close_userland(); \
3794 if (err) \
3795 goto fault; \
3796 } while (0)
3797 @@ -249,6 +253,7 @@ union offset_union {
3798 #define __put16_unaligned_check(ins,val,addr) \
3799 do { \
3800 unsigned int err = 0, v = val, a = addr; \
3801 + pax_open_userland(); \
3802 __asm__( FIRST_BYTE_16 \
3803 ARM( "1: "ins" %1, [%2], #1\n" ) \
3804 THUMB( "1: "ins" %1, [%2]\n" ) \
3805 @@ -268,6 +273,7 @@ union offset_union {
3806 " .popsection\n" \
3807 : "=r" (err), "=&r" (v), "=&r" (a) \
3808 : "0" (err), "1" (v), "2" (a)); \
3809 + pax_close_userland(); \
3810 if (err) \
3811 goto fault; \
3812 } while (0)
3813 @@ -281,6 +287,7 @@ union offset_union {
3814 #define __put32_unaligned_check(ins,val,addr) \
3815 do { \
3816 unsigned int err = 0, v = val, a = addr; \
3817 + pax_open_userland(); \
3818 __asm__( FIRST_BYTE_32 \
3819 ARM( "1: "ins" %1, [%2], #1\n" ) \
3820 THUMB( "1: "ins" %1, [%2]\n" ) \
3821 @@ -310,6 +317,7 @@ union offset_union {
3822 " .popsection\n" \
3823 : "=r" (err), "=&r" (v), "=&r" (a) \
3824 : "0" (err), "1" (v), "2" (a)); \
3825 + pax_close_userland(); \
3826 if (err) \
3827 goto fault; \
3828 } while (0)
3829 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3830 index d07df17..59d5493 100644
3831 --- a/arch/arm/mm/context.c
3832 +++ b/arch/arm/mm/context.c
3833 @@ -45,7 +45,7 @@ static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3834 static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3835 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3836
3837 -static DEFINE_PER_CPU(atomic64_t, active_asids);
3838 +DEFINE_PER_CPU(atomic64_t, active_asids);
3839 static DEFINE_PER_CPU(u64, reserved_asids);
3840 static cpumask_t tlb_flush_pending;
3841
3842 @@ -209,8 +209,10 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3843 atomic64_set(&mm->context.id, asid);
3844 }
3845
3846 - if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending))
3847 + if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending)) {
3848 local_flush_tlb_all();
3849 + dummy_flush_tlb_a15_erratum();
3850 + }
3851
3852 atomic64_set(&per_cpu(active_asids, cpu), asid);
3853 cpumask_set_cpu(cpu, mm_cpumask(mm));
3854 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3855 index 5dbf13f..1a60561 100644
3856 --- a/arch/arm/mm/fault.c
3857 +++ b/arch/arm/mm/fault.c
3858 @@ -25,6 +25,7 @@
3859 #include <asm/system_misc.h>
3860 #include <asm/system_info.h>
3861 #include <asm/tlbflush.h>
3862 +#include <asm/sections.h>
3863
3864 #include "fault.h"
3865
3866 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3867 if (fixup_exception(regs))
3868 return;
3869
3870 +#ifdef CONFIG_PAX_KERNEXEC
3871 + if ((fsr & FSR_WRITE) &&
3872 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3873 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3874 + {
3875 + if (current->signal->curr_ip)
3876 + 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),
3877 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3878 + else
3879 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3880 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3881 + }
3882 +#endif
3883 +
3884 /*
3885 * No handler, we'll have to terminate things with extreme prejudice.
3886 */
3887 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3888 }
3889 #endif
3890
3891 +#ifdef CONFIG_PAX_PAGEEXEC
3892 + if (fsr & FSR_LNX_PF) {
3893 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3894 + do_group_exit(SIGKILL);
3895 + }
3896 +#endif
3897 +
3898 tsk->thread.address = addr;
3899 tsk->thread.error_code = fsr;
3900 tsk->thread.trap_no = 14;
3901 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3902 }
3903 #endif /* CONFIG_MMU */
3904
3905 +#ifdef CONFIG_PAX_PAGEEXEC
3906 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3907 +{
3908 + long i;
3909 +
3910 + printk(KERN_ERR "PAX: bytes at PC: ");
3911 + for (i = 0; i < 20; i++) {
3912 + unsigned char c;
3913 + if (get_user(c, (__force unsigned char __user *)pc+i))
3914 + printk(KERN_CONT "?? ");
3915 + else
3916 + printk(KERN_CONT "%02x ", c);
3917 + }
3918 + printk("\n");
3919 +
3920 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3921 + for (i = -1; i < 20; i++) {
3922 + unsigned long c;
3923 + if (get_user(c, (__force unsigned long __user *)sp+i))
3924 + printk(KERN_CONT "???????? ");
3925 + else
3926 + printk(KERN_CONT "%08lx ", c);
3927 + }
3928 + printk("\n");
3929 +}
3930 +#endif
3931 +
3932 /*
3933 * First Level Translation Fault Handler
3934 *
3935 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3936 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3937 struct siginfo info;
3938
3939 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3940 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3941 + if (current->signal->curr_ip)
3942 + 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),
3943 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3944 + else
3945 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3946 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3947 + goto die;
3948 + }
3949 +#endif
3950 +
3951 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3952 return;
3953
3954 +die:
3955 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3956 inf->name, fsr, addr);
3957
3958 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3959 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3960 struct siginfo info;
3961
3962 + if (user_mode(regs)) {
3963 + if (addr == 0xffff0fe0UL) {
3964 + /*
3965 + * PaX: __kuser_get_tls emulation
3966 + */
3967 + regs->ARM_r0 = current_thread_info()->tp_value;
3968 + regs->ARM_pc = regs->ARM_lr;
3969 + return;
3970 + }
3971 + }
3972 +
3973 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3974 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3975 + if (current->signal->curr_ip)
3976 + 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),
3977 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3978 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3979 + else
3980 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3981 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3982 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3983 + goto die;
3984 + }
3985 +#endif
3986 +
3987 +#ifdef CONFIG_PAX_REFCOUNT
3988 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3989 + unsigned int bkpt;
3990 +
3991 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3992 + current->thread.error_code = ifsr;
3993 + current->thread.trap_no = 0;
3994 + pax_report_refcount_overflow(regs);
3995 + fixup_exception(regs);
3996 + return;
3997 + }
3998 + }
3999 +#endif
4000 +
4001 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
4002 return;
4003
4004 +die:
4005 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4006 inf->name, ifsr, addr);
4007
4008 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4009 index cf08bdf..772656c 100644
4010 --- a/arch/arm/mm/fault.h
4011 +++ b/arch/arm/mm/fault.h
4012 @@ -3,6 +3,7 @@
4013
4014 /*
4015 * Fault status register encodings. We steal bit 31 for our own purposes.
4016 + * Set when the FSR value is from an instruction fault.
4017 */
4018 #define FSR_LNX_PF (1 << 31)
4019 #define FSR_WRITE (1 << 11)
4020 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4021 }
4022 #endif
4023
4024 +/* valid for LPAE and !LPAE */
4025 +static inline int is_xn_fault(unsigned int fsr)
4026 +{
4027 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4028 +}
4029 +
4030 +static inline int is_domain_fault(unsigned int fsr)
4031 +{
4032 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4033 +}
4034 +
4035 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4036 unsigned long search_exception_table(unsigned long addr);
4037
4038 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4039 index ad722f1..763fdd3 100644
4040 --- a/arch/arm/mm/init.c
4041 +++ b/arch/arm/mm/init.c
4042 @@ -30,6 +30,8 @@
4043 #include <asm/setup.h>
4044 #include <asm/tlb.h>
4045 #include <asm/fixmap.h>
4046 +#include <asm/system_info.h>
4047 +#include <asm/cp15.h>
4048
4049 #include <asm/mach/arch.h>
4050 #include <asm/mach/map.h>
4051 @@ -736,7 +738,46 @@ void free_initmem(void)
4052 {
4053 #ifdef CONFIG_HAVE_TCM
4054 extern char __tcm_start, __tcm_end;
4055 +#endif
4056
4057 +#ifdef CONFIG_PAX_KERNEXEC
4058 + unsigned long addr;
4059 + pgd_t *pgd;
4060 + pud_t *pud;
4061 + pmd_t *pmd;
4062 + int cpu_arch = cpu_architecture();
4063 + unsigned int cr = get_cr();
4064 +
4065 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4066 + /* make pages tables, etc before .text NX */
4067 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4068 + pgd = pgd_offset_k(addr);
4069 + pud = pud_offset(pgd, addr);
4070 + pmd = pmd_offset(pud, addr);
4071 + __section_update(pmd, addr, PMD_SECT_XN);
4072 + }
4073 + /* make init NX */
4074 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4075 + pgd = pgd_offset_k(addr);
4076 + pud = pud_offset(pgd, addr);
4077 + pmd = pmd_offset(pud, addr);
4078 + __section_update(pmd, addr, PMD_SECT_XN);
4079 + }
4080 + /* make kernel code/rodata RX */
4081 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4082 + pgd = pgd_offset_k(addr);
4083 + pud = pud_offset(pgd, addr);
4084 + pmd = pmd_offset(pud, addr);
4085 +#ifdef CONFIG_ARM_LPAE
4086 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4087 +#else
4088 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4089 +#endif
4090 + }
4091 + }
4092 +#endif
4093 +
4094 +#ifdef CONFIG_HAVE_TCM
4095 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4096 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
4097 __phys_to_pfn(__pa(&__tcm_end)),
4098 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4099 index 88fd86c..7a224ce 100644
4100 --- a/arch/arm/mm/ioremap.c
4101 +++ b/arch/arm/mm/ioremap.c
4102 @@ -335,9 +335,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
4103 unsigned int mtype;
4104
4105 if (cached)
4106 - mtype = MT_MEMORY;
4107 + mtype = MT_MEMORY_RX;
4108 else
4109 - mtype = MT_MEMORY_NONCACHED;
4110 + mtype = MT_MEMORY_NONCACHED_RX;
4111
4112 return __arm_ioremap_caller(phys_addr, size, mtype,
4113 __builtin_return_address(0));
4114 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4115 index 10062ce..aa96dd7 100644
4116 --- a/arch/arm/mm/mmap.c
4117 +++ b/arch/arm/mm/mmap.c
4118 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4119 struct vm_area_struct *vma;
4120 int do_align = 0;
4121 int aliasing = cache_is_vipt_aliasing();
4122 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4123 struct vm_unmapped_area_info info;
4124
4125 /*
4126 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4127 if (len > TASK_SIZE)
4128 return -ENOMEM;
4129
4130 +#ifdef CONFIG_PAX_RANDMMAP
4131 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4132 +#endif
4133 +
4134 if (addr) {
4135 if (do_align)
4136 addr = COLOUR_ALIGN(addr, pgoff);
4137 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4138 addr = PAGE_ALIGN(addr);
4139
4140 vma = find_vma(mm, addr);
4141 - if (TASK_SIZE - len >= addr &&
4142 - (!vma || addr + len <= vma->vm_start))
4143 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4144 return addr;
4145 }
4146
4147 @@ -112,6 +116,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4148 unsigned long addr = addr0;
4149 int do_align = 0;
4150 int aliasing = cache_is_vipt_aliasing();
4151 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4152 struct vm_unmapped_area_info info;
4153
4154 /*
4155 @@ -132,6 +137,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4156 return addr;
4157 }
4158
4159 +#ifdef CONFIG_PAX_RANDMMAP
4160 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4161 +#endif
4162 +
4163 /* requesting a specific address */
4164 if (addr) {
4165 if (do_align)
4166 @@ -139,8 +148,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4167 else
4168 addr = PAGE_ALIGN(addr);
4169 vma = find_vma(mm, addr);
4170 - if (TASK_SIZE - len >= addr &&
4171 - (!vma || addr + len <= vma->vm_start))
4172 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4173 return addr;
4174 }
4175
4176 @@ -162,6 +170,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4177 VM_BUG_ON(addr != -ENOMEM);
4178 info.flags = 0;
4179 info.low_limit = mm->mmap_base;
4180 +
4181 +#ifdef CONFIG_PAX_RANDMMAP
4182 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4183 + info.low_limit += mm->delta_mmap;
4184 +#endif
4185 +
4186 info.high_limit = TASK_SIZE;
4187 addr = vm_unmapped_area(&info);
4188 }
4189 @@ -173,6 +187,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4190 {
4191 unsigned long random_factor = 0UL;
4192
4193 +#ifdef CONFIG_PAX_RANDMMAP
4194 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4195 +#endif
4196 +
4197 /* 8 bits of randomness in 20 address space bits */
4198 if ((current->flags & PF_RANDOMIZE) &&
4199 !(current->personality & ADDR_NO_RANDOMIZE))
4200 @@ -180,10 +198,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4201
4202 if (mmap_is_legacy()) {
4203 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4204 +
4205 +#ifdef CONFIG_PAX_RANDMMAP
4206 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4207 + mm->mmap_base += mm->delta_mmap;
4208 +#endif
4209 +
4210 mm->get_unmapped_area = arch_get_unmapped_area;
4211 mm->unmap_area = arch_unmap_area;
4212 } else {
4213 mm->mmap_base = mmap_base(random_factor);
4214 +
4215 +#ifdef CONFIG_PAX_RANDMMAP
4216 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4217 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4218 +#endif
4219 +
4220 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4221 mm->unmap_area = arch_unmap_area_topdown;
4222 }
4223 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4224 index ce328c7..35b88dc 100644
4225 --- a/arch/arm/mm/mmu.c
4226 +++ b/arch/arm/mm/mmu.c
4227 @@ -35,6 +35,23 @@
4228
4229 #include "mm.h"
4230
4231 +
4232 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4233 +void modify_domain(unsigned int dom, unsigned int type)
4234 +{
4235 + struct thread_info *thread = current_thread_info();
4236 + unsigned int domain = thread->cpu_domain;
4237 + /*
4238 + * DOMAIN_MANAGER might be defined to some other value,
4239 + * use the arch-defined constant
4240 + */
4241 + domain &= ~domain_val(dom, 3);
4242 + thread->cpu_domain = domain | domain_val(dom, type);
4243 + set_domain(thread->cpu_domain);
4244 +}
4245 +EXPORT_SYMBOL(modify_domain);
4246 +#endif
4247 +
4248 /*
4249 * empty_zero_page is a special page that is used for
4250 * zero-initialized data and COW.
4251 @@ -195,10 +212,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
4252 }
4253 #endif
4254
4255 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4256 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4257 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4258
4259 -static struct mem_type mem_types[] = {
4260 +#ifdef CONFIG_PAX_KERNEXEC
4261 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4262 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4263 +#else
4264 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4265 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4266 +#endif
4267 +
4268 +static struct mem_type mem_types[] __read_only = {
4269 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4270 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4271 L_PTE_SHARED,
4272 @@ -227,16 +252,16 @@ static struct mem_type mem_types[] = {
4273 [MT_UNCACHED] = {
4274 .prot_pte = PROT_PTE_DEVICE,
4275 .prot_l1 = PMD_TYPE_TABLE,
4276 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4277 + .prot_sect = PROT_SECT_DEVICE,
4278 .domain = DOMAIN_IO,
4279 },
4280 [MT_CACHECLEAN] = {
4281 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4282 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4283 .domain = DOMAIN_KERNEL,
4284 },
4285 #ifndef CONFIG_ARM_LPAE
4286 [MT_MINICLEAN] = {
4287 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4288 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4289 .domain = DOMAIN_KERNEL,
4290 },
4291 #endif
4292 @@ -244,36 +269,54 @@ static struct mem_type mem_types[] = {
4293 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4294 L_PTE_RDONLY,
4295 .prot_l1 = PMD_TYPE_TABLE,
4296 - .domain = DOMAIN_USER,
4297 + .domain = DOMAIN_VECTORS,
4298 },
4299 [MT_HIGH_VECTORS] = {
4300 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4301 - L_PTE_USER | L_PTE_RDONLY,
4302 + L_PTE_RDONLY,
4303 .prot_l1 = PMD_TYPE_TABLE,
4304 - .domain = DOMAIN_USER,
4305 + .domain = DOMAIN_VECTORS,
4306 },
4307 - [MT_MEMORY] = {
4308 + [MT_MEMORY_RWX] = {
4309 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4310 .prot_l1 = PMD_TYPE_TABLE,
4311 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4312 .domain = DOMAIN_KERNEL,
4313 },
4314 + [MT_MEMORY_RW] = {
4315 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4316 + .prot_l1 = PMD_TYPE_TABLE,
4317 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4318 + .domain = DOMAIN_KERNEL,
4319 + },
4320 + [MT_MEMORY_RX] = {
4321 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4322 + .prot_l1 = PMD_TYPE_TABLE,
4323 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4324 + .domain = DOMAIN_KERNEL,
4325 + },
4326 [MT_ROM] = {
4327 - .prot_sect = PMD_TYPE_SECT,
4328 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4329 .domain = DOMAIN_KERNEL,
4330 },
4331 - [MT_MEMORY_NONCACHED] = {
4332 + [MT_MEMORY_NONCACHED_RW] = {
4333 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4334 L_PTE_MT_BUFFERABLE,
4335 .prot_l1 = PMD_TYPE_TABLE,
4336 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4337 .domain = DOMAIN_KERNEL,
4338 },
4339 + [MT_MEMORY_NONCACHED_RX] = {
4340 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4341 + L_PTE_MT_BUFFERABLE,
4342 + .prot_l1 = PMD_TYPE_TABLE,
4343 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4344 + .domain = DOMAIN_KERNEL,
4345 + },
4346 [MT_MEMORY_DTCM] = {
4347 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4348 - L_PTE_XN,
4349 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4350 .prot_l1 = PMD_TYPE_TABLE,
4351 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4352 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4353 .domain = DOMAIN_KERNEL,
4354 },
4355 [MT_MEMORY_ITCM] = {
4356 @@ -283,10 +326,10 @@ static struct mem_type mem_types[] = {
4357 },
4358 [MT_MEMORY_SO] = {
4359 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4360 - L_PTE_MT_UNCACHED | L_PTE_XN,
4361 + L_PTE_MT_UNCACHED,
4362 .prot_l1 = PMD_TYPE_TABLE,
4363 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4364 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4365 + PMD_SECT_UNCACHED,
4366 .domain = DOMAIN_KERNEL,
4367 },
4368 [MT_MEMORY_DMA_READY] = {
4369 @@ -371,9 +414,35 @@ static void __init build_mem_type_table(void)
4370 * to prevent speculative instruction fetches.
4371 */
4372 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4373 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4374 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4375 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4376 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4377 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4378 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4379 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4380 +
4381 + /* Mark other regions on ARMv6+ as execute-never */
4382 +
4383 +#ifdef CONFIG_PAX_KERNEXEC
4384 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4385 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4386 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4387 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4388 +#ifndef CONFIG_ARM_LPAE
4389 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4390 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4391 +#endif
4392 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4393 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4394 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4395 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4396 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4397 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4398 +#endif
4399 +
4400 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4401 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4402 }
4403 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4404 /*
4405 @@ -432,6 +501,9 @@ static void __init build_mem_type_table(void)
4406 * from SVC mode and no access from userspace.
4407 */
4408 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4409 +#ifdef CONFIG_PAX_KERNEXEC
4410 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4411 +#endif
4412 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4413 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4414 #endif
4415 @@ -448,11 +520,17 @@ static void __init build_mem_type_table(void)
4416 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4417 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4418 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4419 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4420 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4421 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4422 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4423 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4424 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4425 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4426 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4427 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4428 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4429 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4430 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4431 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4432 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4433 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4434 }
4435 }
4436
4437 @@ -463,15 +541,20 @@ static void __init build_mem_type_table(void)
4438 if (cpu_arch >= CPU_ARCH_ARMv6) {
4439 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4440 /* Non-cacheable Normal is XCB = 001 */
4441 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4442 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4443 + PMD_SECT_BUFFERED;
4444 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4445 PMD_SECT_BUFFERED;
4446 } else {
4447 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4448 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4449 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4450 + PMD_SECT_TEX(1);
4451 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4452 PMD_SECT_TEX(1);
4453 }
4454 } else {
4455 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4456 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4457 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4458 }
4459
4460 #ifdef CONFIG_ARM_LPAE
4461 @@ -487,6 +570,8 @@ static void __init build_mem_type_table(void)
4462 vecs_pgprot |= PTE_EXT_AF;
4463 #endif
4464
4465 + user_pgprot |= __supported_pte_mask;
4466 +
4467 for (i = 0; i < 16; i++) {
4468 pteval_t v = pgprot_val(protection_map[i]);
4469 protection_map[i] = __pgprot(v | user_pgprot);
4470 @@ -501,10 +586,15 @@ static void __init build_mem_type_table(void)
4471
4472 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4473 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4474 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4475 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4476 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4477 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4478 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4479 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4480 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4481 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4482 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4483 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4484 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4485 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4486 mem_types[MT_ROM].prot_sect |= cp->pmd;
4487
4488 switch (cp->pmd) {
4489 @@ -1105,18 +1195,15 @@ void __init arm_mm_memblock_reserve(void)
4490 * called function. This means you can't use any function or debugging
4491 * method which may touch any device, otherwise the kernel _will_ crash.
4492 */
4493 +
4494 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4495 +
4496 static void __init devicemaps_init(struct machine_desc *mdesc)
4497 {
4498 struct map_desc map;
4499 unsigned long addr;
4500 - void *vectors;
4501
4502 - /*
4503 - * Allocate the vector page early.
4504 - */
4505 - vectors = early_alloc(PAGE_SIZE);
4506 -
4507 - early_trap_init(vectors);
4508 + early_trap_init(&vectors);
4509
4510 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4511 pmd_clear(pmd_off_k(addr));
4512 @@ -1156,7 +1243,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4513 * location (0xffff0000). If we aren't using high-vectors, also
4514 * create a mapping at the low-vectors virtual address.
4515 */
4516 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4517 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4518 map.virtual = 0xffff0000;
4519 map.length = PAGE_SIZE;
4520 map.type = MT_HIGH_VECTORS;
4521 @@ -1214,8 +1301,39 @@ static void __init map_lowmem(void)
4522 map.pfn = __phys_to_pfn(start);
4523 map.virtual = __phys_to_virt(start);
4524 map.length = end - start;
4525 - map.type = MT_MEMORY;
4526
4527 +#ifdef CONFIG_PAX_KERNEXEC
4528 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4529 + struct map_desc kernel;
4530 + struct map_desc initmap;
4531 +
4532 + /* when freeing initmem we will make this RW */
4533 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4534 + initmap.virtual = (unsigned long)__init_begin;
4535 + initmap.length = _sdata - __init_begin;
4536 + initmap.type = MT_MEMORY_RWX;
4537 + create_mapping(&initmap);
4538 +
4539 + /* when freeing initmem we will make this RX */
4540 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4541 + kernel.virtual = (unsigned long)_stext;
4542 + kernel.length = __init_begin - _stext;
4543 + kernel.type = MT_MEMORY_RWX;
4544 + create_mapping(&kernel);
4545 +
4546 + if (map.virtual < (unsigned long)_stext) {
4547 + map.length = (unsigned long)_stext - map.virtual;
4548 + map.type = MT_MEMORY_RWX;
4549 + create_mapping(&map);
4550 + }
4551 +
4552 + map.pfn = __phys_to_pfn(__pa(_sdata));
4553 + map.virtual = (unsigned long)_sdata;
4554 + map.length = end - __pa(_sdata);
4555 + }
4556 +#endif
4557 +
4558 + map.type = MT_MEMORY_RW;
4559 create_mapping(&map);
4560 }
4561 }
4562 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4563 index 6d98c13..3cfb174 100644
4564 --- a/arch/arm/mm/proc-v7-2level.S
4565 +++ b/arch/arm/mm/proc-v7-2level.S
4566 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4567 tst r1, #L_PTE_XN
4568 orrne r3, r3, #PTE_EXT_XN
4569
4570 + tst r1, #L_PTE_PXN
4571 + orrne r3, r3, #PTE_EXT_PXN
4572 +
4573 tst r1, #L_PTE_YOUNG
4574 tstne r1, #L_PTE_VALID
4575 #ifndef CONFIG_CPU_USE_DOMAINS
4576 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4577 index a5bc92d..0bb4730 100644
4578 --- a/arch/arm/plat-omap/sram.c
4579 +++ b/arch/arm/plat-omap/sram.c
4580 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4581 * Looks like we need to preserve some bootloader code at the
4582 * beginning of SRAM for jumping to flash for reboot to work...
4583 */
4584 + pax_open_kernel();
4585 memset_io(omap_sram_base + omap_sram_skip, 0,
4586 omap_sram_size - omap_sram_skip);
4587 + pax_close_kernel();
4588 }
4589 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4590 index f5144cd..71f6d1f 100644
4591 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4592 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4593 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4594 int (*started)(unsigned ch);
4595 int (*flush)(unsigned ch);
4596 int (*stop)(unsigned ch);
4597 -};
4598 +} __no_const;
4599
4600 extern void *samsung_dmadev_get_ops(void);
4601 extern void *s3c_dma_get_ops(void);
4602 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4603 index 0c3ba9f..95722b3 100644
4604 --- a/arch/arm64/kernel/debug-monitors.c
4605 +++ b/arch/arm64/kernel/debug-monitors.c
4606 @@ -151,7 +151,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4607 return NOTIFY_OK;
4608 }
4609
4610 -static struct notifier_block __cpuinitdata os_lock_nb = {
4611 +static struct notifier_block os_lock_nb = {
4612 .notifier_call = os_lock_notify,
4613 };
4614
4615 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4616 index 5ab825c..96aaec8 100644
4617 --- a/arch/arm64/kernel/hw_breakpoint.c
4618 +++ b/arch/arm64/kernel/hw_breakpoint.c
4619 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4620 return NOTIFY_OK;
4621 }
4622
4623 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4624 +static struct notifier_block hw_breakpoint_reset_nb = {
4625 .notifier_call = hw_breakpoint_reset_notify,
4626 };
4627
4628 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4629 index c3a58a1..78fbf54 100644
4630 --- a/arch/avr32/include/asm/cache.h
4631 +++ b/arch/avr32/include/asm/cache.h
4632 @@ -1,8 +1,10 @@
4633 #ifndef __ASM_AVR32_CACHE_H
4634 #define __ASM_AVR32_CACHE_H
4635
4636 +#include <linux/const.h>
4637 +
4638 #define L1_CACHE_SHIFT 5
4639 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4640 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4641
4642 /*
4643 * Memory returned by kmalloc() may be used for DMA, so we must make
4644 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4645 index e2c3287..6c4f98c 100644
4646 --- a/arch/avr32/include/asm/elf.h
4647 +++ b/arch/avr32/include/asm/elf.h
4648 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4649 the loader. We need to make sure that it is out of the way of the program
4650 that it will "exec", and that there is sufficient room for the brk. */
4651
4652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4654
4655 +#ifdef CONFIG_PAX_ASLR
4656 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4657 +
4658 +#define PAX_DELTA_MMAP_LEN 15
4659 +#define PAX_DELTA_STACK_LEN 15
4660 +#endif
4661
4662 /* This yields a mask that user programs can use to figure out what
4663 instruction set this CPU supports. This could be done in user space,
4664 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4665 index 479330b..53717a8 100644
4666 --- a/arch/avr32/include/asm/kmap_types.h
4667 +++ b/arch/avr32/include/asm/kmap_types.h
4668 @@ -2,9 +2,9 @@
4669 #define __ASM_AVR32_KMAP_TYPES_H
4670
4671 #ifdef CONFIG_DEBUG_HIGHMEM
4672 -# define KM_TYPE_NR 29
4673 +# define KM_TYPE_NR 30
4674 #else
4675 -# define KM_TYPE_NR 14
4676 +# define KM_TYPE_NR 15
4677 #endif
4678
4679 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4680 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4681 index b2f2d2d..d1c85cb 100644
4682 --- a/arch/avr32/mm/fault.c
4683 +++ b/arch/avr32/mm/fault.c
4684 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4685
4686 int exception_trace = 1;
4687
4688 +#ifdef CONFIG_PAX_PAGEEXEC
4689 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4690 +{
4691 + unsigned long i;
4692 +
4693 + printk(KERN_ERR "PAX: bytes at PC: ");
4694 + for (i = 0; i < 20; i++) {
4695 + unsigned char c;
4696 + if (get_user(c, (unsigned char *)pc+i))
4697 + printk(KERN_CONT "???????? ");
4698 + else
4699 + printk(KERN_CONT "%02x ", c);
4700 + }
4701 + printk("\n");
4702 +}
4703 +#endif
4704 +
4705 /*
4706 * This routine handles page faults. It determines the address and the
4707 * problem, and then passes it off to one of the appropriate routines.
4708 @@ -174,6 +191,16 @@ bad_area:
4709 up_read(&mm->mmap_sem);
4710
4711 if (user_mode(regs)) {
4712 +
4713 +#ifdef CONFIG_PAX_PAGEEXEC
4714 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4715 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4716 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4717 + do_group_exit(SIGKILL);
4718 + }
4719 + }
4720 +#endif
4721 +
4722 if (exception_trace && printk_ratelimit())
4723 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4724 "sp %08lx ecr %lu\n",
4725 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4726 index 568885a..f8008df 100644
4727 --- a/arch/blackfin/include/asm/cache.h
4728 +++ b/arch/blackfin/include/asm/cache.h
4729 @@ -7,6 +7,7 @@
4730 #ifndef __ARCH_BLACKFIN_CACHE_H
4731 #define __ARCH_BLACKFIN_CACHE_H
4732
4733 +#include <linux/const.h>
4734 #include <linux/linkage.h> /* for asmlinkage */
4735
4736 /*
4737 @@ -14,7 +15,7 @@
4738 * Blackfin loads 32 bytes for cache
4739 */
4740 #define L1_CACHE_SHIFT 5
4741 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4742 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4743 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4744
4745 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4746 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4747 index aea2718..3639a60 100644
4748 --- a/arch/cris/include/arch-v10/arch/cache.h
4749 +++ b/arch/cris/include/arch-v10/arch/cache.h
4750 @@ -1,8 +1,9 @@
4751 #ifndef _ASM_ARCH_CACHE_H
4752 #define _ASM_ARCH_CACHE_H
4753
4754 +#include <linux/const.h>
4755 /* Etrax 100LX have 32-byte cache-lines. */
4756 -#define L1_CACHE_BYTES 32
4757 #define L1_CACHE_SHIFT 5
4758 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4759
4760 #endif /* _ASM_ARCH_CACHE_H */
4761 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4762 index 7caf25d..ee65ac5 100644
4763 --- a/arch/cris/include/arch-v32/arch/cache.h
4764 +++ b/arch/cris/include/arch-v32/arch/cache.h
4765 @@ -1,11 +1,12 @@
4766 #ifndef _ASM_CRIS_ARCH_CACHE_H
4767 #define _ASM_CRIS_ARCH_CACHE_H
4768
4769 +#include <linux/const.h>
4770 #include <arch/hwregs/dma.h>
4771
4772 /* A cache-line is 32 bytes. */
4773 -#define L1_CACHE_BYTES 32
4774 #define L1_CACHE_SHIFT 5
4775 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4776
4777 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4778
4779 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4780 index b86329d..6709906 100644
4781 --- a/arch/frv/include/asm/atomic.h
4782 +++ b/arch/frv/include/asm/atomic.h
4783 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4784 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4785 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4786
4787 +#define atomic64_read_unchecked(v) atomic64_read(v)
4788 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4789 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4790 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4791 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4792 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4793 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4794 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4795 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4796 +
4797 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4798 {
4799 int c, old;
4800 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4801 index 2797163..c2a401d 100644
4802 --- a/arch/frv/include/asm/cache.h
4803 +++ b/arch/frv/include/asm/cache.h
4804 @@ -12,10 +12,11 @@
4805 #ifndef __ASM_CACHE_H
4806 #define __ASM_CACHE_H
4807
4808 +#include <linux/const.h>
4809
4810 /* bytes per L1 cache line */
4811 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4812 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4813 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4814
4815 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4816 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4817 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4818 index 43901f2..0d8b865 100644
4819 --- a/arch/frv/include/asm/kmap_types.h
4820 +++ b/arch/frv/include/asm/kmap_types.h
4821 @@ -2,6 +2,6 @@
4822 #ifndef _ASM_KMAP_TYPES_H
4823 #define _ASM_KMAP_TYPES_H
4824
4825 -#define KM_TYPE_NR 17
4826 +#define KM_TYPE_NR 18
4827
4828 #endif
4829 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4830 index 385fd30..3aaf4fe 100644
4831 --- a/arch/frv/mm/elf-fdpic.c
4832 +++ b/arch/frv/mm/elf-fdpic.c
4833 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4834 {
4835 struct vm_area_struct *vma;
4836 unsigned long limit;
4837 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4838
4839 if (len > TASK_SIZE)
4840 return -ENOMEM;
4841 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4842 if (addr) {
4843 addr = PAGE_ALIGN(addr);
4844 vma = find_vma(current->mm, addr);
4845 - if (TASK_SIZE - len >= addr &&
4846 - (!vma || addr + len <= vma->vm_start))
4847 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4848 goto success;
4849 }
4850
4851 @@ -89,7 +89,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4852 for (; vma; vma = vma->vm_next) {
4853 if (addr > limit)
4854 break;
4855 - if (addr + len <= vma->vm_start)
4856 + if (check_heap_stack_gap(vma, addr, len, offset))
4857 goto success;
4858 addr = vma->vm_end;
4859 }
4860 @@ -104,7 +104,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4861 for (; vma; vma = vma->vm_next) {
4862 if (addr > limit)
4863 break;
4864 - if (addr + len <= vma->vm_start)
4865 + if (check_heap_stack_gap(vma, addr, len, offset))
4866 goto success;
4867 addr = vma->vm_end;
4868 }
4869 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4870 index f4ca594..adc72fd6 100644
4871 --- a/arch/hexagon/include/asm/cache.h
4872 +++ b/arch/hexagon/include/asm/cache.h
4873 @@ -21,9 +21,11 @@
4874 #ifndef __ASM_CACHE_H
4875 #define __ASM_CACHE_H
4876
4877 +#include <linux/const.h>
4878 +
4879 /* Bytes per L1 cache line */
4880 -#define L1_CACHE_SHIFT (5)
4881 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4882 +#define L1_CACHE_SHIFT 5
4883 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4884
4885 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4886 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4887 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4888 index 6e6fe18..a6ae668 100644
4889 --- a/arch/ia64/include/asm/atomic.h
4890 +++ b/arch/ia64/include/asm/atomic.h
4891 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4892 #define atomic64_inc(v) atomic64_add(1, (v))
4893 #define atomic64_dec(v) atomic64_sub(1, (v))
4894
4895 +#define atomic64_read_unchecked(v) atomic64_read(v)
4896 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4897 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4898 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4899 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4900 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4901 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4902 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4903 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4904 +
4905 /* Atomic operations are already serializing */
4906 #define smp_mb__before_atomic_dec() barrier()
4907 #define smp_mb__after_atomic_dec() barrier()
4908 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4909 index 988254a..e1ee885 100644
4910 --- a/arch/ia64/include/asm/cache.h
4911 +++ b/arch/ia64/include/asm/cache.h
4912 @@ -1,6 +1,7 @@
4913 #ifndef _ASM_IA64_CACHE_H
4914 #define _ASM_IA64_CACHE_H
4915
4916 +#include <linux/const.h>
4917
4918 /*
4919 * Copyright (C) 1998-2000 Hewlett-Packard Co
4920 @@ -9,7 +10,7 @@
4921
4922 /* Bytes per L1 (data) cache line. */
4923 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4924 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4925 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4926
4927 #ifdef CONFIG_SMP
4928 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4929 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4930 index b5298eb..67c6e62 100644
4931 --- a/arch/ia64/include/asm/elf.h
4932 +++ b/arch/ia64/include/asm/elf.h
4933 @@ -42,6 +42,13 @@
4934 */
4935 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4936
4937 +#ifdef CONFIG_PAX_ASLR
4938 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4939 +
4940 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4941 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4942 +#endif
4943 +
4944 #define PT_IA_64_UNWIND 0x70000001
4945
4946 /* IA-64 relocations: */
4947 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4948 index 96a8d92..617a1cf 100644
4949 --- a/arch/ia64/include/asm/pgalloc.h
4950 +++ b/arch/ia64/include/asm/pgalloc.h
4951 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4952 pgd_val(*pgd_entry) = __pa(pud);
4953 }
4954
4955 +static inline void
4956 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4957 +{
4958 + pgd_populate(mm, pgd_entry, pud);
4959 +}
4960 +
4961 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4962 {
4963 return quicklist_alloc(0, GFP_KERNEL, NULL);
4964 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4965 pud_val(*pud_entry) = __pa(pmd);
4966 }
4967
4968 +static inline void
4969 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4970 +{
4971 + pud_populate(mm, pud_entry, pmd);
4972 +}
4973 +
4974 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4975 {
4976 return quicklist_alloc(0, GFP_KERNEL, NULL);
4977 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4978 index 815810c..d60bd4c 100644
4979 --- a/arch/ia64/include/asm/pgtable.h
4980 +++ b/arch/ia64/include/asm/pgtable.h
4981 @@ -12,7 +12,7 @@
4982 * David Mosberger-Tang <davidm@hpl.hp.com>
4983 */
4984
4985 -
4986 +#include <linux/const.h>
4987 #include <asm/mman.h>
4988 #include <asm/page.h>
4989 #include <asm/processor.h>
4990 @@ -142,6 +142,17 @@
4991 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4992 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4993 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4994 +
4995 +#ifdef CONFIG_PAX_PAGEEXEC
4996 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4997 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4998 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4999 +#else
5000 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5001 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5002 +# define PAGE_COPY_NOEXEC PAGE_COPY
5003 +#endif
5004 +
5005 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
5006 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
5007 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
5008 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
5009 index 54ff557..70c88b7 100644
5010 --- a/arch/ia64/include/asm/spinlock.h
5011 +++ b/arch/ia64/include/asm/spinlock.h
5012 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
5013 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
5014
5015 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
5016 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
5017 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
5018 }
5019
5020 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
5021 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
5022 index 449c8c0..18965fb 100644
5023 --- a/arch/ia64/include/asm/uaccess.h
5024 +++ b/arch/ia64/include/asm/uaccess.h
5025 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
5026 static inline unsigned long
5027 __copy_to_user (void __user *to, const void *from, unsigned long count)
5028 {
5029 + if (count > INT_MAX)
5030 + return count;
5031 +
5032 + if (!__builtin_constant_p(count))
5033 + check_object_size(from, count, true);
5034 +
5035 return __copy_user(to, (__force void __user *) from, count);
5036 }
5037
5038 static inline unsigned long
5039 __copy_from_user (void *to, const void __user *from, unsigned long count)
5040 {
5041 + if (count > INT_MAX)
5042 + return count;
5043 +
5044 + if (!__builtin_constant_p(count))
5045 + check_object_size(to, count, false);
5046 +
5047 return __copy_user((__force void __user *) to, from, count);
5048 }
5049
5050 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5051 ({ \
5052 void __user *__cu_to = (to); \
5053 const void *__cu_from = (from); \
5054 - long __cu_len = (n); \
5055 + unsigned long __cu_len = (n); \
5056 \
5057 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5058 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5059 + if (!__builtin_constant_p(n)) \
5060 + check_object_size(__cu_from, __cu_len, true); \
5061 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5062 + } \
5063 __cu_len; \
5064 })
5065
5066 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5067 ({ \
5068 void *__cu_to = (to); \
5069 const void __user *__cu_from = (from); \
5070 - long __cu_len = (n); \
5071 + unsigned long __cu_len = (n); \
5072 \
5073 __chk_user_ptr(__cu_from); \
5074 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5075 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5076 + if (!__builtin_constant_p(n)) \
5077 + check_object_size(__cu_to, __cu_len, false); \
5078 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5079 + } \
5080 __cu_len; \
5081 })
5082
5083 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
5084 index 2d67317..07d8bfa 100644
5085 --- a/arch/ia64/kernel/err_inject.c
5086 +++ b/arch/ia64/kernel/err_inject.c
5087 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
5088 return NOTIFY_OK;
5089 }
5090
5091 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
5092 +static struct notifier_block err_inject_cpu_notifier =
5093 {
5094 .notifier_call = err_inject_cpu_callback,
5095 };
5096 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
5097 index 65bf9cd..794f06b 100644
5098 --- a/arch/ia64/kernel/mca.c
5099 +++ b/arch/ia64/kernel/mca.c
5100 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
5101 return NOTIFY_OK;
5102 }
5103
5104 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
5105 +static struct notifier_block mca_cpu_notifier = {
5106 .notifier_call = mca_cpu_callback
5107 };
5108
5109 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5110 index 24603be..948052d 100644
5111 --- a/arch/ia64/kernel/module.c
5112 +++ b/arch/ia64/kernel/module.c
5113 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5114 void
5115 module_free (struct module *mod, void *module_region)
5116 {
5117 - if (mod && mod->arch.init_unw_table &&
5118 - module_region == mod->module_init) {
5119 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5120 unw_remove_unwind_table(mod->arch.init_unw_table);
5121 mod->arch.init_unw_table = NULL;
5122 }
5123 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5124 }
5125
5126 static inline int
5127 +in_init_rx (const struct module *mod, uint64_t addr)
5128 +{
5129 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5130 +}
5131 +
5132 +static inline int
5133 +in_init_rw (const struct module *mod, uint64_t addr)
5134 +{
5135 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5136 +}
5137 +
5138 +static inline int
5139 in_init (const struct module *mod, uint64_t addr)
5140 {
5141 - return addr - (uint64_t) mod->module_init < mod->init_size;
5142 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5143 +}
5144 +
5145 +static inline int
5146 +in_core_rx (const struct module *mod, uint64_t addr)
5147 +{
5148 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5149 +}
5150 +
5151 +static inline int
5152 +in_core_rw (const struct module *mod, uint64_t addr)
5153 +{
5154 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5155 }
5156
5157 static inline int
5158 in_core (const struct module *mod, uint64_t addr)
5159 {
5160 - return addr - (uint64_t) mod->module_core < mod->core_size;
5161 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5162 }
5163
5164 static inline int
5165 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5166 break;
5167
5168 case RV_BDREL:
5169 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5170 + if (in_init_rx(mod, val))
5171 + val -= (uint64_t) mod->module_init_rx;
5172 + else if (in_init_rw(mod, val))
5173 + val -= (uint64_t) mod->module_init_rw;
5174 + else if (in_core_rx(mod, val))
5175 + val -= (uint64_t) mod->module_core_rx;
5176 + else if (in_core_rw(mod, val))
5177 + val -= (uint64_t) mod->module_core_rw;
5178 break;
5179
5180 case RV_LTV:
5181 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5182 * addresses have been selected...
5183 */
5184 uint64_t gp;
5185 - if (mod->core_size > MAX_LTOFF)
5186 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5187 /*
5188 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5189 * at the end of the module.
5190 */
5191 - gp = mod->core_size - MAX_LTOFF / 2;
5192 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5193 else
5194 - gp = mod->core_size / 2;
5195 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5196 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5197 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5198 mod->arch.gp = gp;
5199 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5200 }
5201 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5202 index 77597e5..189dd62f 100644
5203 --- a/arch/ia64/kernel/palinfo.c
5204 +++ b/arch/ia64/kernel/palinfo.c
5205 @@ -977,7 +977,7 @@ create_palinfo_proc_entries(unsigned int cpu)
5206 struct proc_dir_entry **pdir;
5207 struct proc_dir_entry *cpu_dir;
5208 int j;
5209 - char cpustr[sizeof(CPUSTR)];
5210 + char cpustr[3+4+1];
5211
5212
5213 /*
5214 @@ -1045,7 +1045,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
5215 return NOTIFY_OK;
5216 }
5217
5218 -static struct notifier_block __refdata palinfo_cpu_notifier =
5219 +static struct notifier_block palinfo_cpu_notifier =
5220 {
5221 .notifier_call = palinfo_cpu_callback,
5222 .priority = 0,
5223 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
5224 index 79802e5..1a89ec5 100644
5225 --- a/arch/ia64/kernel/salinfo.c
5226 +++ b/arch/ia64/kernel/salinfo.c
5227 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
5228 return NOTIFY_OK;
5229 }
5230
5231 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
5232 +static struct notifier_block salinfo_cpu_notifier =
5233 {
5234 .notifier_call = salinfo_cpu_callback,
5235 .priority = 0,
5236 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5237 index d9439ef..d0cac6b 100644
5238 --- a/arch/ia64/kernel/sys_ia64.c
5239 +++ b/arch/ia64/kernel/sys_ia64.c
5240 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5241 unsigned long start_addr, align_mask = PAGE_SIZE - 1;
5242 struct mm_struct *mm = current->mm;
5243 struct vm_area_struct *vma;
5244 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5245
5246 if (len > RGN_MAP_LIMIT)
5247 return -ENOMEM;
5248 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5249 if (REGION_NUMBER(addr) == RGN_HPAGE)
5250 addr = 0;
5251 #endif
5252 +
5253 +#ifdef CONFIG_PAX_RANDMMAP
5254 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5255 + addr = mm->free_area_cache;
5256 + else
5257 +#endif
5258 +
5259 if (!addr)
5260 addr = mm->free_area_cache;
5261
5262 @@ -61,14 +69,14 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5263 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
5264 /* At this point: (!vma || addr < vma->vm_end). */
5265 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
5266 - if (start_addr != TASK_UNMAPPED_BASE) {
5267 + if (start_addr != mm->mmap_base) {
5268 /* Start a new search --- just in case we missed some holes. */
5269 - addr = TASK_UNMAPPED_BASE;
5270 + addr = mm->mmap_base;
5271 goto full_search;
5272 }
5273 return -ENOMEM;
5274 }
5275 - if (!vma || addr + len <= vma->vm_start) {
5276 + if (check_heap_stack_gap(vma, addr, len, offset)) {
5277 /* Remember the address where we stopped this search: */
5278 mm->free_area_cache = addr + len;
5279 return addr;
5280 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5281 index dc00b2c..cce53c2 100644
5282 --- a/arch/ia64/kernel/topology.c
5283 +++ b/arch/ia64/kernel/topology.c
5284 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5285 return NOTIFY_OK;
5286 }
5287
5288 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5289 +static struct notifier_block cache_cpu_notifier =
5290 {
5291 .notifier_call = cache_cpu_callback
5292 };
5293 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5294 index 0ccb28f..8992469 100644
5295 --- a/arch/ia64/kernel/vmlinux.lds.S
5296 +++ b/arch/ia64/kernel/vmlinux.lds.S
5297 @@ -198,7 +198,7 @@ SECTIONS {
5298 /* Per-cpu data: */
5299 . = ALIGN(PERCPU_PAGE_SIZE);
5300 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5301 - __phys_per_cpu_start = __per_cpu_load;
5302 + __phys_per_cpu_start = per_cpu_load;
5303 /*
5304 * ensure percpu data fits
5305 * into percpu page size
5306 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5307 index 6cf0341..d352594 100644
5308 --- a/arch/ia64/mm/fault.c
5309 +++ b/arch/ia64/mm/fault.c
5310 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5311 return pte_present(pte);
5312 }
5313
5314 +#ifdef CONFIG_PAX_PAGEEXEC
5315 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5316 +{
5317 + unsigned long i;
5318 +
5319 + printk(KERN_ERR "PAX: bytes at PC: ");
5320 + for (i = 0; i < 8; i++) {
5321 + unsigned int c;
5322 + if (get_user(c, (unsigned int *)pc+i))
5323 + printk(KERN_CONT "???????? ");
5324 + else
5325 + printk(KERN_CONT "%08x ", c);
5326 + }
5327 + printk("\n");
5328 +}
5329 +#endif
5330 +
5331 # define VM_READ_BIT 0
5332 # define VM_WRITE_BIT 1
5333 # define VM_EXEC_BIT 2
5334 @@ -149,8 +166,21 @@ retry:
5335 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5336 goto bad_area;
5337
5338 - if ((vma->vm_flags & mask) != mask)
5339 + if ((vma->vm_flags & mask) != mask) {
5340 +
5341 +#ifdef CONFIG_PAX_PAGEEXEC
5342 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5343 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5344 + goto bad_area;
5345 +
5346 + up_read(&mm->mmap_sem);
5347 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5348 + do_group_exit(SIGKILL);
5349 + }
5350 +#endif
5351 +
5352 goto bad_area;
5353 + }
5354
5355 /*
5356 * If for any reason at all we couldn't handle the fault, make
5357 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5358 index 5ca674b..127c3cb 100644
5359 --- a/arch/ia64/mm/hugetlbpage.c
5360 +++ b/arch/ia64/mm/hugetlbpage.c
5361 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5362 unsigned long pgoff, unsigned long flags)
5363 {
5364 struct vm_area_struct *vmm;
5365 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5366
5367 if (len > RGN_MAP_LIMIT)
5368 return -ENOMEM;
5369 @@ -171,7 +172,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5370 /* At this point: (!vmm || addr < vmm->vm_end). */
5371 if (REGION_OFFSET(addr) + len > RGN_MAP_LIMIT)
5372 return -ENOMEM;
5373 - if (!vmm || (addr + len) <= vmm->vm_start)
5374 + if (check_heap_stack_gap(vmm, addr, len, offset))
5375 return addr;
5376 addr = ALIGN(vmm->vm_end, HPAGE_SIZE);
5377 }
5378 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5379 index b755ea9..b9a969e 100644
5380 --- a/arch/ia64/mm/init.c
5381 +++ b/arch/ia64/mm/init.c
5382 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5383 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5384 vma->vm_end = vma->vm_start + PAGE_SIZE;
5385 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5386 +
5387 +#ifdef CONFIG_PAX_PAGEEXEC
5388 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5389 + vma->vm_flags &= ~VM_EXEC;
5390 +
5391 +#ifdef CONFIG_PAX_MPROTECT
5392 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5393 + vma->vm_flags &= ~VM_MAYEXEC;
5394 +#endif
5395 +
5396 + }
5397 +#endif
5398 +
5399 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5400 down_write(&current->mm->mmap_sem);
5401 if (insert_vm_struct(current->mm, vma)) {
5402 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5403 index 40b3ee9..8c2c112 100644
5404 --- a/arch/m32r/include/asm/cache.h
5405 +++ b/arch/m32r/include/asm/cache.h
5406 @@ -1,8 +1,10 @@
5407 #ifndef _ASM_M32R_CACHE_H
5408 #define _ASM_M32R_CACHE_H
5409
5410 +#include <linux/const.h>
5411 +
5412 /* L1 cache line size */
5413 #define L1_CACHE_SHIFT 4
5414 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5415 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5416
5417 #endif /* _ASM_M32R_CACHE_H */
5418 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5419 index 82abd15..d95ae5d 100644
5420 --- a/arch/m32r/lib/usercopy.c
5421 +++ b/arch/m32r/lib/usercopy.c
5422 @@ -14,6 +14,9 @@
5423 unsigned long
5424 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5425 {
5426 + if ((long)n < 0)
5427 + return n;
5428 +
5429 prefetch(from);
5430 if (access_ok(VERIFY_WRITE, to, n))
5431 __copy_user(to,from,n);
5432 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5433 unsigned long
5434 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5435 {
5436 + if ((long)n < 0)
5437 + return n;
5438 +
5439 prefetchw(to);
5440 if (access_ok(VERIFY_READ, from, n))
5441 __copy_user_zeroing(to,from,n);
5442 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5443 index 0395c51..5f26031 100644
5444 --- a/arch/m68k/include/asm/cache.h
5445 +++ b/arch/m68k/include/asm/cache.h
5446 @@ -4,9 +4,11 @@
5447 #ifndef __ARCH_M68K_CACHE_H
5448 #define __ARCH_M68K_CACHE_H
5449
5450 +#include <linux/const.h>
5451 +
5452 /* bytes per L1 cache line */
5453 #define L1_CACHE_SHIFT 4
5454 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5455 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5456
5457 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5458
5459 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5460 index 4efe96a..60e8699 100644
5461 --- a/arch/microblaze/include/asm/cache.h
5462 +++ b/arch/microblaze/include/asm/cache.h
5463 @@ -13,11 +13,12 @@
5464 #ifndef _ASM_MICROBLAZE_CACHE_H
5465 #define _ASM_MICROBLAZE_CACHE_H
5466
5467 +#include <linux/const.h>
5468 #include <asm/registers.h>
5469
5470 #define L1_CACHE_SHIFT 5
5471 /* word-granular cache in microblaze */
5472 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5473 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5474
5475 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5476
5477 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5478 index 01cc6ba..bcb7a5d 100644
5479 --- a/arch/mips/include/asm/atomic.h
5480 +++ b/arch/mips/include/asm/atomic.h
5481 @@ -21,6 +21,10 @@
5482 #include <asm/cmpxchg.h>
5483 #include <asm/war.h>
5484
5485 +#ifdef CONFIG_GENERIC_ATOMIC64
5486 +#include <asm-generic/atomic64.h>
5487 +#endif
5488 +
5489 #define ATOMIC_INIT(i) { (i) }
5490
5491 /*
5492 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5493 */
5494 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5495
5496 +#define atomic64_read_unchecked(v) atomic64_read(v)
5497 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5498 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5499 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5500 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5501 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5502 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5503 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5504 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5505 +
5506 #endif /* CONFIG_64BIT */
5507
5508 /*
5509 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5510 index b4db69f..8f3b093 100644
5511 --- a/arch/mips/include/asm/cache.h
5512 +++ b/arch/mips/include/asm/cache.h
5513 @@ -9,10 +9,11 @@
5514 #ifndef _ASM_CACHE_H
5515 #define _ASM_CACHE_H
5516
5517 +#include <linux/const.h>
5518 #include <kmalloc.h>
5519
5520 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5521 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5522 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5523
5524 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5525 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5526 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5527 index 455c0ac..ad65fbe 100644
5528 --- a/arch/mips/include/asm/elf.h
5529 +++ b/arch/mips/include/asm/elf.h
5530 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5531 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5532 #endif
5533
5534 +#ifdef CONFIG_PAX_ASLR
5535 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5536 +
5537 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5538 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5539 +#endif
5540 +
5541 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5542 struct linux_binprm;
5543 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5544 int uses_interp);
5545
5546 -struct mm_struct;
5547 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5548 -#define arch_randomize_brk arch_randomize_brk
5549 -
5550 #endif /* _ASM_ELF_H */
5551 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5552 index c1f6afa..38cc6e9 100644
5553 --- a/arch/mips/include/asm/exec.h
5554 +++ b/arch/mips/include/asm/exec.h
5555 @@ -12,6 +12,6 @@
5556 #ifndef _ASM_EXEC_H
5557 #define _ASM_EXEC_H
5558
5559 -extern unsigned long arch_align_stack(unsigned long sp);
5560 +#define arch_align_stack(x) ((x) & ~0xfUL)
5561
5562 #endif /* _ASM_EXEC_H */
5563 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5564 index dbaec94..6a14935 100644
5565 --- a/arch/mips/include/asm/page.h
5566 +++ b/arch/mips/include/asm/page.h
5567 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5568 #ifdef CONFIG_CPU_MIPS32
5569 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5570 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5571 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5572 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5573 #else
5574 typedef struct { unsigned long long pte; } pte_t;
5575 #define pte_val(x) ((x).pte)
5576 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5577 index 881d18b..cea38bc 100644
5578 --- a/arch/mips/include/asm/pgalloc.h
5579 +++ b/arch/mips/include/asm/pgalloc.h
5580 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5581 {
5582 set_pud(pud, __pud((unsigned long)pmd));
5583 }
5584 +
5585 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5586 +{
5587 + pud_populate(mm, pud, pmd);
5588 +}
5589 #endif
5590
5591 /*
5592 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5593 index b2050b9..d71bb1b 100644
5594 --- a/arch/mips/include/asm/thread_info.h
5595 +++ b/arch/mips/include/asm/thread_info.h
5596 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5597 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5598 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5599 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5600 +/* li takes a 32bit immediate */
5601 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5602 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5603
5604 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5605 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5606 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5607 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5608 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5609 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5610 +
5611 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5612
5613 /* work to do in syscall_trace_leave() */
5614 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5615 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5616
5617 /* work to do on interrupt/exception return */
5618 #define _TIF_WORK_MASK \
5619 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5620 /* work to do on any return to u-space */
5621 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5622 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5623
5624 #endif /* __KERNEL__ */
5625
5626 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5627 index 9fdd8bc..4bd7f1a 100644
5628 --- a/arch/mips/kernel/binfmt_elfn32.c
5629 +++ b/arch/mips/kernel/binfmt_elfn32.c
5630 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5631 #undef ELF_ET_DYN_BASE
5632 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5633
5634 +#ifdef CONFIG_PAX_ASLR
5635 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5636 +
5637 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5638 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5639 +#endif
5640 +
5641 #include <asm/processor.h>
5642 #include <linux/module.h>
5643 #include <linux/elfcore.h>
5644 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5645 index ff44823..97f8906 100644
5646 --- a/arch/mips/kernel/binfmt_elfo32.c
5647 +++ b/arch/mips/kernel/binfmt_elfo32.c
5648 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5649 #undef ELF_ET_DYN_BASE
5650 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5651
5652 +#ifdef CONFIG_PAX_ASLR
5653 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5654 +
5655 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5656 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5657 +#endif
5658 +
5659 #include <asm/processor.h>
5660
5661 /*
5662 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5663 index a11c6f9..be5e164 100644
5664 --- a/arch/mips/kernel/process.c
5665 +++ b/arch/mips/kernel/process.c
5666 @@ -460,15 +460,3 @@ unsigned long get_wchan(struct task_struct *task)
5667 out:
5668 return pc;
5669 }
5670 -
5671 -/*
5672 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5673 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5674 - */
5675 -unsigned long arch_align_stack(unsigned long sp)
5676 -{
5677 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5678 - sp -= get_random_int() & ~PAGE_MASK;
5679 -
5680 - return sp & ALMASK;
5681 -}
5682 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5683 index 4812c6d..2069554 100644
5684 --- a/arch/mips/kernel/ptrace.c
5685 +++ b/arch/mips/kernel/ptrace.c
5686 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5687 return arch;
5688 }
5689
5690 +#ifdef CONFIG_GRKERNSEC_SETXID
5691 +extern void gr_delayed_cred_worker(void);
5692 +#endif
5693 +
5694 /*
5695 * Notification of system call entry/exit
5696 * - triggered by current->work.syscall_trace
5697 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5698 /* do the secure computing check first */
5699 secure_computing_strict(regs->regs[2]);
5700
5701 +#ifdef CONFIG_GRKERNSEC_SETXID
5702 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5703 + gr_delayed_cred_worker();
5704 +#endif
5705 +
5706 if (!(current->ptrace & PT_PTRACED))
5707 goto out;
5708
5709 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5710 index d20a4bc..7096ae5 100644
5711 --- a/arch/mips/kernel/scall32-o32.S
5712 +++ b/arch/mips/kernel/scall32-o32.S
5713 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5714
5715 stack_done:
5716 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5717 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5718 + li t1, _TIF_SYSCALL_WORK
5719 and t0, t1
5720 bnez t0, syscall_trace_entry # -> yes
5721
5722 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5723 index b64f642..0fe6eab 100644
5724 --- a/arch/mips/kernel/scall64-64.S
5725 +++ b/arch/mips/kernel/scall64-64.S
5726 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5727
5728 sd a3, PT_R26(sp) # save a3 for syscall restarting
5729
5730 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5731 + li t1, _TIF_SYSCALL_WORK
5732 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5733 and t0, t1, t0
5734 bnez t0, syscall_trace_entry
5735 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5736 index c29ac19..c592d05 100644
5737 --- a/arch/mips/kernel/scall64-n32.S
5738 +++ b/arch/mips/kernel/scall64-n32.S
5739 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5740
5741 sd a3, PT_R26(sp) # save a3 for syscall restarting
5742
5743 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5744 + li t1, _TIF_SYSCALL_WORK
5745 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5746 and t0, t1, t0
5747 bnez t0, n32_syscall_trace_entry
5748 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5749 index cf3e75e..72e93fe 100644
5750 --- a/arch/mips/kernel/scall64-o32.S
5751 +++ b/arch/mips/kernel/scall64-o32.S
5752 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5753 PTR 4b, bad_stack
5754 .previous
5755
5756 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5757 + li t1, _TIF_SYSCALL_WORK
5758 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5759 and t0, t1, t0
5760 bnez t0, trace_a_syscall
5761 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5762 index ddcec1e..c7f983e 100644
5763 --- a/arch/mips/mm/fault.c
5764 +++ b/arch/mips/mm/fault.c
5765 @@ -27,6 +27,23 @@
5766 #include <asm/highmem.h> /* For VMALLOC_END */
5767 #include <linux/kdebug.h>
5768
5769 +#ifdef CONFIG_PAX_PAGEEXEC
5770 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5771 +{
5772 + unsigned long i;
5773 +
5774 + printk(KERN_ERR "PAX: bytes at PC: ");
5775 + for (i = 0; i < 5; i++) {
5776 + unsigned int c;
5777 + if (get_user(c, (unsigned int *)pc+i))
5778 + printk(KERN_CONT "???????? ");
5779 + else
5780 + printk(KERN_CONT "%08x ", c);
5781 + }
5782 + printk("\n");
5783 +}
5784 +#endif
5785 +
5786 /*
5787 * This routine handles page faults. It determines the address,
5788 * and the problem, and then passes it off to one of the appropriate
5789 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5790 index 7e5fe27..479a219 100644
5791 --- a/arch/mips/mm/mmap.c
5792 +++ b/arch/mips/mm/mmap.c
5793 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5794 struct vm_area_struct *vma;
5795 unsigned long addr = addr0;
5796 int do_color_align;
5797 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5798 struct vm_unmapped_area_info info;
5799
5800 if (unlikely(len > TASK_SIZE))
5801 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5802 do_color_align = 1;
5803
5804 /* requesting a specific address */
5805 +
5806 +#ifdef CONFIG_PAX_RANDMMAP
5807 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5808 +#endif
5809 +
5810 if (addr) {
5811 if (do_color_align)
5812 addr = COLOUR_ALIGN(addr, pgoff);
5813 @@ -91,8 +97,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5814 addr = PAGE_ALIGN(addr);
5815
5816 vma = find_vma(mm, addr);
5817 - if (TASK_SIZE - len >= addr &&
5818 - (!vma || addr + len <= vma->vm_start))
5819 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5820 return addr;
5821 }
5822
5823 @@ -146,6 +151,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5824 {
5825 unsigned long random_factor = 0UL;
5826
5827 +#ifdef CONFIG_PAX_RANDMMAP
5828 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5829 +#endif
5830 +
5831 if (current->flags & PF_RANDOMIZE) {
5832 random_factor = get_random_int();
5833 random_factor = random_factor << PAGE_SHIFT;
5834 @@ -157,42 +166,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5835
5836 if (mmap_is_legacy()) {
5837 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5838 +
5839 +#ifdef CONFIG_PAX_RANDMMAP
5840 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5841 + mm->mmap_base += mm->delta_mmap;
5842 +#endif
5843 +
5844 mm->get_unmapped_area = arch_get_unmapped_area;
5845 mm->unmap_area = arch_unmap_area;
5846 } else {
5847 mm->mmap_base = mmap_base(random_factor);
5848 +
5849 +#ifdef CONFIG_PAX_RANDMMAP
5850 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5851 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5852 +#endif
5853 +
5854 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5855 mm->unmap_area = arch_unmap_area_topdown;
5856 }
5857 }
5858
5859 -static inline unsigned long brk_rnd(void)
5860 -{
5861 - unsigned long rnd = get_random_int();
5862 -
5863 - rnd = rnd << PAGE_SHIFT;
5864 - /* 8MB for 32bit, 256MB for 64bit */
5865 - if (TASK_IS_32BIT_ADDR)
5866 - rnd = rnd & 0x7ffffful;
5867 - else
5868 - rnd = rnd & 0xffffffful;
5869 -
5870 - return rnd;
5871 -}
5872 -
5873 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5874 -{
5875 - unsigned long base = mm->brk;
5876 - unsigned long ret;
5877 -
5878 - ret = PAGE_ALIGN(base + brk_rnd());
5879 -
5880 - if (ret < mm->brk)
5881 - return mm->brk;
5882 -
5883 - return ret;
5884 -}
5885 -
5886 int __virt_addr_valid(const volatile void *kaddr)
5887 {
5888 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5889 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5890 index 967d144..db12197 100644
5891 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5892 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5893 @@ -11,12 +11,14 @@
5894 #ifndef _ASM_PROC_CACHE_H
5895 #define _ASM_PROC_CACHE_H
5896
5897 +#include <linux/const.h>
5898 +
5899 /* L1 cache */
5900
5901 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5902 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5903 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5904 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5905 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5906 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5907
5908 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5909 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5910 index bcb5df2..84fabd2 100644
5911 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5912 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5913 @@ -16,13 +16,15 @@
5914 #ifndef _ASM_PROC_CACHE_H
5915 #define _ASM_PROC_CACHE_H
5916
5917 +#include <linux/const.h>
5918 +
5919 /*
5920 * L1 cache
5921 */
5922 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5923 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5924 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5925 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5926 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5927 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5928
5929 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5930 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5931 index 4ce7a01..449202a 100644
5932 --- a/arch/openrisc/include/asm/cache.h
5933 +++ b/arch/openrisc/include/asm/cache.h
5934 @@ -19,11 +19,13 @@
5935 #ifndef __ASM_OPENRISC_CACHE_H
5936 #define __ASM_OPENRISC_CACHE_H
5937
5938 +#include <linux/const.h>
5939 +
5940 /* FIXME: How can we replace these with values from the CPU...
5941 * they shouldn't be hard-coded!
5942 */
5943
5944 -#define L1_CACHE_BYTES 16
5945 #define L1_CACHE_SHIFT 4
5946 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5947
5948 #endif /* __ASM_OPENRISC_CACHE_H */
5949 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5950 index af9cf30..2aae9b2 100644
5951 --- a/arch/parisc/include/asm/atomic.h
5952 +++ b/arch/parisc/include/asm/atomic.h
5953 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5954
5955 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5956
5957 +#define atomic64_read_unchecked(v) atomic64_read(v)
5958 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5959 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5960 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5961 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5962 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5963 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5964 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5965 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5966 +
5967 #endif /* !CONFIG_64BIT */
5968
5969
5970 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5971 index 47f11c7..3420df2 100644
5972 --- a/arch/parisc/include/asm/cache.h
5973 +++ b/arch/parisc/include/asm/cache.h
5974 @@ -5,6 +5,7 @@
5975 #ifndef __ARCH_PARISC_CACHE_H
5976 #define __ARCH_PARISC_CACHE_H
5977
5978 +#include <linux/const.h>
5979
5980 /*
5981 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5982 @@ -15,13 +16,13 @@
5983 * just ruin performance.
5984 */
5985 #ifdef CONFIG_PA20
5986 -#define L1_CACHE_BYTES 64
5987 #define L1_CACHE_SHIFT 6
5988 #else
5989 -#define L1_CACHE_BYTES 32
5990 #define L1_CACHE_SHIFT 5
5991 #endif
5992
5993 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5994 +
5995 #ifndef __ASSEMBLY__
5996
5997 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5998 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5999 index 19f6cb1..6c78cf2 100644
6000 --- a/arch/parisc/include/asm/elf.h
6001 +++ b/arch/parisc/include/asm/elf.h
6002 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
6003
6004 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
6005
6006 +#ifdef CONFIG_PAX_ASLR
6007 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
6008 +
6009 +#define PAX_DELTA_MMAP_LEN 16
6010 +#define PAX_DELTA_STACK_LEN 16
6011 +#endif
6012 +
6013 /* This yields a mask that user programs can use to figure out what
6014 instruction set this CPU supports. This could be done in user space,
6015 but it's not easy, and we've already done it here. */
6016 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
6017 index fc987a1..6e068ef 100644
6018 --- a/arch/parisc/include/asm/pgalloc.h
6019 +++ b/arch/parisc/include/asm/pgalloc.h
6020 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6021 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
6022 }
6023
6024 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6025 +{
6026 + pgd_populate(mm, pgd, pmd);
6027 +}
6028 +
6029 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
6030 {
6031 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
6032 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
6033 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
6034 #define pmd_free(mm, x) do { } while (0)
6035 #define pgd_populate(mm, pmd, pte) BUG()
6036 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
6037
6038 #endif
6039
6040 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
6041 index 7df49fa..38b62bf 100644
6042 --- a/arch/parisc/include/asm/pgtable.h
6043 +++ b/arch/parisc/include/asm/pgtable.h
6044 @@ -218,6 +218,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6045 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
6046 #define PAGE_COPY PAGE_EXECREAD
6047 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
6048 +
6049 +#ifdef CONFIG_PAX_PAGEEXEC
6050 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
6051 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6052 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6053 +#else
6054 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
6055 +# define PAGE_COPY_NOEXEC PAGE_COPY
6056 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
6057 +#endif
6058 +
6059 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
6060 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
6061 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
6062 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
6063 index 4ba2c93..f5e3974 100644
6064 --- a/arch/parisc/include/asm/uaccess.h
6065 +++ b/arch/parisc/include/asm/uaccess.h
6066 @@ -251,10 +251,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
6067 const void __user *from,
6068 unsigned long n)
6069 {
6070 - int sz = __compiletime_object_size(to);
6071 + size_t sz = __compiletime_object_size(to);
6072 int ret = -EFAULT;
6073
6074 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
6075 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
6076 ret = __copy_from_user(to, from, n);
6077 else
6078 copy_from_user_overflow();
6079 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
6080 index 2a625fb..9908930 100644
6081 --- a/arch/parisc/kernel/module.c
6082 +++ b/arch/parisc/kernel/module.c
6083 @@ -98,16 +98,38 @@
6084
6085 /* three functions to determine where in the module core
6086 * or init pieces the location is */
6087 +static inline int in_init_rx(struct module *me, void *loc)
6088 +{
6089 + return (loc >= me->module_init_rx &&
6090 + loc < (me->module_init_rx + me->init_size_rx));
6091 +}
6092 +
6093 +static inline int in_init_rw(struct module *me, void *loc)
6094 +{
6095 + return (loc >= me->module_init_rw &&
6096 + loc < (me->module_init_rw + me->init_size_rw));
6097 +}
6098 +
6099 static inline int in_init(struct module *me, void *loc)
6100 {
6101 - return (loc >= me->module_init &&
6102 - loc <= (me->module_init + me->init_size));
6103 + return in_init_rx(me, loc) || in_init_rw(me, loc);
6104 +}
6105 +
6106 +static inline int in_core_rx(struct module *me, void *loc)
6107 +{
6108 + return (loc >= me->module_core_rx &&
6109 + loc < (me->module_core_rx + me->core_size_rx));
6110 +}
6111 +
6112 +static inline int in_core_rw(struct module *me, void *loc)
6113 +{
6114 + return (loc >= me->module_core_rw &&
6115 + loc < (me->module_core_rw + me->core_size_rw));
6116 }
6117
6118 static inline int in_core(struct module *me, void *loc)
6119 {
6120 - return (loc >= me->module_core &&
6121 - loc <= (me->module_core + me->core_size));
6122 + return in_core_rx(me, loc) || in_core_rw(me, loc);
6123 }
6124
6125 static inline int in_local(struct module *me, void *loc)
6126 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
6127 }
6128
6129 /* align things a bit */
6130 - me->core_size = ALIGN(me->core_size, 16);
6131 - me->arch.got_offset = me->core_size;
6132 - me->core_size += gots * sizeof(struct got_entry);
6133 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6134 + me->arch.got_offset = me->core_size_rw;
6135 + me->core_size_rw += gots * sizeof(struct got_entry);
6136
6137 - me->core_size = ALIGN(me->core_size, 16);
6138 - me->arch.fdesc_offset = me->core_size;
6139 - me->core_size += fdescs * sizeof(Elf_Fdesc);
6140 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6141 + me->arch.fdesc_offset = me->core_size_rw;
6142 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
6143
6144 me->arch.got_max = gots;
6145 me->arch.fdesc_max = fdescs;
6146 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6147
6148 BUG_ON(value == 0);
6149
6150 - got = me->module_core + me->arch.got_offset;
6151 + got = me->module_core_rw + me->arch.got_offset;
6152 for (i = 0; got[i].addr; i++)
6153 if (got[i].addr == value)
6154 goto out;
6155 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6156 #ifdef CONFIG_64BIT
6157 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6158 {
6159 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
6160 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
6161
6162 if (!value) {
6163 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
6164 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6165
6166 /* Create new one */
6167 fdesc->addr = value;
6168 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6169 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6170 return (Elf_Addr)fdesc;
6171 }
6172 #endif /* CONFIG_64BIT */
6173 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
6174
6175 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
6176 end = table + sechdrs[me->arch.unwind_section].sh_size;
6177 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6178 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6179
6180 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
6181 me->arch.unwind_section, table, end, gp);
6182 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
6183 index f76c108..92bad82 100644
6184 --- a/arch/parisc/kernel/sys_parisc.c
6185 +++ b/arch/parisc/kernel/sys_parisc.c
6186 @@ -33,9 +33,11 @@
6187 #include <linux/utsname.h>
6188 #include <linux/personality.h>
6189
6190 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6191 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
6192 + unsigned long flags)
6193 {
6194 struct vm_area_struct *vma;
6195 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6196
6197 addr = PAGE_ALIGN(addr);
6198
6199 @@ -43,7 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6200 /* At this point: (!vma || addr < vma->vm_end). */
6201 if (TASK_SIZE - len < addr)
6202 return -ENOMEM;
6203 - if (!vma || addr + len <= vma->vm_start)
6204 + if (check_heap_stack_gap(vma, addr, len, offset))
6205 return addr;
6206 addr = vma->vm_end;
6207 }
6208 @@ -67,11 +69,12 @@ static int get_offset(struct address_space *mapping)
6209 return offset & 0x3FF000;
6210 }
6211
6212 -static unsigned long get_shared_area(struct address_space *mapping,
6213 - unsigned long addr, unsigned long len, unsigned long pgoff)
6214 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
6215 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
6216 {
6217 struct vm_area_struct *vma;
6218 int offset = mapping ? get_offset(mapping) : 0;
6219 + unsigned long rand_offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6220
6221 offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
6222
6223 @@ -81,7 +84,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
6224 /* At this point: (!vma || addr < vma->vm_end). */
6225 if (TASK_SIZE - len < addr)
6226 return -ENOMEM;
6227 - if (!vma || addr + len <= vma->vm_start)
6228 + if (check_heap_stack_gap(vma, addr, len, rand_offset))
6229 return addr;
6230 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
6231 if (addr < vma->vm_end) /* handle wraparound */
6232 @@ -100,14 +103,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
6233 if (flags & MAP_FIXED)
6234 return addr;
6235 if (!addr)
6236 - addr = TASK_UNMAPPED_BASE;
6237 + addr = current->mm->mmap_base;
6238
6239 if (filp) {
6240 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6241 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6242 } else if(flags & MAP_SHARED) {
6243 - addr = get_shared_area(NULL, addr, len, pgoff);
6244 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6245 } else {
6246 - addr = get_unshared_area(addr, len);
6247 + addr = get_unshared_area(filp, addr, len, flags);
6248 }
6249 return addr;
6250 }
6251 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6252 index 45ba99f..8e22c33 100644
6253 --- a/arch/parisc/kernel/traps.c
6254 +++ b/arch/parisc/kernel/traps.c
6255 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6256
6257 down_read(&current->mm->mmap_sem);
6258 vma = find_vma(current->mm,regs->iaoq[0]);
6259 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6260 - && (vma->vm_flags & VM_EXEC)) {
6261 -
6262 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6263 fault_address = regs->iaoq[0];
6264 fault_space = regs->iasq[0];
6265
6266 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6267 index 18162ce..94de376 100644
6268 --- a/arch/parisc/mm/fault.c
6269 +++ b/arch/parisc/mm/fault.c
6270 @@ -15,6 +15,7 @@
6271 #include <linux/sched.h>
6272 #include <linux/interrupt.h>
6273 #include <linux/module.h>
6274 +#include <linux/unistd.h>
6275
6276 #include <asm/uaccess.h>
6277 #include <asm/traps.h>
6278 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6279 static unsigned long
6280 parisc_acctyp(unsigned long code, unsigned int inst)
6281 {
6282 - if (code == 6 || code == 16)
6283 + if (code == 6 || code == 7 || code == 16)
6284 return VM_EXEC;
6285
6286 switch (inst & 0xf0000000) {
6287 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6288 }
6289 #endif
6290
6291 +#ifdef CONFIG_PAX_PAGEEXEC
6292 +/*
6293 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6294 + *
6295 + * returns 1 when task should be killed
6296 + * 2 when rt_sigreturn trampoline was detected
6297 + * 3 when unpatched PLT trampoline was detected
6298 + */
6299 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6300 +{
6301 +
6302 +#ifdef CONFIG_PAX_EMUPLT
6303 + int err;
6304 +
6305 + do { /* PaX: unpatched PLT emulation */
6306 + unsigned int bl, depwi;
6307 +
6308 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6309 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6310 +
6311 + if (err)
6312 + break;
6313 +
6314 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6315 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6316 +
6317 + err = get_user(ldw, (unsigned int *)addr);
6318 + err |= get_user(bv, (unsigned int *)(addr+4));
6319 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6320 +
6321 + if (err)
6322 + break;
6323 +
6324 + if (ldw == 0x0E801096U &&
6325 + bv == 0xEAC0C000U &&
6326 + ldw2 == 0x0E881095U)
6327 + {
6328 + unsigned int resolver, map;
6329 +
6330 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6331 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6332 + if (err)
6333 + break;
6334 +
6335 + regs->gr[20] = instruction_pointer(regs)+8;
6336 + regs->gr[21] = map;
6337 + regs->gr[22] = resolver;
6338 + regs->iaoq[0] = resolver | 3UL;
6339 + regs->iaoq[1] = regs->iaoq[0] + 4;
6340 + return 3;
6341 + }
6342 + }
6343 + } while (0);
6344 +#endif
6345 +
6346 +#ifdef CONFIG_PAX_EMUTRAMP
6347 +
6348 +#ifndef CONFIG_PAX_EMUSIGRT
6349 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6350 + return 1;
6351 +#endif
6352 +
6353 + do { /* PaX: rt_sigreturn emulation */
6354 + unsigned int ldi1, ldi2, bel, nop;
6355 +
6356 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6357 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6358 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6359 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6360 +
6361 + if (err)
6362 + break;
6363 +
6364 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6365 + ldi2 == 0x3414015AU &&
6366 + bel == 0xE4008200U &&
6367 + nop == 0x08000240U)
6368 + {
6369 + regs->gr[25] = (ldi1 & 2) >> 1;
6370 + regs->gr[20] = __NR_rt_sigreturn;
6371 + regs->gr[31] = regs->iaoq[1] + 16;
6372 + regs->sr[0] = regs->iasq[1];
6373 + regs->iaoq[0] = 0x100UL;
6374 + regs->iaoq[1] = regs->iaoq[0] + 4;
6375 + regs->iasq[0] = regs->sr[2];
6376 + regs->iasq[1] = regs->sr[2];
6377 + return 2;
6378 + }
6379 + } while (0);
6380 +#endif
6381 +
6382 + return 1;
6383 +}
6384 +
6385 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6386 +{
6387 + unsigned long i;
6388 +
6389 + printk(KERN_ERR "PAX: bytes at PC: ");
6390 + for (i = 0; i < 5; i++) {
6391 + unsigned int c;
6392 + if (get_user(c, (unsigned int *)pc+i))
6393 + printk(KERN_CONT "???????? ");
6394 + else
6395 + printk(KERN_CONT "%08x ", c);
6396 + }
6397 + printk("\n");
6398 +}
6399 +#endif
6400 +
6401 int fixup_exception(struct pt_regs *regs)
6402 {
6403 const struct exception_table_entry *fix;
6404 @@ -192,8 +303,33 @@ good_area:
6405
6406 acc_type = parisc_acctyp(code,regs->iir);
6407
6408 - if ((vma->vm_flags & acc_type) != acc_type)
6409 + if ((vma->vm_flags & acc_type) != acc_type) {
6410 +
6411 +#ifdef CONFIG_PAX_PAGEEXEC
6412 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6413 + (address & ~3UL) == instruction_pointer(regs))
6414 + {
6415 + up_read(&mm->mmap_sem);
6416 + switch (pax_handle_fetch_fault(regs)) {
6417 +
6418 +#ifdef CONFIG_PAX_EMUPLT
6419 + case 3:
6420 + return;
6421 +#endif
6422 +
6423 +#ifdef CONFIG_PAX_EMUTRAMP
6424 + case 2:
6425 + return;
6426 +#endif
6427 +
6428 + }
6429 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6430 + do_group_exit(SIGKILL);
6431 + }
6432 +#endif
6433 +
6434 goto bad_area;
6435 + }
6436
6437 /*
6438 * If for any reason at all we couldn't handle the fault, make
6439 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6440 index e3b1d41..8e81edf 100644
6441 --- a/arch/powerpc/include/asm/atomic.h
6442 +++ b/arch/powerpc/include/asm/atomic.h
6443 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6444 return t1;
6445 }
6446
6447 +#define atomic64_read_unchecked(v) atomic64_read(v)
6448 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6449 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6450 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6451 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6452 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6453 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6454 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6455 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6456 +
6457 #endif /* __powerpc64__ */
6458
6459 #endif /* __KERNEL__ */
6460 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6461 index 9e495c9..b6878e5 100644
6462 --- a/arch/powerpc/include/asm/cache.h
6463 +++ b/arch/powerpc/include/asm/cache.h
6464 @@ -3,6 +3,7 @@
6465
6466 #ifdef __KERNEL__
6467
6468 +#include <linux/const.h>
6469
6470 /* bytes per L1 cache line */
6471 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6472 @@ -22,7 +23,7 @@
6473 #define L1_CACHE_SHIFT 7
6474 #endif
6475
6476 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6477 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6478
6479 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6480
6481 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6482 index 6abf0a1..459d0f1 100644
6483 --- a/arch/powerpc/include/asm/elf.h
6484 +++ b/arch/powerpc/include/asm/elf.h
6485 @@ -28,8 +28,19 @@
6486 the loader. We need to make sure that it is out of the way of the program
6487 that it will "exec", and that there is sufficient room for the brk. */
6488
6489 -extern unsigned long randomize_et_dyn(unsigned long base);
6490 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6491 +#define ELF_ET_DYN_BASE (0x20000000)
6492 +
6493 +#ifdef CONFIG_PAX_ASLR
6494 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6495 +
6496 +#ifdef __powerpc64__
6497 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6498 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6499 +#else
6500 +#define PAX_DELTA_MMAP_LEN 15
6501 +#define PAX_DELTA_STACK_LEN 15
6502 +#endif
6503 +#endif
6504
6505 /*
6506 * Our registers are always unsigned longs, whether we're a 32 bit
6507 @@ -124,10 +135,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6508 (0x7ff >> (PAGE_SHIFT - 12)) : \
6509 (0x3ffff >> (PAGE_SHIFT - 12)))
6510
6511 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6512 -#define arch_randomize_brk arch_randomize_brk
6513 -
6514 -
6515 #ifdef CONFIG_SPU_BASE
6516 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6517 #define NT_SPU 1
6518 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6519 index 8196e9c..d83a9f3 100644
6520 --- a/arch/powerpc/include/asm/exec.h
6521 +++ b/arch/powerpc/include/asm/exec.h
6522 @@ -4,6 +4,6 @@
6523 #ifndef _ASM_POWERPC_EXEC_H
6524 #define _ASM_POWERPC_EXEC_H
6525
6526 -extern unsigned long arch_align_stack(unsigned long sp);
6527 +#define arch_align_stack(x) ((x) & ~0xfUL)
6528
6529 #endif /* _ASM_POWERPC_EXEC_H */
6530 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6531 index 5acabbd..7ea14fa 100644
6532 --- a/arch/powerpc/include/asm/kmap_types.h
6533 +++ b/arch/powerpc/include/asm/kmap_types.h
6534 @@ -10,7 +10,7 @@
6535 * 2 of the License, or (at your option) any later version.
6536 */
6537
6538 -#define KM_TYPE_NR 16
6539 +#define KM_TYPE_NR 17
6540
6541 #endif /* __KERNEL__ */
6542 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6543 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6544 index 8565c25..2865190 100644
6545 --- a/arch/powerpc/include/asm/mman.h
6546 +++ b/arch/powerpc/include/asm/mman.h
6547 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6548 }
6549 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6550
6551 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6552 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6553 {
6554 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6555 }
6556 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6557 index f072e97..b436dee 100644
6558 --- a/arch/powerpc/include/asm/page.h
6559 +++ b/arch/powerpc/include/asm/page.h
6560 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6561 * and needs to be executable. This means the whole heap ends
6562 * up being executable.
6563 */
6564 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6565 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6566 +#define VM_DATA_DEFAULT_FLAGS32 \
6567 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6568 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6569
6570 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6571 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6572 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6573 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6574 #endif
6575
6576 +#define ktla_ktva(addr) (addr)
6577 +#define ktva_ktla(addr) (addr)
6578 +
6579 /*
6580 * Use the top bit of the higher-level page table entries to indicate whether
6581 * the entries we point to contain hugepages. This works because we know that
6582 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6583 index cd915d6..c10cee8 100644
6584 --- a/arch/powerpc/include/asm/page_64.h
6585 +++ b/arch/powerpc/include/asm/page_64.h
6586 @@ -154,15 +154,18 @@ do { \
6587 * stack by default, so in the absence of a PT_GNU_STACK program header
6588 * we turn execute permission off.
6589 */
6590 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6591 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6592 +#define VM_STACK_DEFAULT_FLAGS32 \
6593 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6594 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6595
6596 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6597 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6598
6599 +#ifndef CONFIG_PAX_PAGEEXEC
6600 #define VM_STACK_DEFAULT_FLAGS \
6601 (is_32bit_task() ? \
6602 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6603 +#endif
6604
6605 #include <asm-generic/getorder.h>
6606
6607 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6608 index 292725c..f87ae14 100644
6609 --- a/arch/powerpc/include/asm/pgalloc-64.h
6610 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6611 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6612 #ifndef CONFIG_PPC_64K_PAGES
6613
6614 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6615 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6616
6617 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6618 {
6619 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6620 pud_set(pud, (unsigned long)pmd);
6621 }
6622
6623 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6624 +{
6625 + pud_populate(mm, pud, pmd);
6626 +}
6627 +
6628 #define pmd_populate(mm, pmd, pte_page) \
6629 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6630 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6631 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6632 #else /* CONFIG_PPC_64K_PAGES */
6633
6634 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6635 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6636
6637 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6638 pte_t *pte)
6639 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6640 index a9cbd3b..3b67efa 100644
6641 --- a/arch/powerpc/include/asm/pgtable.h
6642 +++ b/arch/powerpc/include/asm/pgtable.h
6643 @@ -2,6 +2,7 @@
6644 #define _ASM_POWERPC_PGTABLE_H
6645 #ifdef __KERNEL__
6646
6647 +#include <linux/const.h>
6648 #ifndef __ASSEMBLY__
6649 #include <asm/processor.h> /* For TASK_SIZE */
6650 #include <asm/mmu.h>
6651 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6652 index 4aad413..85d86bf 100644
6653 --- a/arch/powerpc/include/asm/pte-hash32.h
6654 +++ b/arch/powerpc/include/asm/pte-hash32.h
6655 @@ -21,6 +21,7 @@
6656 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6657 #define _PAGE_USER 0x004 /* usermode access allowed */
6658 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6659 +#define _PAGE_EXEC _PAGE_GUARDED
6660 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6661 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6662 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6663 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6664 index 3d5c9dc..62f8414 100644
6665 --- a/arch/powerpc/include/asm/reg.h
6666 +++ b/arch/powerpc/include/asm/reg.h
6667 @@ -215,6 +215,7 @@
6668 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6669 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6670 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6671 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6672 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6673 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6674 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6675 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6676 index 406b7b9..af63426 100644
6677 --- a/arch/powerpc/include/asm/thread_info.h
6678 +++ b/arch/powerpc/include/asm/thread_info.h
6679 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6680 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6681 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6682 #define TIF_SINGLESTEP 8 /* singlestepping active */
6683 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6684 #define TIF_SECCOMP 10 /* secure computing */
6685 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6686 #define TIF_NOERROR 12 /* Force successful syscall return */
6687 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6688 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6689 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6690 for stack store? */
6691 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6692 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6693 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6694
6695 /* as above, but as bit values */
6696 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6697 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6698 #define _TIF_UPROBE (1<<TIF_UPROBE)
6699 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6700 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6701 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6702 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6703 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6704 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6705 + _TIF_GRSEC_SETXID)
6706
6707 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6708 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6709 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6710 index 4db4959..aba5c41 100644
6711 --- a/arch/powerpc/include/asm/uaccess.h
6712 +++ b/arch/powerpc/include/asm/uaccess.h
6713 @@ -318,52 +318,6 @@ do { \
6714 extern unsigned long __copy_tofrom_user(void __user *to,
6715 const void __user *from, unsigned long size);
6716
6717 -#ifndef __powerpc64__
6718 -
6719 -static inline unsigned long copy_from_user(void *to,
6720 - const void __user *from, unsigned long n)
6721 -{
6722 - unsigned long over;
6723 -
6724 - if (access_ok(VERIFY_READ, from, n))
6725 - return __copy_tofrom_user((__force void __user *)to, from, n);
6726 - if ((unsigned long)from < TASK_SIZE) {
6727 - over = (unsigned long)from + n - TASK_SIZE;
6728 - return __copy_tofrom_user((__force void __user *)to, from,
6729 - n - over) + over;
6730 - }
6731 - return n;
6732 -}
6733 -
6734 -static inline unsigned long copy_to_user(void __user *to,
6735 - const void *from, unsigned long n)
6736 -{
6737 - unsigned long over;
6738 -
6739 - if (access_ok(VERIFY_WRITE, to, n))
6740 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6741 - if ((unsigned long)to < TASK_SIZE) {
6742 - over = (unsigned long)to + n - TASK_SIZE;
6743 - return __copy_tofrom_user(to, (__force void __user *)from,
6744 - n - over) + over;
6745 - }
6746 - return n;
6747 -}
6748 -
6749 -#else /* __powerpc64__ */
6750 -
6751 -#define __copy_in_user(to, from, size) \
6752 - __copy_tofrom_user((to), (from), (size))
6753 -
6754 -extern unsigned long copy_from_user(void *to, const void __user *from,
6755 - unsigned long n);
6756 -extern unsigned long copy_to_user(void __user *to, const void *from,
6757 - unsigned long n);
6758 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6759 - unsigned long n);
6760 -
6761 -#endif /* __powerpc64__ */
6762 -
6763 static inline unsigned long __copy_from_user_inatomic(void *to,
6764 const void __user *from, unsigned long n)
6765 {
6766 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6767 if (ret == 0)
6768 return 0;
6769 }
6770 +
6771 + if (!__builtin_constant_p(n))
6772 + check_object_size(to, n, false);
6773 +
6774 return __copy_tofrom_user((__force void __user *)to, from, n);
6775 }
6776
6777 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6778 if (ret == 0)
6779 return 0;
6780 }
6781 +
6782 + if (!__builtin_constant_p(n))
6783 + check_object_size(from, n, true);
6784 +
6785 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6786 }
6787
6788 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6789 return __copy_to_user_inatomic(to, from, size);
6790 }
6791
6792 +#ifndef __powerpc64__
6793 +
6794 +static inline unsigned long __must_check copy_from_user(void *to,
6795 + const void __user *from, unsigned long n)
6796 +{
6797 + unsigned long over;
6798 +
6799 + if ((long)n < 0)
6800 + return n;
6801 +
6802 + if (access_ok(VERIFY_READ, from, n)) {
6803 + if (!__builtin_constant_p(n))
6804 + check_object_size(to, n, false);
6805 + return __copy_tofrom_user((__force void __user *)to, from, n);
6806 + }
6807 + if ((unsigned long)from < TASK_SIZE) {
6808 + over = (unsigned long)from + n - TASK_SIZE;
6809 + if (!__builtin_constant_p(n - over))
6810 + check_object_size(to, n - over, false);
6811 + return __copy_tofrom_user((__force void __user *)to, from,
6812 + n - over) + over;
6813 + }
6814 + return n;
6815 +}
6816 +
6817 +static inline unsigned long __must_check copy_to_user(void __user *to,
6818 + const void *from, unsigned long n)
6819 +{
6820 + unsigned long over;
6821 +
6822 + if ((long)n < 0)
6823 + return n;
6824 +
6825 + if (access_ok(VERIFY_WRITE, to, n)) {
6826 + if (!__builtin_constant_p(n))
6827 + check_object_size(from, n, true);
6828 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6829 + }
6830 + if ((unsigned long)to < TASK_SIZE) {
6831 + over = (unsigned long)to + n - TASK_SIZE;
6832 + if (!__builtin_constant_p(n))
6833 + check_object_size(from, n - over, true);
6834 + return __copy_tofrom_user(to, (__force void __user *)from,
6835 + n - over) + over;
6836 + }
6837 + return n;
6838 +}
6839 +
6840 +#else /* __powerpc64__ */
6841 +
6842 +#define __copy_in_user(to, from, size) \
6843 + __copy_tofrom_user((to), (from), (size))
6844 +
6845 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6846 +{
6847 + if ((long)n < 0 || n > INT_MAX)
6848 + return n;
6849 +
6850 + if (!__builtin_constant_p(n))
6851 + check_object_size(to, n, false);
6852 +
6853 + if (likely(access_ok(VERIFY_READ, from, n)))
6854 + n = __copy_from_user(to, from, n);
6855 + else
6856 + memset(to, 0, n);
6857 + return n;
6858 +}
6859 +
6860 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6861 +{
6862 + if ((long)n < 0 || n > INT_MAX)
6863 + return n;
6864 +
6865 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6866 + if (!__builtin_constant_p(n))
6867 + check_object_size(from, n, true);
6868 + n = __copy_to_user(to, from, n);
6869 + }
6870 + return n;
6871 +}
6872 +
6873 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6874 + unsigned long n);
6875 +
6876 +#endif /* __powerpc64__ */
6877 +
6878 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6879
6880 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6881 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6882 index 4684e33..acc4d19e 100644
6883 --- a/arch/powerpc/kernel/exceptions-64e.S
6884 +++ b/arch/powerpc/kernel/exceptions-64e.S
6885 @@ -715,6 +715,7 @@ storage_fault_common:
6886 std r14,_DAR(r1)
6887 std r15,_DSISR(r1)
6888 addi r3,r1,STACK_FRAME_OVERHEAD
6889 + bl .save_nvgprs
6890 mr r4,r14
6891 mr r5,r15
6892 ld r14,PACA_EXGEN+EX_R14(r13)
6893 @@ -723,8 +724,7 @@ storage_fault_common:
6894 cmpdi r3,0
6895 bne- 1f
6896 b .ret_from_except_lite
6897 -1: bl .save_nvgprs
6898 - mr r5,r3
6899 +1: mr r5,r3
6900 addi r3,r1,STACK_FRAME_OVERHEAD
6901 ld r4,_DAR(r1)
6902 bl .bad_page_fault
6903 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6904 index 3684cbd..bc89eab 100644
6905 --- a/arch/powerpc/kernel/exceptions-64s.S
6906 +++ b/arch/powerpc/kernel/exceptions-64s.S
6907 @@ -1206,10 +1206,10 @@ handle_page_fault:
6908 11: ld r4,_DAR(r1)
6909 ld r5,_DSISR(r1)
6910 addi r3,r1,STACK_FRAME_OVERHEAD
6911 + bl .save_nvgprs
6912 bl .do_page_fault
6913 cmpdi r3,0
6914 beq+ 12f
6915 - bl .save_nvgprs
6916 mr r5,r3
6917 addi r3,r1,STACK_FRAME_OVERHEAD
6918 lwz r4,_DAR(r1)
6919 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6920 index 2e3200c..72095ce 100644
6921 --- a/arch/powerpc/kernel/module_32.c
6922 +++ b/arch/powerpc/kernel/module_32.c
6923 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6924 me->arch.core_plt_section = i;
6925 }
6926 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6927 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6928 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6929 return -ENOEXEC;
6930 }
6931
6932 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6933
6934 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6935 /* Init, or core PLT? */
6936 - if (location >= mod->module_core
6937 - && location < mod->module_core + mod->core_size)
6938 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6939 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6940 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6941 - else
6942 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6943 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6944 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6945 + else {
6946 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6947 + return ~0UL;
6948 + }
6949
6950 /* Find this entry, or if that fails, the next avail. entry */
6951 while (entry->jump[0]) {
6952 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6953 index 8143067..21ae55b 100644
6954 --- a/arch/powerpc/kernel/process.c
6955 +++ b/arch/powerpc/kernel/process.c
6956 @@ -680,8 +680,8 @@ void show_regs(struct pt_regs * regs)
6957 * Lookup NIP late so we have the best change of getting the
6958 * above info out without failing
6959 */
6960 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6961 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6962 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6963 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6964 #endif
6965 show_stack(current, (unsigned long *) regs->gpr[1]);
6966 if (!user_mode(regs))
6967 @@ -1129,10 +1129,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6968 newsp = stack[0];
6969 ip = stack[STACK_FRAME_LR_SAVE];
6970 if (!firstframe || ip != lr) {
6971 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6972 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6973 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6974 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6975 - printk(" (%pS)",
6976 + printk(" (%pA)",
6977 (void *)current->ret_stack[curr_frame].ret);
6978 curr_frame--;
6979 }
6980 @@ -1152,7 +1152,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6981 struct pt_regs *regs = (struct pt_regs *)
6982 (sp + STACK_FRAME_OVERHEAD);
6983 lr = regs->link;
6984 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6985 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6986 regs->trap, (void *)regs->nip, (void *)lr);
6987 firstframe = 1;
6988 }
6989 @@ -1194,58 +1194,3 @@ void __ppc64_runlatch_off(void)
6990 mtspr(SPRN_CTRLT, ctrl);
6991 }
6992 #endif /* CONFIG_PPC64 */
6993 -
6994 -unsigned long arch_align_stack(unsigned long sp)
6995 -{
6996 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6997 - sp -= get_random_int() & ~PAGE_MASK;
6998 - return sp & ~0xf;
6999 -}
7000 -
7001 -static inline unsigned long brk_rnd(void)
7002 -{
7003 - unsigned long rnd = 0;
7004 -
7005 - /* 8MB for 32bit, 1GB for 64bit */
7006 - if (is_32bit_task())
7007 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
7008 - else
7009 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
7010 -
7011 - return rnd << PAGE_SHIFT;
7012 -}
7013 -
7014 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7015 -{
7016 - unsigned long base = mm->brk;
7017 - unsigned long ret;
7018 -
7019 -#ifdef CONFIG_PPC_STD_MMU_64
7020 - /*
7021 - * If we are using 1TB segments and we are allowed to randomise
7022 - * the heap, we can put it above 1TB so it is backed by a 1TB
7023 - * segment. Otherwise the heap will be in the bottom 1TB
7024 - * which always uses 256MB segments and this may result in a
7025 - * performance penalty.
7026 - */
7027 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
7028 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
7029 -#endif
7030 -
7031 - ret = PAGE_ALIGN(base + brk_rnd());
7032 -
7033 - if (ret < mm->brk)
7034 - return mm->brk;
7035 -
7036 - return ret;
7037 -}
7038 -
7039 -unsigned long randomize_et_dyn(unsigned long base)
7040 -{
7041 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7042 -
7043 - if (ret < base)
7044 - return base;
7045 -
7046 - return ret;
7047 -}
7048 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
7049 index c497000..8fde506 100644
7050 --- a/arch/powerpc/kernel/ptrace.c
7051 +++ b/arch/powerpc/kernel/ptrace.c
7052 @@ -1737,6 +1737,10 @@ long arch_ptrace(struct task_struct *child, long request,
7053 return ret;
7054 }
7055
7056 +#ifdef CONFIG_GRKERNSEC_SETXID
7057 +extern void gr_delayed_cred_worker(void);
7058 +#endif
7059 +
7060 /*
7061 * We must return the syscall number to actually look up in the table.
7062 * This can be -1L to skip running any syscall at all.
7063 @@ -1747,6 +1751,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
7064
7065 secure_computing_strict(regs->gpr[0]);
7066
7067 +#ifdef CONFIG_GRKERNSEC_SETXID
7068 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7069 + gr_delayed_cred_worker();
7070 +#endif
7071 +
7072 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
7073 tracehook_report_syscall_entry(regs))
7074 /*
7075 @@ -1781,6 +1790,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
7076 {
7077 int step;
7078
7079 +#ifdef CONFIG_GRKERNSEC_SETXID
7080 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7081 + gr_delayed_cred_worker();
7082 +#endif
7083 +
7084 audit_syscall_exit(regs);
7085
7086 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
7087 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
7088 index 804e323..79181c1 100644
7089 --- a/arch/powerpc/kernel/signal_32.c
7090 +++ b/arch/powerpc/kernel/signal_32.c
7091 @@ -851,7 +851,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
7092 /* Save user registers on the stack */
7093 frame = &rt_sf->uc.uc_mcontext;
7094 addr = frame;
7095 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
7096 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7097 if (save_user_regs(regs, frame, 0, 1))
7098 goto badframe;
7099 regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp;
7100 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
7101 index 1ca045d..139c3f7 100644
7102 --- a/arch/powerpc/kernel/signal_64.c
7103 +++ b/arch/powerpc/kernel/signal_64.c
7104 @@ -430,7 +430,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
7105 current->thread.fpscr.val = 0;
7106
7107 /* Set up to return from userspace. */
7108 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
7109 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7110 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
7111 } else {
7112 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
7113 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
7114 index 3ce1f86..c30e629 100644
7115 --- a/arch/powerpc/kernel/sysfs.c
7116 +++ b/arch/powerpc/kernel/sysfs.c
7117 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
7118 return NOTIFY_OK;
7119 }
7120
7121 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
7122 +static struct notifier_block sysfs_cpu_nb = {
7123 .notifier_call = sysfs_cpu_notify,
7124 };
7125
7126 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
7127 index 3251840..3f7c77a 100644
7128 --- a/arch/powerpc/kernel/traps.c
7129 +++ b/arch/powerpc/kernel/traps.c
7130 @@ -133,6 +133,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
7131 return flags;
7132 }
7133
7134 +extern void gr_handle_kernel_exploit(void);
7135 +
7136 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7137 int signr)
7138 {
7139 @@ -182,6 +184,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7140 panic("Fatal exception in interrupt");
7141 if (panic_on_oops)
7142 panic("Fatal exception");
7143 +
7144 + gr_handle_kernel_exploit();
7145 +
7146 do_exit(signr);
7147 }
7148
7149 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
7150 index 1b2076f..835e4be 100644
7151 --- a/arch/powerpc/kernel/vdso.c
7152 +++ b/arch/powerpc/kernel/vdso.c
7153 @@ -34,6 +34,7 @@
7154 #include <asm/firmware.h>
7155 #include <asm/vdso.h>
7156 #include <asm/vdso_datapage.h>
7157 +#include <asm/mman.h>
7158
7159 #include "setup.h"
7160
7161 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7162 vdso_base = VDSO32_MBASE;
7163 #endif
7164
7165 - current->mm->context.vdso_base = 0;
7166 + current->mm->context.vdso_base = ~0UL;
7167
7168 /* vDSO has a problem and was disabled, just don't "enable" it for the
7169 * process
7170 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7171 vdso_base = get_unmapped_area(NULL, vdso_base,
7172 (vdso_pages << PAGE_SHIFT) +
7173 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
7174 - 0, 0);
7175 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
7176 if (IS_ERR_VALUE(vdso_base)) {
7177 rc = vdso_base;
7178 goto fail_mmapsem;
7179 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
7180 index 5eea6f3..5d10396 100644
7181 --- a/arch/powerpc/lib/usercopy_64.c
7182 +++ b/arch/powerpc/lib/usercopy_64.c
7183 @@ -9,22 +9,6 @@
7184 #include <linux/module.h>
7185 #include <asm/uaccess.h>
7186
7187 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
7188 -{
7189 - if (likely(access_ok(VERIFY_READ, from, n)))
7190 - n = __copy_from_user(to, from, n);
7191 - else
7192 - memset(to, 0, n);
7193 - return n;
7194 -}
7195 -
7196 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
7197 -{
7198 - if (likely(access_ok(VERIFY_WRITE, to, n)))
7199 - n = __copy_to_user(to, from, n);
7200 - return n;
7201 -}
7202 -
7203 unsigned long copy_in_user(void __user *to, const void __user *from,
7204 unsigned long n)
7205 {
7206 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
7207 return n;
7208 }
7209
7210 -EXPORT_SYMBOL(copy_from_user);
7211 -EXPORT_SYMBOL(copy_to_user);
7212 EXPORT_SYMBOL(copy_in_user);
7213
7214 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
7215 index 3a8489a..6a63b3b 100644
7216 --- a/arch/powerpc/mm/fault.c
7217 +++ b/arch/powerpc/mm/fault.c
7218 @@ -32,6 +32,10 @@
7219 #include <linux/perf_event.h>
7220 #include <linux/magic.h>
7221 #include <linux/ratelimit.h>
7222 +#include <linux/slab.h>
7223 +#include <linux/pagemap.h>
7224 +#include <linux/compiler.h>
7225 +#include <linux/unistd.h>
7226
7227 #include <asm/firmware.h>
7228 #include <asm/page.h>
7229 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7230 }
7231 #endif
7232
7233 +#ifdef CONFIG_PAX_PAGEEXEC
7234 +/*
7235 + * PaX: decide what to do with offenders (regs->nip = fault address)
7236 + *
7237 + * returns 1 when task should be killed
7238 + */
7239 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7240 +{
7241 + return 1;
7242 +}
7243 +
7244 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7245 +{
7246 + unsigned long i;
7247 +
7248 + printk(KERN_ERR "PAX: bytes at PC: ");
7249 + for (i = 0; i < 5; i++) {
7250 + unsigned int c;
7251 + if (get_user(c, (unsigned int __user *)pc+i))
7252 + printk(KERN_CONT "???????? ");
7253 + else
7254 + printk(KERN_CONT "%08x ", c);
7255 + }
7256 + printk("\n");
7257 +}
7258 +#endif
7259 +
7260 /*
7261 * Check whether the instruction at regs->nip is a store using
7262 * an update addressing form which will update r1.
7263 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7264 * indicate errors in DSISR but can validly be set in SRR1.
7265 */
7266 if (trap == 0x400)
7267 - error_code &= 0x48200000;
7268 + error_code &= 0x58200000;
7269 else
7270 is_write = error_code & DSISR_ISSTORE;
7271 #else
7272 @@ -364,7 +395,7 @@ good_area:
7273 * "undefined". Of those that can be set, this is the only
7274 * one which seems bad.
7275 */
7276 - if (error_code & 0x10000000)
7277 + if (error_code & DSISR_GUARDED)
7278 /* Guarded storage error. */
7279 goto bad_area;
7280 #endif /* CONFIG_8xx */
7281 @@ -379,7 +410,7 @@ good_area:
7282 * processors use the same I/D cache coherency mechanism
7283 * as embedded.
7284 */
7285 - if (error_code & DSISR_PROTFAULT)
7286 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7287 goto bad_area;
7288 #endif /* CONFIG_PPC_STD_MMU */
7289
7290 @@ -462,6 +493,23 @@ bad_area:
7291 bad_area_nosemaphore:
7292 /* User mode accesses cause a SIGSEGV */
7293 if (user_mode(regs)) {
7294 +
7295 +#ifdef CONFIG_PAX_PAGEEXEC
7296 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7297 +#ifdef CONFIG_PPC_STD_MMU
7298 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7299 +#else
7300 + if (is_exec && regs->nip == address) {
7301 +#endif
7302 + switch (pax_handle_fetch_fault(regs)) {
7303 + }
7304 +
7305 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7306 + do_group_exit(SIGKILL);
7307 + }
7308 + }
7309 +#endif
7310 +
7311 _exception(SIGSEGV, regs, code, address);
7312 return 0;
7313 }
7314 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7315 index 67a42ed..cd463e0 100644
7316 --- a/arch/powerpc/mm/mmap_64.c
7317 +++ b/arch/powerpc/mm/mmap_64.c
7318 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7319 {
7320 unsigned long rnd = 0;
7321
7322 +#ifdef CONFIG_PAX_RANDMMAP
7323 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7324 +#endif
7325 +
7326 if (current->flags & PF_RANDOMIZE) {
7327 /* 8MB for 32bit, 1GB for 64bit */
7328 if (is_32bit_task())
7329 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7330 */
7331 if (mmap_is_legacy()) {
7332 mm->mmap_base = TASK_UNMAPPED_BASE;
7333 +
7334 +#ifdef CONFIG_PAX_RANDMMAP
7335 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7336 + mm->mmap_base += mm->delta_mmap;
7337 +#endif
7338 +
7339 mm->get_unmapped_area = arch_get_unmapped_area;
7340 mm->unmap_area = arch_unmap_area;
7341 } else {
7342 mm->mmap_base = mmap_base();
7343 +
7344 +#ifdef CONFIG_PAX_RANDMMAP
7345 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7346 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7347 +#endif
7348 +
7349 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7350 mm->unmap_area = arch_unmap_area_topdown;
7351 }
7352 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7353 index e779642..e5bb889 100644
7354 --- a/arch/powerpc/mm/mmu_context_nohash.c
7355 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7356 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7357 return NOTIFY_OK;
7358 }
7359
7360 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7361 +static struct notifier_block mmu_context_cpu_nb = {
7362 .notifier_call = mmu_context_cpu_notify,
7363 };
7364
7365 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7366 index bba87ca..c346a33 100644
7367 --- a/arch/powerpc/mm/numa.c
7368 +++ b/arch/powerpc/mm/numa.c
7369 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7370 return ret;
7371 }
7372
7373 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7374 +static struct notifier_block ppc64_numa_nb = {
7375 .notifier_call = cpu_numa_callback,
7376 .priority = 1 /* Must run before sched domains notifier. */
7377 };
7378 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7379 index cf9dada..241529f 100644
7380 --- a/arch/powerpc/mm/slice.c
7381 +++ b/arch/powerpc/mm/slice.c
7382 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7383 if ((mm->task_size - len) < addr)
7384 return 0;
7385 vma = find_vma(mm, addr);
7386 - return (!vma || (addr + len) <= vma->vm_start);
7387 + return check_heap_stack_gap(vma, addr, len, 0);
7388 }
7389
7390 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7391 @@ -272,7 +272,7 @@ full_search:
7392 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7393 continue;
7394 }
7395 - if (!vma || addr + len <= vma->vm_start) {
7396 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7397 /*
7398 * Remember the place where we stopped the search:
7399 */
7400 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7401 }
7402 }
7403
7404 - addr = mm->mmap_base;
7405 - while (addr > len) {
7406 + if (mm->mmap_base < len)
7407 + addr = -ENOMEM;
7408 + else
7409 + addr = mm->mmap_base - len;
7410 +
7411 + while (!IS_ERR_VALUE(addr)) {
7412 /* Go down by chunk size */
7413 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7414 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7415
7416 /* Check for hit with different page size */
7417 mask = slice_range_to_mask(addr, len);
7418 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7419 * return with success:
7420 */
7421 vma = find_vma(mm, addr);
7422 - if (!vma || (addr + len) <= vma->vm_start) {
7423 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7424 /* remember the address as a hint for next time */
7425 if (use_cache)
7426 mm->free_area_cache = addr;
7427 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7428 mm->cached_hole_size = vma->vm_start - addr;
7429
7430 /* try just below the current vma->vm_start */
7431 - addr = vma->vm_start;
7432 + addr = skip_heap_stack_gap(vma, len, 0);
7433 }
7434
7435 /*
7436 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7437 if (fixed && addr > (mm->task_size - len))
7438 return -EINVAL;
7439
7440 +#ifdef CONFIG_PAX_RANDMMAP
7441 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7442 + addr = 0;
7443 +#endif
7444 +
7445 /* If hint, make sure it matches our alignment restrictions */
7446 if (!fixed && addr) {
7447 addr = _ALIGN_UP(addr, 1ul << pshift);
7448 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7449 index 0cfece4..2f1a0e5 100644
7450 --- a/arch/powerpc/platforms/cell/spufs/file.c
7451 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7452 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7453 return VM_FAULT_NOPAGE;
7454 }
7455
7456 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7457 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7458 unsigned long address,
7459 - void *buf, int len, int write)
7460 + void *buf, size_t len, int write)
7461 {
7462 struct spu_context *ctx = vma->vm_file->private_data;
7463 unsigned long offset = address - vma->vm_start;
7464 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7465 index bdb738a..49c9f95 100644
7466 --- a/arch/powerpc/platforms/powermac/smp.c
7467 +++ b/arch/powerpc/platforms/powermac/smp.c
7468 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7469 return NOTIFY_OK;
7470 }
7471
7472 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7473 +static struct notifier_block smp_core99_cpu_nb = {
7474 .notifier_call = smp_core99_cpu_notify,
7475 };
7476 #endif /* CONFIG_HOTPLUG_CPU */
7477 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7478 index c797832..ce575c8 100644
7479 --- a/arch/s390/include/asm/atomic.h
7480 +++ b/arch/s390/include/asm/atomic.h
7481 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7482 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7483 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7484
7485 +#define atomic64_read_unchecked(v) atomic64_read(v)
7486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7494 +
7495 #define smp_mb__before_atomic_dec() smp_mb()
7496 #define smp_mb__after_atomic_dec() smp_mb()
7497 #define smp_mb__before_atomic_inc() smp_mb()
7498 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7499 index 4d7ccac..d03d0ad 100644
7500 --- a/arch/s390/include/asm/cache.h
7501 +++ b/arch/s390/include/asm/cache.h
7502 @@ -9,8 +9,10 @@
7503 #ifndef __ARCH_S390_CACHE_H
7504 #define __ARCH_S390_CACHE_H
7505
7506 -#define L1_CACHE_BYTES 256
7507 +#include <linux/const.h>
7508 +
7509 #define L1_CACHE_SHIFT 8
7510 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7511 #define NET_SKB_PAD 32
7512
7513 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7514 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7515 index 178ff96..8c93bd1 100644
7516 --- a/arch/s390/include/asm/elf.h
7517 +++ b/arch/s390/include/asm/elf.h
7518 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7519 the loader. We need to make sure that it is out of the way of the program
7520 that it will "exec", and that there is sufficient room for the brk. */
7521
7522 -extern unsigned long randomize_et_dyn(unsigned long base);
7523 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7524 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7525 +
7526 +#ifdef CONFIG_PAX_ASLR
7527 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7528 +
7529 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7530 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7531 +#endif
7532
7533 /* This yields a mask that user programs can use to figure out what
7534 instruction set this CPU supports. */
7535 @@ -210,9 +216,6 @@ struct linux_binprm;
7536 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7537 int arch_setup_additional_pages(struct linux_binprm *, int);
7538
7539 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7540 -#define arch_randomize_brk arch_randomize_brk
7541 -
7542 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7543
7544 #endif
7545 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7546 index c4a93d6..4d2a9b4 100644
7547 --- a/arch/s390/include/asm/exec.h
7548 +++ b/arch/s390/include/asm/exec.h
7549 @@ -7,6 +7,6 @@
7550 #ifndef __ASM_EXEC_H
7551 #define __ASM_EXEC_H
7552
7553 -extern unsigned long arch_align_stack(unsigned long sp);
7554 +#define arch_align_stack(x) ((x) & ~0xfUL)
7555
7556 #endif /* __ASM_EXEC_H */
7557 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7558 index 34268df..ea97318 100644
7559 --- a/arch/s390/include/asm/uaccess.h
7560 +++ b/arch/s390/include/asm/uaccess.h
7561 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7562 copy_to_user(void __user *to, const void *from, unsigned long n)
7563 {
7564 might_fault();
7565 +
7566 + if ((long)n < 0)
7567 + return n;
7568 +
7569 if (access_ok(VERIFY_WRITE, to, n))
7570 n = __copy_to_user(to, from, n);
7571 return n;
7572 @@ -277,6 +281,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7573 static inline unsigned long __must_check
7574 __copy_from_user(void *to, const void __user *from, unsigned long n)
7575 {
7576 + if ((long)n < 0)
7577 + return n;
7578 +
7579 if (__builtin_constant_p(n) && (n <= 256))
7580 return uaccess.copy_from_user_small(n, from, to);
7581 else
7582 @@ -308,10 +315,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7583 static inline unsigned long __must_check
7584 copy_from_user(void *to, const void __user *from, unsigned long n)
7585 {
7586 - unsigned int sz = __compiletime_object_size(to);
7587 + size_t sz = __compiletime_object_size(to);
7588
7589 might_fault();
7590 - if (unlikely(sz != -1 && sz < n)) {
7591 +
7592 + if ((long)n < 0)
7593 + return n;
7594 +
7595 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7596 copy_from_user_overflow();
7597 return n;
7598 }
7599 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7600 index 4610dea..cf0af21 100644
7601 --- a/arch/s390/kernel/module.c
7602 +++ b/arch/s390/kernel/module.c
7603 @@ -171,11 +171,11 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7604
7605 /* Increase core size by size of got & plt and set start
7606 offsets for got and plt. */
7607 - me->core_size = ALIGN(me->core_size, 4);
7608 - me->arch.got_offset = me->core_size;
7609 - me->core_size += me->arch.got_size;
7610 - me->arch.plt_offset = me->core_size;
7611 - me->core_size += me->arch.plt_size;
7612 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7613 + me->arch.got_offset = me->core_size_rw;
7614 + me->core_size_rw += me->arch.got_size;
7615 + me->arch.plt_offset = me->core_size_rx;
7616 + me->core_size_rx += me->arch.plt_size;
7617 return 0;
7618 }
7619
7620 @@ -252,7 +252,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7621 if (info->got_initialized == 0) {
7622 Elf_Addr *gotent;
7623
7624 - gotent = me->module_core + me->arch.got_offset +
7625 + gotent = me->module_core_rw + me->arch.got_offset +
7626 info->got_offset;
7627 *gotent = val;
7628 info->got_initialized = 1;
7629 @@ -276,7 +276,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7630 else if (r_type == R_390_GOTENT ||
7631 r_type == R_390_GOTPLTENT)
7632 *(unsigned int *) loc =
7633 - (val + (Elf_Addr) me->module_core - loc) >> 1;
7634 + (val + (Elf_Addr) me->module_core_rw - loc) >> 1;
7635 else if (r_type == R_390_GOT64 ||
7636 r_type == R_390_GOTPLT64)
7637 *(unsigned long *) loc = val;
7638 @@ -290,7 +290,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7639 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7640 if (info->plt_initialized == 0) {
7641 unsigned int *ip;
7642 - ip = me->module_core + me->arch.plt_offset +
7643 + ip = me->module_core_rx + me->arch.plt_offset +
7644 info->plt_offset;
7645 #ifndef CONFIG_64BIT
7646 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7647 @@ -315,7 +315,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7648 val - loc + 0xffffUL < 0x1ffffeUL) ||
7649 (r_type == R_390_PLT32DBL &&
7650 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7651 - val = (Elf_Addr) me->module_core +
7652 + val = (Elf_Addr) me->module_core_rx +
7653 me->arch.plt_offset +
7654 info->plt_offset;
7655 val += rela->r_addend - loc;
7656 @@ -337,7 +337,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7657 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7658 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7659 val = val + rela->r_addend -
7660 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7661 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7662 if (r_type == R_390_GOTOFF16)
7663 *(unsigned short *) loc = val;
7664 else if (r_type == R_390_GOTOFF32)
7665 @@ -347,7 +347,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7666 break;
7667 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7668 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7669 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7670 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7671 rela->r_addend - loc;
7672 if (r_type == R_390_GOTPC)
7673 *(unsigned int *) loc = val;
7674 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7675 index 536d645..4a5bd9e 100644
7676 --- a/arch/s390/kernel/process.c
7677 +++ b/arch/s390/kernel/process.c
7678 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7679 }
7680 return 0;
7681 }
7682 -
7683 -unsigned long arch_align_stack(unsigned long sp)
7684 -{
7685 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7686 - sp -= get_random_int() & ~PAGE_MASK;
7687 - return sp & ~0xf;
7688 -}
7689 -
7690 -static inline unsigned long brk_rnd(void)
7691 -{
7692 - /* 8MB for 32bit, 1GB for 64bit */
7693 - if (is_32bit_task())
7694 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7695 - else
7696 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7697 -}
7698 -
7699 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7700 -{
7701 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7702 -
7703 - if (ret < mm->brk)
7704 - return mm->brk;
7705 - return ret;
7706 -}
7707 -
7708 -unsigned long randomize_et_dyn(unsigned long base)
7709 -{
7710 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7711 -
7712 - if (!(current->flags & PF_RANDOMIZE))
7713 - return base;
7714 - if (ret < base)
7715 - return base;
7716 - return ret;
7717 -}
7718 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7719 index c59a5ef..3fae59c 100644
7720 --- a/arch/s390/mm/mmap.c
7721 +++ b/arch/s390/mm/mmap.c
7722 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7723 */
7724 if (mmap_is_legacy()) {
7725 mm->mmap_base = TASK_UNMAPPED_BASE;
7726 +
7727 +#ifdef CONFIG_PAX_RANDMMAP
7728 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7729 + mm->mmap_base += mm->delta_mmap;
7730 +#endif
7731 +
7732 mm->get_unmapped_area = arch_get_unmapped_area;
7733 mm->unmap_area = arch_unmap_area;
7734 } else {
7735 mm->mmap_base = mmap_base();
7736 +
7737 +#ifdef CONFIG_PAX_RANDMMAP
7738 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7739 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7740 +#endif
7741 +
7742 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7743 mm->unmap_area = arch_unmap_area_topdown;
7744 }
7745 @@ -172,10 +184,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7746 */
7747 if (mmap_is_legacy()) {
7748 mm->mmap_base = TASK_UNMAPPED_BASE;
7749 +
7750 +#ifdef CONFIG_PAX_RANDMMAP
7751 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7752 + mm->mmap_base += mm->delta_mmap;
7753 +#endif
7754 +
7755 mm->get_unmapped_area = s390_get_unmapped_area;
7756 mm->unmap_area = arch_unmap_area;
7757 } else {
7758 mm->mmap_base = mmap_base();
7759 +
7760 +#ifdef CONFIG_PAX_RANDMMAP
7761 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7762 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7763 +#endif
7764 +
7765 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7766 mm->unmap_area = arch_unmap_area_topdown;
7767 }
7768 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7769 index ae3d59f..f65f075 100644
7770 --- a/arch/score/include/asm/cache.h
7771 +++ b/arch/score/include/asm/cache.h
7772 @@ -1,7 +1,9 @@
7773 #ifndef _ASM_SCORE_CACHE_H
7774 #define _ASM_SCORE_CACHE_H
7775
7776 +#include <linux/const.h>
7777 +
7778 #define L1_CACHE_SHIFT 4
7779 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7780 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7781
7782 #endif /* _ASM_SCORE_CACHE_H */
7783 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7784 index f9f3cd5..58ff438 100644
7785 --- a/arch/score/include/asm/exec.h
7786 +++ b/arch/score/include/asm/exec.h
7787 @@ -1,6 +1,6 @@
7788 #ifndef _ASM_SCORE_EXEC_H
7789 #define _ASM_SCORE_EXEC_H
7790
7791 -extern unsigned long arch_align_stack(unsigned long sp);
7792 +#define arch_align_stack(x) (x)
7793
7794 #endif /* _ASM_SCORE_EXEC_H */
7795 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7796 index 7956846..5f37677 100644
7797 --- a/arch/score/kernel/process.c
7798 +++ b/arch/score/kernel/process.c
7799 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7800
7801 return task_pt_regs(task)->cp0_epc;
7802 }
7803 -
7804 -unsigned long arch_align_stack(unsigned long sp)
7805 -{
7806 - return sp;
7807 -}
7808 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7809 index ef9e555..331bd29 100644
7810 --- a/arch/sh/include/asm/cache.h
7811 +++ b/arch/sh/include/asm/cache.h
7812 @@ -9,10 +9,11 @@
7813 #define __ASM_SH_CACHE_H
7814 #ifdef __KERNEL__
7815
7816 +#include <linux/const.h>
7817 #include <linux/init.h>
7818 #include <cpu/cache.h>
7819
7820 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7821 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7822
7823 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7824
7825 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7826 index 03f2b55..b027032 100644
7827 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7828 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7829 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7830 return NOTIFY_OK;
7831 }
7832
7833 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7834 +static struct notifier_block shx3_cpu_notifier = {
7835 .notifier_call = shx3_cpu_callback,
7836 };
7837
7838 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7839 index 6777177..cb5e44f 100644
7840 --- a/arch/sh/mm/mmap.c
7841 +++ b/arch/sh/mm/mmap.c
7842 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7843 struct mm_struct *mm = current->mm;
7844 struct vm_area_struct *vma;
7845 int do_colour_align;
7846 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7847 struct vm_unmapped_area_info info;
7848
7849 if (flags & MAP_FIXED) {
7850 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7851 if (filp || (flags & MAP_SHARED))
7852 do_colour_align = 1;
7853
7854 +#ifdef CONFIG_PAX_RANDMMAP
7855 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7856 +#endif
7857 +
7858 if (addr) {
7859 if (do_colour_align)
7860 addr = COLOUR_ALIGN(addr, pgoff);
7861 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7862 addr = PAGE_ALIGN(addr);
7863
7864 vma = find_vma(mm, addr);
7865 - if (TASK_SIZE - len >= addr &&
7866 - (!vma || addr + len <= vma->vm_start))
7867 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7868 return addr;
7869 }
7870
7871 info.flags = 0;
7872 info.length = len;
7873 - info.low_limit = TASK_UNMAPPED_BASE;
7874 + info.low_limit = mm->mmap_base;
7875 info.high_limit = TASK_SIZE;
7876 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7877 info.align_offset = pgoff << PAGE_SHIFT;
7878 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7879 struct mm_struct *mm = current->mm;
7880 unsigned long addr = addr0;
7881 int do_colour_align;
7882 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7883 struct vm_unmapped_area_info info;
7884
7885 if (flags & MAP_FIXED) {
7886 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7887 if (filp || (flags & MAP_SHARED))
7888 do_colour_align = 1;
7889
7890 +#ifdef CONFIG_PAX_RANDMMAP
7891 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7892 +#endif
7893 +
7894 /* requesting a specific address */
7895 if (addr) {
7896 if (do_colour_align)
7897 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7898 addr = PAGE_ALIGN(addr);
7899
7900 vma = find_vma(mm, addr);
7901 - if (TASK_SIZE - len >= addr &&
7902 - (!vma || addr + len <= vma->vm_start))
7903 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7904 return addr;
7905 }
7906
7907 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7908 VM_BUG_ON(addr != -ENOMEM);
7909 info.flags = 0;
7910 info.low_limit = TASK_UNMAPPED_BASE;
7911 +
7912 +#ifdef CONFIG_PAX_RANDMMAP
7913 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7914 + info.low_limit += mm->delta_mmap;
7915 +#endif
7916 +
7917 info.high_limit = TASK_SIZE;
7918 addr = vm_unmapped_area(&info);
7919 }
7920 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7921 index be56a24..443328f 100644
7922 --- a/arch/sparc/include/asm/atomic_64.h
7923 +++ b/arch/sparc/include/asm/atomic_64.h
7924 @@ -14,18 +14,40 @@
7925 #define ATOMIC64_INIT(i) { (i) }
7926
7927 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7928 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7929 +{
7930 + return v->counter;
7931 +}
7932 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7933 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7934 +{
7935 + return v->counter;
7936 +}
7937
7938 #define atomic_set(v, i) (((v)->counter) = i)
7939 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7940 +{
7941 + v->counter = i;
7942 +}
7943 #define atomic64_set(v, i) (((v)->counter) = i)
7944 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7945 +{
7946 + v->counter = i;
7947 +}
7948
7949 extern void atomic_add(int, atomic_t *);
7950 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7951 extern void atomic64_add(long, atomic64_t *);
7952 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7953 extern void atomic_sub(int, atomic_t *);
7954 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7955 extern void atomic64_sub(long, atomic64_t *);
7956 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7957
7958 extern int atomic_add_ret(int, atomic_t *);
7959 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7960 extern long atomic64_add_ret(long, atomic64_t *);
7961 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7962 extern int atomic_sub_ret(int, atomic_t *);
7963 extern long atomic64_sub_ret(long, atomic64_t *);
7964
7965 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7966 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7967
7968 #define atomic_inc_return(v) atomic_add_ret(1, v)
7969 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7970 +{
7971 + return atomic_add_ret_unchecked(1, v);
7972 +}
7973 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7974 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7975 +{
7976 + return atomic64_add_ret_unchecked(1, v);
7977 +}
7978
7979 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7980 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7981
7982 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7983 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7984 +{
7985 + return atomic_add_ret_unchecked(i, v);
7986 +}
7987 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7988 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7989 +{
7990 + return atomic64_add_ret_unchecked(i, v);
7991 +}
7992
7993 /*
7994 * atomic_inc_and_test - increment and test
7995 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7996 * other cases.
7997 */
7998 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7999 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8000 +{
8001 + return atomic_inc_return_unchecked(v) == 0;
8002 +}
8003 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8004
8005 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8006 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8007 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8008
8009 #define atomic_inc(v) atomic_add(1, v)
8010 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8011 +{
8012 + atomic_add_unchecked(1, v);
8013 +}
8014 #define atomic64_inc(v) atomic64_add(1, v)
8015 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8016 +{
8017 + atomic64_add_unchecked(1, v);
8018 +}
8019
8020 #define atomic_dec(v) atomic_sub(1, v)
8021 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8022 +{
8023 + atomic_sub_unchecked(1, v);
8024 +}
8025 #define atomic64_dec(v) atomic64_sub(1, v)
8026 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8027 +{
8028 + atomic64_sub_unchecked(1, v);
8029 +}
8030
8031 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8032 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8033
8034 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8035 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8036 +{
8037 + return cmpxchg(&v->counter, old, new);
8038 +}
8039 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8040 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8041 +{
8042 + return xchg(&v->counter, new);
8043 +}
8044
8045 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8046 {
8047 - int c, old;
8048 + int c, old, new;
8049 c = atomic_read(v);
8050 for (;;) {
8051 - if (unlikely(c == (u)))
8052 + if (unlikely(c == u))
8053 break;
8054 - old = atomic_cmpxchg((v), c, c + (a));
8055 +
8056 + asm volatile("addcc %2, %0, %0\n"
8057 +
8058 +#ifdef CONFIG_PAX_REFCOUNT
8059 + "tvs %%icc, 6\n"
8060 +#endif
8061 +
8062 + : "=r" (new)
8063 + : "0" (c), "ir" (a)
8064 + : "cc");
8065 +
8066 + old = atomic_cmpxchg(v, c, new);
8067 if (likely(old == c))
8068 break;
8069 c = old;
8070 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8071 #define atomic64_cmpxchg(v, o, n) \
8072 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8073 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8074 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8075 +{
8076 + return xchg(&v->counter, new);
8077 +}
8078
8079 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8080 {
8081 - long c, old;
8082 + long c, old, new;
8083 c = atomic64_read(v);
8084 for (;;) {
8085 - if (unlikely(c == (u)))
8086 + if (unlikely(c == u))
8087 break;
8088 - old = atomic64_cmpxchg((v), c, c + (a));
8089 +
8090 + asm volatile("addcc %2, %0, %0\n"
8091 +
8092 +#ifdef CONFIG_PAX_REFCOUNT
8093 + "tvs %%xcc, 6\n"
8094 +#endif
8095 +
8096 + : "=r" (new)
8097 + : "0" (c), "ir" (a)
8098 + : "cc");
8099 +
8100 + old = atomic64_cmpxchg(v, c, new);
8101 if (likely(old == c))
8102 break;
8103 c = old;
8104 }
8105 - return c != (u);
8106 + return c != u;
8107 }
8108
8109 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8110 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
8111 index 5bb6991..5c2132e 100644
8112 --- a/arch/sparc/include/asm/cache.h
8113 +++ b/arch/sparc/include/asm/cache.h
8114 @@ -7,10 +7,12 @@
8115 #ifndef _SPARC_CACHE_H
8116 #define _SPARC_CACHE_H
8117
8118 +#include <linux/const.h>
8119 +
8120 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
8121
8122 #define L1_CACHE_SHIFT 5
8123 -#define L1_CACHE_BYTES 32
8124 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8125
8126 #ifdef CONFIG_SPARC32
8127 #define SMP_CACHE_BYTES_SHIFT 5
8128 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
8129 index ac74a2c..a9e58af 100644
8130 --- a/arch/sparc/include/asm/elf_32.h
8131 +++ b/arch/sparc/include/asm/elf_32.h
8132 @@ -114,6 +114,13 @@ typedef struct {
8133
8134 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
8135
8136 +#ifdef CONFIG_PAX_ASLR
8137 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
8138 +
8139 +#define PAX_DELTA_MMAP_LEN 16
8140 +#define PAX_DELTA_STACK_LEN 16
8141 +#endif
8142 +
8143 /* This yields a mask that user programs can use to figure out what
8144 instruction set this cpu supports. This can NOT be done in userspace
8145 on Sparc. */
8146 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
8147 index 370ca1e..d4f4a98 100644
8148 --- a/arch/sparc/include/asm/elf_64.h
8149 +++ b/arch/sparc/include/asm/elf_64.h
8150 @@ -189,6 +189,13 @@ typedef struct {
8151 #define ELF_ET_DYN_BASE 0x0000010000000000UL
8152 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
8153
8154 +#ifdef CONFIG_PAX_ASLR
8155 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
8156 +
8157 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
8158 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
8159 +#endif
8160 +
8161 extern unsigned long sparc64_elf_hwcap;
8162 #define ELF_HWCAP sparc64_elf_hwcap
8163
8164 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
8165 index 9b1c36d..209298b 100644
8166 --- a/arch/sparc/include/asm/pgalloc_32.h
8167 +++ b/arch/sparc/include/asm/pgalloc_32.h
8168 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
8169 }
8170
8171 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
8172 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
8173
8174 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
8175 unsigned long address)
8176 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
8177 index bcfe063..b333142 100644
8178 --- a/arch/sparc/include/asm/pgalloc_64.h
8179 +++ b/arch/sparc/include/asm/pgalloc_64.h
8180 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8181 }
8182
8183 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
8184 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
8185
8186 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
8187 {
8188 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
8189 index 6fc1348..390c50a 100644
8190 --- a/arch/sparc/include/asm/pgtable_32.h
8191 +++ b/arch/sparc/include/asm/pgtable_32.h
8192 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
8193 #define PAGE_SHARED SRMMU_PAGE_SHARED
8194 #define PAGE_COPY SRMMU_PAGE_COPY
8195 #define PAGE_READONLY SRMMU_PAGE_RDONLY
8196 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
8197 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
8198 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
8199 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
8200
8201 /* Top-level page directory - dummy used by init-mm.
8202 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
8203
8204 /* xwr */
8205 #define __P000 PAGE_NONE
8206 -#define __P001 PAGE_READONLY
8207 -#define __P010 PAGE_COPY
8208 -#define __P011 PAGE_COPY
8209 +#define __P001 PAGE_READONLY_NOEXEC
8210 +#define __P010 PAGE_COPY_NOEXEC
8211 +#define __P011 PAGE_COPY_NOEXEC
8212 #define __P100 PAGE_READONLY
8213 #define __P101 PAGE_READONLY
8214 #define __P110 PAGE_COPY
8215 #define __P111 PAGE_COPY
8216
8217 #define __S000 PAGE_NONE
8218 -#define __S001 PAGE_READONLY
8219 -#define __S010 PAGE_SHARED
8220 -#define __S011 PAGE_SHARED
8221 +#define __S001 PAGE_READONLY_NOEXEC
8222 +#define __S010 PAGE_SHARED_NOEXEC
8223 +#define __S011 PAGE_SHARED_NOEXEC
8224 #define __S100 PAGE_READONLY
8225 #define __S101 PAGE_READONLY
8226 #define __S110 PAGE_SHARED
8227 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
8228 index 79da178..c2eede8 100644
8229 --- a/arch/sparc/include/asm/pgtsrmmu.h
8230 +++ b/arch/sparc/include/asm/pgtsrmmu.h
8231 @@ -115,6 +115,11 @@
8232 SRMMU_EXEC | SRMMU_REF)
8233 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
8234 SRMMU_EXEC | SRMMU_REF)
8235 +
8236 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
8237 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8238 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8239 +
8240 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
8241 SRMMU_DIRTY | SRMMU_REF)
8242
8243 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
8244 index 9689176..63c18ea 100644
8245 --- a/arch/sparc/include/asm/spinlock_64.h
8246 +++ b/arch/sparc/include/asm/spinlock_64.h
8247 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8248
8249 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8250
8251 -static void inline arch_read_lock(arch_rwlock_t *lock)
8252 +static inline void arch_read_lock(arch_rwlock_t *lock)
8253 {
8254 unsigned long tmp1, tmp2;
8255
8256 __asm__ __volatile__ (
8257 "1: ldsw [%2], %0\n"
8258 " brlz,pn %0, 2f\n"
8259 -"4: add %0, 1, %1\n"
8260 +"4: addcc %0, 1, %1\n"
8261 +
8262 +#ifdef CONFIG_PAX_REFCOUNT
8263 +" tvs %%icc, 6\n"
8264 +#endif
8265 +
8266 " cas [%2], %0, %1\n"
8267 " cmp %0, %1\n"
8268 " bne,pn %%icc, 1b\n"
8269 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8270 " .previous"
8271 : "=&r" (tmp1), "=&r" (tmp2)
8272 : "r" (lock)
8273 - : "memory");
8274 + : "memory", "cc");
8275 }
8276
8277 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8278 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8279 {
8280 int tmp1, tmp2;
8281
8282 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8283 "1: ldsw [%2], %0\n"
8284 " brlz,a,pn %0, 2f\n"
8285 " mov 0, %0\n"
8286 -" add %0, 1, %1\n"
8287 +" addcc %0, 1, %1\n"
8288 +
8289 +#ifdef CONFIG_PAX_REFCOUNT
8290 +" tvs %%icc, 6\n"
8291 +#endif
8292 +
8293 " cas [%2], %0, %1\n"
8294 " cmp %0, %1\n"
8295 " bne,pn %%icc, 1b\n"
8296 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8297 return tmp1;
8298 }
8299
8300 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8301 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8302 {
8303 unsigned long tmp1, tmp2;
8304
8305 __asm__ __volatile__(
8306 "1: lduw [%2], %0\n"
8307 -" sub %0, 1, %1\n"
8308 +" subcc %0, 1, %1\n"
8309 +
8310 +#ifdef CONFIG_PAX_REFCOUNT
8311 +" tvs %%icc, 6\n"
8312 +#endif
8313 +
8314 " cas [%2], %0, %1\n"
8315 " cmp %0, %1\n"
8316 " bne,pn %%xcc, 1b\n"
8317 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8318 : "memory");
8319 }
8320
8321 -static void inline arch_write_lock(arch_rwlock_t *lock)
8322 +static inline void arch_write_lock(arch_rwlock_t *lock)
8323 {
8324 unsigned long mask, tmp1, tmp2;
8325
8326 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8327 : "memory");
8328 }
8329
8330 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8331 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8332 {
8333 __asm__ __volatile__(
8334 " stw %%g0, [%0]"
8335 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8336 : "memory");
8337 }
8338
8339 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8340 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8341 {
8342 unsigned long mask, tmp1, tmp2, result;
8343
8344 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8345 index 25849ae..924c54b 100644
8346 --- a/arch/sparc/include/asm/thread_info_32.h
8347 +++ b/arch/sparc/include/asm/thread_info_32.h
8348 @@ -49,6 +49,8 @@ struct thread_info {
8349 unsigned long w_saved;
8350
8351 struct restart_block restart_block;
8352 +
8353 + unsigned long lowest_stack;
8354 };
8355
8356 /*
8357 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8358 index 269bd92..e46a9b8 100644
8359 --- a/arch/sparc/include/asm/thread_info_64.h
8360 +++ b/arch/sparc/include/asm/thread_info_64.h
8361 @@ -63,6 +63,8 @@ struct thread_info {
8362 struct pt_regs *kern_una_regs;
8363 unsigned int kern_una_insn;
8364
8365 + unsigned long lowest_stack;
8366 +
8367 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8368 };
8369
8370 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8371 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8372 /* flag bit 6 is available */
8373 #define TIF_32BIT 7 /* 32-bit binary */
8374 -/* flag bit 8 is available */
8375 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8376 #define TIF_SECCOMP 9 /* secure computing */
8377 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8378 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8379 +
8380 /* NOTE: Thread flags >= 12 should be ones we have no interest
8381 * in using in assembly, else we can't use the mask as
8382 * an immediate value in instructions such as andcc.
8383 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8384 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8385 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8386 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8387 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8388
8389 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8390 _TIF_DO_NOTIFY_RESUME_MASK | \
8391 _TIF_NEED_RESCHED)
8392 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8393
8394 +#define _TIF_WORK_SYSCALL \
8395 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8396 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8397 +
8398 +
8399 /*
8400 * Thread-synchronous status.
8401 *
8402 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8403 index 0167d26..767bb0c 100644
8404 --- a/arch/sparc/include/asm/uaccess.h
8405 +++ b/arch/sparc/include/asm/uaccess.h
8406 @@ -1,5 +1,6 @@
8407 #ifndef ___ASM_SPARC_UACCESS_H
8408 #define ___ASM_SPARC_UACCESS_H
8409 +
8410 #if defined(__sparc__) && defined(__arch64__)
8411 #include <asm/uaccess_64.h>
8412 #else
8413 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8414 index 53a28dd..50c38c3 100644
8415 --- a/arch/sparc/include/asm/uaccess_32.h
8416 +++ b/arch/sparc/include/asm/uaccess_32.h
8417 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8418
8419 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8420 {
8421 - if (n && __access_ok((unsigned long) to, n))
8422 + if ((long)n < 0)
8423 + return n;
8424 +
8425 + if (n && __access_ok((unsigned long) to, n)) {
8426 + if (!__builtin_constant_p(n))
8427 + check_object_size(from, n, true);
8428 return __copy_user(to, (__force void __user *) from, n);
8429 - else
8430 + } else
8431 return n;
8432 }
8433
8434 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8435 {
8436 + if ((long)n < 0)
8437 + return n;
8438 +
8439 + if (!__builtin_constant_p(n))
8440 + check_object_size(from, n, true);
8441 +
8442 return __copy_user(to, (__force void __user *) from, n);
8443 }
8444
8445 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8446 {
8447 - if (n && __access_ok((unsigned long) from, n))
8448 + if ((long)n < 0)
8449 + return n;
8450 +
8451 + if (n && __access_ok((unsigned long) from, n)) {
8452 + if (!__builtin_constant_p(n))
8453 + check_object_size(to, n, false);
8454 return __copy_user((__force void __user *) to, from, n);
8455 - else
8456 + } else
8457 return n;
8458 }
8459
8460 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8461 {
8462 + if ((long)n < 0)
8463 + return n;
8464 +
8465 return __copy_user((__force void __user *) to, from, n);
8466 }
8467
8468 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8469 index e562d3c..191f176 100644
8470 --- a/arch/sparc/include/asm/uaccess_64.h
8471 +++ b/arch/sparc/include/asm/uaccess_64.h
8472 @@ -10,6 +10,7 @@
8473 #include <linux/compiler.h>
8474 #include <linux/string.h>
8475 #include <linux/thread_info.h>
8476 +#include <linux/kernel.h>
8477 #include <asm/asi.h>
8478 #include <asm/spitfire.h>
8479 #include <asm-generic/uaccess-unaligned.h>
8480 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8481 static inline unsigned long __must_check
8482 copy_from_user(void *to, const void __user *from, unsigned long size)
8483 {
8484 - unsigned long ret = ___copy_from_user(to, from, size);
8485 + unsigned long ret;
8486
8487 + if ((long)size < 0 || size > INT_MAX)
8488 + return size;
8489 +
8490 + if (!__builtin_constant_p(size))
8491 + check_object_size(to, size, false);
8492 +
8493 + ret = ___copy_from_user(to, from, size);
8494 if (unlikely(ret))
8495 ret = copy_from_user_fixup(to, from, size);
8496
8497 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8498 static inline unsigned long __must_check
8499 copy_to_user(void __user *to, const void *from, unsigned long size)
8500 {
8501 - unsigned long ret = ___copy_to_user(to, from, size);
8502 + unsigned long ret;
8503
8504 + if ((long)size < 0 || size > INT_MAX)
8505 + return size;
8506 +
8507 + if (!__builtin_constant_p(size))
8508 + check_object_size(from, size, true);
8509 +
8510 + ret = ___copy_to_user(to, from, size);
8511 if (unlikely(ret))
8512 ret = copy_to_user_fixup(to, from, size);
8513 return ret;
8514 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8515 index 6cf591b..b49e65a 100644
8516 --- a/arch/sparc/kernel/Makefile
8517 +++ b/arch/sparc/kernel/Makefile
8518 @@ -3,7 +3,7 @@
8519 #
8520
8521 asflags-y := -ansi
8522 -ccflags-y := -Werror
8523 +#ccflags-y := -Werror
8524
8525 extra-y := head_$(BITS).o
8526
8527 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8528 index be8e862..5b50b12 100644
8529 --- a/arch/sparc/kernel/process_32.c
8530 +++ b/arch/sparc/kernel/process_32.c
8531 @@ -126,14 +126,14 @@ void show_regs(struct pt_regs *r)
8532
8533 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8534 r->psr, r->pc, r->npc, r->y, print_tainted());
8535 - printk("PC: <%pS>\n", (void *) r->pc);
8536 + printk("PC: <%pA>\n", (void *) r->pc);
8537 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8538 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8539 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8540 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8541 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8542 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8543 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8544 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8545
8546 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8547 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8548 @@ -168,7 +168,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8549 rw = (struct reg_window32 *) fp;
8550 pc = rw->ins[7];
8551 printk("[%08lx : ", pc);
8552 - printk("%pS ] ", (void *) pc);
8553 + printk("%pA ] ", (void *) pc);
8554 fp = rw->ins[6];
8555 } while (++count < 16);
8556 printk("\n");
8557 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8558 index cdb80b2..5ca141d 100644
8559 --- a/arch/sparc/kernel/process_64.c
8560 +++ b/arch/sparc/kernel/process_64.c
8561 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8562 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8563 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8564 if (regs->tstate & TSTATE_PRIV)
8565 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8566 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8567 }
8568
8569 void show_regs(struct pt_regs *regs)
8570 {
8571 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8572 regs->tpc, regs->tnpc, regs->y, print_tainted());
8573 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8574 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8575 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8576 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8577 regs->u_regs[3]);
8578 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8579 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8580 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8581 regs->u_regs[15]);
8582 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8583 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8584 show_regwindow(regs);
8585 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8586 }
8587 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8588 ((tp && tp->task) ? tp->task->pid : -1));
8589
8590 if (gp->tstate & TSTATE_PRIV) {
8591 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8592 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8593 (void *) gp->tpc,
8594 (void *) gp->o7,
8595 (void *) gp->i7,
8596 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8597 index 1303021..c2a6321 100644
8598 --- a/arch/sparc/kernel/prom_common.c
8599 +++ b/arch/sparc/kernel/prom_common.c
8600 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8601
8602 unsigned int prom_early_allocated __initdata;
8603
8604 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8605 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8606 .nextprop = prom_common_nextprop,
8607 .getproplen = prom_getproplen,
8608 .getproperty = prom_getproperty,
8609 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8610 index 7ff45e4..a58f271 100644
8611 --- a/arch/sparc/kernel/ptrace_64.c
8612 +++ b/arch/sparc/kernel/ptrace_64.c
8613 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8614 return ret;
8615 }
8616
8617 +#ifdef CONFIG_GRKERNSEC_SETXID
8618 +extern void gr_delayed_cred_worker(void);
8619 +#endif
8620 +
8621 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8622 {
8623 int ret = 0;
8624 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8625 /* do the secure computing check first */
8626 secure_computing_strict(regs->u_regs[UREG_G1]);
8627
8628 +#ifdef CONFIG_GRKERNSEC_SETXID
8629 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8630 + gr_delayed_cred_worker();
8631 +#endif
8632 +
8633 if (test_thread_flag(TIF_SYSCALL_TRACE))
8634 ret = tracehook_report_syscall_entry(regs);
8635
8636 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8637
8638 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8639 {
8640 +#ifdef CONFIG_GRKERNSEC_SETXID
8641 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8642 + gr_delayed_cred_worker();
8643 +#endif
8644 +
8645 audit_syscall_exit(regs);
8646
8647 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8648 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8649 index 2da0bdc..79128d2 100644
8650 --- a/arch/sparc/kernel/sys_sparc_32.c
8651 +++ b/arch/sparc/kernel/sys_sparc_32.c
8652 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8653 if (len > TASK_SIZE - PAGE_SIZE)
8654 return -ENOMEM;
8655 if (!addr)
8656 - addr = TASK_UNMAPPED_BASE;
8657 + addr = current->mm->mmap_base;
8658
8659 info.flags = 0;
8660 info.length = len;
8661 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8662 index 708bc29..f0129cb 100644
8663 --- a/arch/sparc/kernel/sys_sparc_64.c
8664 +++ b/arch/sparc/kernel/sys_sparc_64.c
8665 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8666 struct vm_area_struct * vma;
8667 unsigned long task_size = TASK_SIZE;
8668 int do_color_align;
8669 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8670 struct vm_unmapped_area_info info;
8671
8672 if (flags & MAP_FIXED) {
8673 /* We do not accept a shared mapping if it would violate
8674 * cache aliasing constraints.
8675 */
8676 - if ((flags & MAP_SHARED) &&
8677 + if ((filp || (flags & MAP_SHARED)) &&
8678 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8679 return -EINVAL;
8680 return addr;
8681 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8682 if (filp || (flags & MAP_SHARED))
8683 do_color_align = 1;
8684
8685 +#ifdef CONFIG_PAX_RANDMMAP
8686 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8687 +#endif
8688 +
8689 if (addr) {
8690 if (do_color_align)
8691 addr = COLOR_ALIGN(addr, pgoff);
8692 @@ -118,14 +123,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8693 addr = PAGE_ALIGN(addr);
8694
8695 vma = find_vma(mm, addr);
8696 - if (task_size - len >= addr &&
8697 - (!vma || addr + len <= vma->vm_start))
8698 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8699 return addr;
8700 }
8701
8702 info.flags = 0;
8703 info.length = len;
8704 - info.low_limit = TASK_UNMAPPED_BASE;
8705 + info.low_limit = mm->mmap_base;
8706 info.high_limit = min(task_size, VA_EXCLUDE_START);
8707 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8708 info.align_offset = pgoff << PAGE_SHIFT;
8709 @@ -134,6 +138,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8710 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8711 VM_BUG_ON(addr != -ENOMEM);
8712 info.low_limit = VA_EXCLUDE_END;
8713 +
8714 +#ifdef CONFIG_PAX_RANDMMAP
8715 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8716 + info.low_limit += mm->delta_mmap;
8717 +#endif
8718 +
8719 info.high_limit = task_size;
8720 addr = vm_unmapped_area(&info);
8721 }
8722 @@ -151,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8723 unsigned long task_size = STACK_TOP32;
8724 unsigned long addr = addr0;
8725 int do_color_align;
8726 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8727 struct vm_unmapped_area_info info;
8728
8729 /* This should only ever run for 32-bit processes. */
8730 @@ -160,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8731 /* We do not accept a shared mapping if it would violate
8732 * cache aliasing constraints.
8733 */
8734 - if ((flags & MAP_SHARED) &&
8735 + if ((filp || (flags & MAP_SHARED)) &&
8736 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8737 return -EINVAL;
8738 return addr;
8739 @@ -173,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8740 if (filp || (flags & MAP_SHARED))
8741 do_color_align = 1;
8742
8743 +#ifdef CONFIG_PAX_RANDMMAP
8744 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8745 +#endif
8746 +
8747 /* requesting a specific address */
8748 if (addr) {
8749 if (do_color_align)
8750 @@ -181,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8751 addr = PAGE_ALIGN(addr);
8752
8753 vma = find_vma(mm, addr);
8754 - if (task_size - len >= addr &&
8755 - (!vma || addr + len <= vma->vm_start))
8756 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8757 return addr;
8758 }
8759
8760 @@ -204,6 +218,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8761 VM_BUG_ON(addr != -ENOMEM);
8762 info.flags = 0;
8763 info.low_limit = TASK_UNMAPPED_BASE;
8764 +
8765 +#ifdef CONFIG_PAX_RANDMMAP
8766 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8767 + info.low_limit += mm->delta_mmap;
8768 +#endif
8769 +
8770 info.high_limit = STACK_TOP32;
8771 addr = vm_unmapped_area(&info);
8772 }
8773 @@ -264,6 +284,10 @@ static unsigned long mmap_rnd(void)
8774 {
8775 unsigned long rnd = 0UL;
8776
8777 +#ifdef CONFIG_PAX_RANDMMAP
8778 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8779 +#endif
8780 +
8781 if (current->flags & PF_RANDOMIZE) {
8782 unsigned long val = get_random_int();
8783 if (test_thread_flag(TIF_32BIT))
8784 @@ -289,6 +313,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8785 gap == RLIM_INFINITY ||
8786 sysctl_legacy_va_layout) {
8787 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8788 +
8789 +#ifdef CONFIG_PAX_RANDMMAP
8790 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8791 + mm->mmap_base += mm->delta_mmap;
8792 +#endif
8793 +
8794 mm->get_unmapped_area = arch_get_unmapped_area;
8795 mm->unmap_area = arch_unmap_area;
8796 } else {
8797 @@ -301,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8798 gap = (task_size / 6 * 5);
8799
8800 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8801 +
8802 +#ifdef CONFIG_PAX_RANDMMAP
8803 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8804 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8805 +#endif
8806 +
8807 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8808 mm->unmap_area = arch_unmap_area_topdown;
8809 }
8810 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8811 index e0fed77..604a7e5 100644
8812 --- a/arch/sparc/kernel/syscalls.S
8813 +++ b/arch/sparc/kernel/syscalls.S
8814 @@ -58,7 +58,7 @@ sys32_rt_sigreturn:
8815 #endif
8816 .align 32
8817 1: ldx [%g6 + TI_FLAGS], %l5
8818 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8819 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8820 be,pt %icc, rtrap
8821 nop
8822 call syscall_trace_leave
8823 @@ -190,7 +190,7 @@ linux_sparc_syscall32:
8824
8825 srl %i5, 0, %o5 ! IEU1
8826 srl %i2, 0, %o2 ! IEU0 Group
8827 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8828 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8829 bne,pn %icc, linux_syscall_trace32 ! CTI
8830 mov %i0, %l5 ! IEU1
8831 call %l7 ! CTI Group brk forced
8832 @@ -213,7 +213,7 @@ linux_sparc_syscall:
8833
8834 mov %i3, %o3 ! IEU1
8835 mov %i4, %o4 ! IEU0 Group
8836 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8837 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8838 bne,pn %icc, linux_syscall_trace ! CTI Group
8839 mov %i0, %l5 ! IEU0
8840 2: call %l7 ! CTI Group brk forced
8841 @@ -229,7 +229,7 @@ ret_sys_call:
8842
8843 cmp %o0, -ERESTART_RESTARTBLOCK
8844 bgeu,pn %xcc, 1f
8845 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8846 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8847 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8848
8849 2:
8850 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8851 index 654e8aa..45f431b 100644
8852 --- a/arch/sparc/kernel/sysfs.c
8853 +++ b/arch/sparc/kernel/sysfs.c
8854 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8855 return NOTIFY_OK;
8856 }
8857
8858 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8859 +static struct notifier_block sysfs_cpu_nb = {
8860 .notifier_call = sysfs_cpu_notify,
8861 };
8862
8863 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8864 index a5785ea..405c5f7 100644
8865 --- a/arch/sparc/kernel/traps_32.c
8866 +++ b/arch/sparc/kernel/traps_32.c
8867 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8868 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8869 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8870
8871 +extern void gr_handle_kernel_exploit(void);
8872 +
8873 void die_if_kernel(char *str, struct pt_regs *regs)
8874 {
8875 static int die_counter;
8876 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8877 count++ < 30 &&
8878 (((unsigned long) rw) >= PAGE_OFFSET) &&
8879 !(((unsigned long) rw) & 0x7)) {
8880 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8881 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8882 (void *) rw->ins[7]);
8883 rw = (struct reg_window32 *)rw->ins[6];
8884 }
8885 }
8886 printk("Instruction DUMP:");
8887 instruction_dump ((unsigned long *) regs->pc);
8888 - if(regs->psr & PSR_PS)
8889 + if(regs->psr & PSR_PS) {
8890 + gr_handle_kernel_exploit();
8891 do_exit(SIGKILL);
8892 + }
8893 do_exit(SIGSEGV);
8894 }
8895
8896 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8897 index e7ecf15..6520e65 100644
8898 --- a/arch/sparc/kernel/traps_64.c
8899 +++ b/arch/sparc/kernel/traps_64.c
8900 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8901 i + 1,
8902 p->trapstack[i].tstate, p->trapstack[i].tpc,
8903 p->trapstack[i].tnpc, p->trapstack[i].tt);
8904 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8905 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8906 }
8907 }
8908
8909 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8910
8911 lvl -= 0x100;
8912 if (regs->tstate & TSTATE_PRIV) {
8913 +
8914 +#ifdef CONFIG_PAX_REFCOUNT
8915 + if (lvl == 6)
8916 + pax_report_refcount_overflow(regs);
8917 +#endif
8918 +
8919 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8920 die_if_kernel(buffer, regs);
8921 }
8922 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8923 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8924 {
8925 char buffer[32];
8926 -
8927 +
8928 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8929 0, lvl, SIGTRAP) == NOTIFY_STOP)
8930 return;
8931
8932 +#ifdef CONFIG_PAX_REFCOUNT
8933 + if (lvl == 6)
8934 + pax_report_refcount_overflow(regs);
8935 +#endif
8936 +
8937 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8938
8939 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8940 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8941 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8942 printk("%s" "ERROR(%d): ",
8943 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8944 - printk("TPC<%pS>\n", (void *) regs->tpc);
8945 + printk("TPC<%pA>\n", (void *) regs->tpc);
8946 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8947 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8948 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8949 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8950 smp_processor_id(),
8951 (type & 0x1) ? 'I' : 'D',
8952 regs->tpc);
8953 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8954 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8955 panic("Irrecoverable Cheetah+ parity error.");
8956 }
8957
8958 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8959 smp_processor_id(),
8960 (type & 0x1) ? 'I' : 'D',
8961 regs->tpc);
8962 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8963 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8964 }
8965
8966 struct sun4v_error_entry {
8967 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8968
8969 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8970 regs->tpc, tl);
8971 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8972 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8973 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8974 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8975 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8976 (void *) regs->u_regs[UREG_I7]);
8977 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8978 "pte[%lx] error[%lx]\n",
8979 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8980
8981 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8982 regs->tpc, tl);
8983 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8984 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8985 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8986 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8987 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8988 (void *) regs->u_regs[UREG_I7]);
8989 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8990 "pte[%lx] error[%lx]\n",
8991 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8992 fp = (unsigned long)sf->fp + STACK_BIAS;
8993 }
8994
8995 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8996 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8997 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8998 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8999 int index = tsk->curr_ret_stack;
9000 if (tsk->ret_stack && index >= graph) {
9001 pc = tsk->ret_stack[index - graph].ret;
9002 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9003 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9004 graph++;
9005 }
9006 }
9007 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
9008 return (struct reg_window *) (fp + STACK_BIAS);
9009 }
9010
9011 +extern void gr_handle_kernel_exploit(void);
9012 +
9013 void die_if_kernel(char *str, struct pt_regs *regs)
9014 {
9015 static int die_counter;
9016 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9017 while (rw &&
9018 count++ < 30 &&
9019 kstack_valid(tp, (unsigned long) rw)) {
9020 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
9021 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
9022 (void *) rw->ins[7]);
9023
9024 rw = kernel_stack_up(rw);
9025 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9026 }
9027 user_instruction_dump ((unsigned int __user *) regs->tpc);
9028 }
9029 - if (regs->tstate & TSTATE_PRIV)
9030 + if (regs->tstate & TSTATE_PRIV) {
9031 + gr_handle_kernel_exploit();
9032 do_exit(SIGKILL);
9033 + }
9034 do_exit(SIGSEGV);
9035 }
9036 EXPORT_SYMBOL(die_if_kernel);
9037 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
9038 index 8201c25e..072a2a7 100644
9039 --- a/arch/sparc/kernel/unaligned_64.c
9040 +++ b/arch/sparc/kernel/unaligned_64.c
9041 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
9042 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
9043
9044 if (__ratelimit(&ratelimit)) {
9045 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
9046 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
9047 regs->tpc, (void *) regs->tpc);
9048 }
9049 }
9050 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
9051 index eb1624b..f9f4ddb 100644
9052 --- a/arch/sparc/kernel/us3_cpufreq.c
9053 +++ b/arch/sparc/kernel/us3_cpufreq.c
9054 @@ -18,14 +18,12 @@
9055 #include <asm/head.h>
9056 #include <asm/timer.h>
9057
9058 -static struct cpufreq_driver *cpufreq_us3_driver;
9059 -
9060 struct us3_freq_percpu_info {
9061 struct cpufreq_frequency_table table[4];
9062 };
9063
9064 /* Indexed by cpu number. */
9065 -static struct us3_freq_percpu_info *us3_freq_table;
9066 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
9067
9068 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
9069 * in the Safari config register.
9070 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
9071
9072 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
9073 {
9074 - if (cpufreq_us3_driver)
9075 - us3_set_cpu_divider_index(policy->cpu, 0);
9076 + us3_set_cpu_divider_index(policy->cpu, 0);
9077
9078 return 0;
9079 }
9080
9081 +static int __init us3_freq_init(void);
9082 +static void __exit us3_freq_exit(void);
9083 +
9084 +static struct cpufreq_driver cpufreq_us3_driver = {
9085 + .init = us3_freq_cpu_init,
9086 + .verify = us3_freq_verify,
9087 + .target = us3_freq_target,
9088 + .get = us3_freq_get,
9089 + .exit = us3_freq_cpu_exit,
9090 + .owner = THIS_MODULE,
9091 + .name = "UltraSPARC-III",
9092 +
9093 +};
9094 +
9095 static int __init us3_freq_init(void)
9096 {
9097 unsigned long manuf, impl, ver;
9098 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
9099 (impl == CHEETAH_IMPL ||
9100 impl == CHEETAH_PLUS_IMPL ||
9101 impl == JAGUAR_IMPL ||
9102 - impl == PANTHER_IMPL)) {
9103 - struct cpufreq_driver *driver;
9104 -
9105 - ret = -ENOMEM;
9106 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
9107 - if (!driver)
9108 - goto err_out;
9109 -
9110 - us3_freq_table = kzalloc(
9111 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
9112 - GFP_KERNEL);
9113 - if (!us3_freq_table)
9114 - goto err_out;
9115 -
9116 - driver->init = us3_freq_cpu_init;
9117 - driver->verify = us3_freq_verify;
9118 - driver->target = us3_freq_target;
9119 - driver->get = us3_freq_get;
9120 - driver->exit = us3_freq_cpu_exit;
9121 - driver->owner = THIS_MODULE,
9122 - strcpy(driver->name, "UltraSPARC-III");
9123 -
9124 - cpufreq_us3_driver = driver;
9125 - ret = cpufreq_register_driver(driver);
9126 - if (ret)
9127 - goto err_out;
9128 -
9129 - return 0;
9130 -
9131 -err_out:
9132 - if (driver) {
9133 - kfree(driver);
9134 - cpufreq_us3_driver = NULL;
9135 - }
9136 - kfree(us3_freq_table);
9137 - us3_freq_table = NULL;
9138 - return ret;
9139 - }
9140 + impl == PANTHER_IMPL))
9141 + return cpufreq_register_driver(cpufreq_us3_driver);
9142
9143 return -ENODEV;
9144 }
9145
9146 static void __exit us3_freq_exit(void)
9147 {
9148 - if (cpufreq_us3_driver) {
9149 - cpufreq_unregister_driver(cpufreq_us3_driver);
9150 - kfree(cpufreq_us3_driver);
9151 - cpufreq_us3_driver = NULL;
9152 - kfree(us3_freq_table);
9153 - us3_freq_table = NULL;
9154 - }
9155 + cpufreq_unregister_driver(cpufreq_us3_driver);
9156 }
9157
9158 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
9159 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
9160 index 8410065f2..4fd4ca22 100644
9161 --- a/arch/sparc/lib/Makefile
9162 +++ b/arch/sparc/lib/Makefile
9163 @@ -2,7 +2,7 @@
9164 #
9165
9166 asflags-y := -ansi -DST_DIV0=0x02
9167 -ccflags-y := -Werror
9168 +#ccflags-y := -Werror
9169
9170 lib-$(CONFIG_SPARC32) += ashrdi3.o
9171 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
9172 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
9173 index 85c233d..68500e0 100644
9174 --- a/arch/sparc/lib/atomic_64.S
9175 +++ b/arch/sparc/lib/atomic_64.S
9176 @@ -17,7 +17,12 @@
9177 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9178 BACKOFF_SETUP(%o2)
9179 1: lduw [%o1], %g1
9180 - add %g1, %o0, %g7
9181 + addcc %g1, %o0, %g7
9182 +
9183 +#ifdef CONFIG_PAX_REFCOUNT
9184 + tvs %icc, 6
9185 +#endif
9186 +
9187 cas [%o1], %g1, %g7
9188 cmp %g1, %g7
9189 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9190 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9191 2: BACKOFF_SPIN(%o2, %o3, 1b)
9192 ENDPROC(atomic_add)
9193
9194 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9195 + BACKOFF_SETUP(%o2)
9196 +1: lduw [%o1], %g1
9197 + add %g1, %o0, %g7
9198 + cas [%o1], %g1, %g7
9199 + cmp %g1, %g7
9200 + bne,pn %icc, 2f
9201 + nop
9202 + retl
9203 + nop
9204 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9205 +ENDPROC(atomic_add_unchecked)
9206 +
9207 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9208 BACKOFF_SETUP(%o2)
9209 1: lduw [%o1], %g1
9210 - sub %g1, %o0, %g7
9211 + subcc %g1, %o0, %g7
9212 +
9213 +#ifdef CONFIG_PAX_REFCOUNT
9214 + tvs %icc, 6
9215 +#endif
9216 +
9217 cas [%o1], %g1, %g7
9218 cmp %g1, %g7
9219 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9220 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9221 2: BACKOFF_SPIN(%o2, %o3, 1b)
9222 ENDPROC(atomic_sub)
9223
9224 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9225 + BACKOFF_SETUP(%o2)
9226 +1: lduw [%o1], %g1
9227 + sub %g1, %o0, %g7
9228 + cas [%o1], %g1, %g7
9229 + cmp %g1, %g7
9230 + bne,pn %icc, 2f
9231 + nop
9232 + retl
9233 + nop
9234 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9235 +ENDPROC(atomic_sub_unchecked)
9236 +
9237 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9238 BACKOFF_SETUP(%o2)
9239 1: lduw [%o1], %g1
9240 - add %g1, %o0, %g7
9241 + addcc %g1, %o0, %g7
9242 +
9243 +#ifdef CONFIG_PAX_REFCOUNT
9244 + tvs %icc, 6
9245 +#endif
9246 +
9247 cas [%o1], %g1, %g7
9248 cmp %g1, %g7
9249 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9250 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9251 2: BACKOFF_SPIN(%o2, %o3, 1b)
9252 ENDPROC(atomic_add_ret)
9253
9254 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9255 + BACKOFF_SETUP(%o2)
9256 +1: lduw [%o1], %g1
9257 + addcc %g1, %o0, %g7
9258 + cas [%o1], %g1, %g7
9259 + cmp %g1, %g7
9260 + bne,pn %icc, 2f
9261 + add %g7, %o0, %g7
9262 + sra %g7, 0, %o0
9263 + retl
9264 + nop
9265 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9266 +ENDPROC(atomic_add_ret_unchecked)
9267 +
9268 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9269 BACKOFF_SETUP(%o2)
9270 1: lduw [%o1], %g1
9271 - sub %g1, %o0, %g7
9272 + subcc %g1, %o0, %g7
9273 +
9274 +#ifdef CONFIG_PAX_REFCOUNT
9275 + tvs %icc, 6
9276 +#endif
9277 +
9278 cas [%o1], %g1, %g7
9279 cmp %g1, %g7
9280 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9281 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
9282 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9283 BACKOFF_SETUP(%o2)
9284 1: ldx [%o1], %g1
9285 - add %g1, %o0, %g7
9286 + addcc %g1, %o0, %g7
9287 +
9288 +#ifdef CONFIG_PAX_REFCOUNT
9289 + tvs %xcc, 6
9290 +#endif
9291 +
9292 casx [%o1], %g1, %g7
9293 cmp %g1, %g7
9294 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9295 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9296 2: BACKOFF_SPIN(%o2, %o3, 1b)
9297 ENDPROC(atomic64_add)
9298
9299 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9300 + BACKOFF_SETUP(%o2)
9301 +1: ldx [%o1], %g1
9302 + addcc %g1, %o0, %g7
9303 + casx [%o1], %g1, %g7
9304 + cmp %g1, %g7
9305 + bne,pn %xcc, 2f
9306 + nop
9307 + retl
9308 + nop
9309 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9310 +ENDPROC(atomic64_add_unchecked)
9311 +
9312 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9313 BACKOFF_SETUP(%o2)
9314 1: ldx [%o1], %g1
9315 - sub %g1, %o0, %g7
9316 + subcc %g1, %o0, %g7
9317 +
9318 +#ifdef CONFIG_PAX_REFCOUNT
9319 + tvs %xcc, 6
9320 +#endif
9321 +
9322 casx [%o1], %g1, %g7
9323 cmp %g1, %g7
9324 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9325 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9326 2: BACKOFF_SPIN(%o2, %o3, 1b)
9327 ENDPROC(atomic64_sub)
9328
9329 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9330 + BACKOFF_SETUP(%o2)
9331 +1: ldx [%o1], %g1
9332 + subcc %g1, %o0, %g7
9333 + casx [%o1], %g1, %g7
9334 + cmp %g1, %g7
9335 + bne,pn %xcc, 2f
9336 + nop
9337 + retl
9338 + nop
9339 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9340 +ENDPROC(atomic64_sub_unchecked)
9341 +
9342 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9343 BACKOFF_SETUP(%o2)
9344 1: ldx [%o1], %g1
9345 - add %g1, %o0, %g7
9346 + addcc %g1, %o0, %g7
9347 +
9348 +#ifdef CONFIG_PAX_REFCOUNT
9349 + tvs %xcc, 6
9350 +#endif
9351 +
9352 casx [%o1], %g1, %g7
9353 cmp %g1, %g7
9354 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9355 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9356 2: BACKOFF_SPIN(%o2, %o3, 1b)
9357 ENDPROC(atomic64_add_ret)
9358
9359 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9360 + BACKOFF_SETUP(%o2)
9361 +1: ldx [%o1], %g1
9362 + addcc %g1, %o0, %g7
9363 + casx [%o1], %g1, %g7
9364 + cmp %g1, %g7
9365 + bne,pn %xcc, 2f
9366 + add %g7, %o0, %g7
9367 + mov %g7, %o0
9368 + retl
9369 + nop
9370 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9371 +ENDPROC(atomic64_add_ret_unchecked)
9372 +
9373 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9374 BACKOFF_SETUP(%o2)
9375 1: ldx [%o1], %g1
9376 - sub %g1, %o0, %g7
9377 + subcc %g1, %o0, %g7
9378 +
9379 +#ifdef CONFIG_PAX_REFCOUNT
9380 + tvs %xcc, 6
9381 +#endif
9382 +
9383 casx [%o1], %g1, %g7
9384 cmp %g1, %g7
9385 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9386 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9387 index 0c4e35e..745d3e4 100644
9388 --- a/arch/sparc/lib/ksyms.c
9389 +++ b/arch/sparc/lib/ksyms.c
9390 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9391
9392 /* Atomic counter implementation. */
9393 EXPORT_SYMBOL(atomic_add);
9394 +EXPORT_SYMBOL(atomic_add_unchecked);
9395 EXPORT_SYMBOL(atomic_add_ret);
9396 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9397 EXPORT_SYMBOL(atomic_sub);
9398 +EXPORT_SYMBOL(atomic_sub_unchecked);
9399 EXPORT_SYMBOL(atomic_sub_ret);
9400 EXPORT_SYMBOL(atomic64_add);
9401 +EXPORT_SYMBOL(atomic64_add_unchecked);
9402 EXPORT_SYMBOL(atomic64_add_ret);
9403 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9404 EXPORT_SYMBOL(atomic64_sub);
9405 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9406 EXPORT_SYMBOL(atomic64_sub_ret);
9407 EXPORT_SYMBOL(atomic64_dec_if_positive);
9408
9409 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9410 index 30c3ecc..736f015 100644
9411 --- a/arch/sparc/mm/Makefile
9412 +++ b/arch/sparc/mm/Makefile
9413 @@ -2,7 +2,7 @@
9414 #
9415
9416 asflags-y := -ansi
9417 -ccflags-y := -Werror
9418 +#ccflags-y := -Werror
9419
9420 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9421 obj-y += fault_$(BITS).o
9422 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9423 index e98bfda..ea8d221 100644
9424 --- a/arch/sparc/mm/fault_32.c
9425 +++ b/arch/sparc/mm/fault_32.c
9426 @@ -21,6 +21,9 @@
9427 #include <linux/perf_event.h>
9428 #include <linux/interrupt.h>
9429 #include <linux/kdebug.h>
9430 +#include <linux/slab.h>
9431 +#include <linux/pagemap.h>
9432 +#include <linux/compiler.h>
9433
9434 #include <asm/page.h>
9435 #include <asm/pgtable.h>
9436 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9437 return safe_compute_effective_address(regs, insn);
9438 }
9439
9440 +#ifdef CONFIG_PAX_PAGEEXEC
9441 +#ifdef CONFIG_PAX_DLRESOLVE
9442 +static void pax_emuplt_close(struct vm_area_struct *vma)
9443 +{
9444 + vma->vm_mm->call_dl_resolve = 0UL;
9445 +}
9446 +
9447 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9448 +{
9449 + unsigned int *kaddr;
9450 +
9451 + vmf->page = alloc_page(GFP_HIGHUSER);
9452 + if (!vmf->page)
9453 + return VM_FAULT_OOM;
9454 +
9455 + kaddr = kmap(vmf->page);
9456 + memset(kaddr, 0, PAGE_SIZE);
9457 + kaddr[0] = 0x9DE3BFA8U; /* save */
9458 + flush_dcache_page(vmf->page);
9459 + kunmap(vmf->page);
9460 + return VM_FAULT_MAJOR;
9461 +}
9462 +
9463 +static const struct vm_operations_struct pax_vm_ops = {
9464 + .close = pax_emuplt_close,
9465 + .fault = pax_emuplt_fault
9466 +};
9467 +
9468 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9469 +{
9470 + int ret;
9471 +
9472 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9473 + vma->vm_mm = current->mm;
9474 + vma->vm_start = addr;
9475 + vma->vm_end = addr + PAGE_SIZE;
9476 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9477 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9478 + vma->vm_ops = &pax_vm_ops;
9479 +
9480 + ret = insert_vm_struct(current->mm, vma);
9481 + if (ret)
9482 + return ret;
9483 +
9484 + ++current->mm->total_vm;
9485 + return 0;
9486 +}
9487 +#endif
9488 +
9489 +/*
9490 + * PaX: decide what to do with offenders (regs->pc = fault address)
9491 + *
9492 + * returns 1 when task should be killed
9493 + * 2 when patched PLT trampoline was detected
9494 + * 3 when unpatched PLT trampoline was detected
9495 + */
9496 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9497 +{
9498 +
9499 +#ifdef CONFIG_PAX_EMUPLT
9500 + int err;
9501 +
9502 + do { /* PaX: patched PLT emulation #1 */
9503 + unsigned int sethi1, sethi2, jmpl;
9504 +
9505 + err = get_user(sethi1, (unsigned int *)regs->pc);
9506 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9507 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9508 +
9509 + if (err)
9510 + break;
9511 +
9512 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9513 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9514 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9515 + {
9516 + unsigned int addr;
9517 +
9518 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9519 + addr = regs->u_regs[UREG_G1];
9520 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9521 + regs->pc = addr;
9522 + regs->npc = addr+4;
9523 + return 2;
9524 + }
9525 + } while (0);
9526 +
9527 + do { /* PaX: patched PLT emulation #2 */
9528 + unsigned int ba;
9529 +
9530 + err = get_user(ba, (unsigned int *)regs->pc);
9531 +
9532 + if (err)
9533 + break;
9534 +
9535 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9536 + unsigned int addr;
9537 +
9538 + if ((ba & 0xFFC00000U) == 0x30800000U)
9539 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9540 + else
9541 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9542 + regs->pc = addr;
9543 + regs->npc = addr+4;
9544 + return 2;
9545 + }
9546 + } while (0);
9547 +
9548 + do { /* PaX: patched PLT emulation #3 */
9549 + unsigned int sethi, bajmpl, nop;
9550 +
9551 + err = get_user(sethi, (unsigned int *)regs->pc);
9552 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9553 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9554 +
9555 + if (err)
9556 + break;
9557 +
9558 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9559 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9560 + nop == 0x01000000U)
9561 + {
9562 + unsigned int addr;
9563 +
9564 + addr = (sethi & 0x003FFFFFU) << 10;
9565 + regs->u_regs[UREG_G1] = addr;
9566 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9567 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9568 + else
9569 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9570 + regs->pc = addr;
9571 + regs->npc = addr+4;
9572 + return 2;
9573 + }
9574 + } while (0);
9575 +
9576 + do { /* PaX: unpatched PLT emulation step 1 */
9577 + unsigned int sethi, ba, nop;
9578 +
9579 + err = get_user(sethi, (unsigned int *)regs->pc);
9580 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9581 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9582 +
9583 + if (err)
9584 + break;
9585 +
9586 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9587 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9588 + nop == 0x01000000U)
9589 + {
9590 + unsigned int addr, save, call;
9591 +
9592 + if ((ba & 0xFFC00000U) == 0x30800000U)
9593 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9594 + else
9595 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9596 +
9597 + err = get_user(save, (unsigned int *)addr);
9598 + err |= get_user(call, (unsigned int *)(addr+4));
9599 + err |= get_user(nop, (unsigned int *)(addr+8));
9600 + if (err)
9601 + break;
9602 +
9603 +#ifdef CONFIG_PAX_DLRESOLVE
9604 + if (save == 0x9DE3BFA8U &&
9605 + (call & 0xC0000000U) == 0x40000000U &&
9606 + nop == 0x01000000U)
9607 + {
9608 + struct vm_area_struct *vma;
9609 + unsigned long call_dl_resolve;
9610 +
9611 + down_read(&current->mm->mmap_sem);
9612 + call_dl_resolve = current->mm->call_dl_resolve;
9613 + up_read(&current->mm->mmap_sem);
9614 + if (likely(call_dl_resolve))
9615 + goto emulate;
9616 +
9617 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9618 +
9619 + down_write(&current->mm->mmap_sem);
9620 + if (current->mm->call_dl_resolve) {
9621 + call_dl_resolve = current->mm->call_dl_resolve;
9622 + up_write(&current->mm->mmap_sem);
9623 + if (vma)
9624 + kmem_cache_free(vm_area_cachep, vma);
9625 + goto emulate;
9626 + }
9627 +
9628 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9629 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9630 + up_write(&current->mm->mmap_sem);
9631 + if (vma)
9632 + kmem_cache_free(vm_area_cachep, vma);
9633 + return 1;
9634 + }
9635 +
9636 + if (pax_insert_vma(vma, call_dl_resolve)) {
9637 + up_write(&current->mm->mmap_sem);
9638 + kmem_cache_free(vm_area_cachep, vma);
9639 + return 1;
9640 + }
9641 +
9642 + current->mm->call_dl_resolve = call_dl_resolve;
9643 + up_write(&current->mm->mmap_sem);
9644 +
9645 +emulate:
9646 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9647 + regs->pc = call_dl_resolve;
9648 + regs->npc = addr+4;
9649 + return 3;
9650 + }
9651 +#endif
9652 +
9653 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9654 + if ((save & 0xFFC00000U) == 0x05000000U &&
9655 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9656 + nop == 0x01000000U)
9657 + {
9658 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9659 + regs->u_regs[UREG_G2] = addr + 4;
9660 + addr = (save & 0x003FFFFFU) << 10;
9661 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9662 + regs->pc = addr;
9663 + regs->npc = addr+4;
9664 + return 3;
9665 + }
9666 + }
9667 + } while (0);
9668 +
9669 + do { /* PaX: unpatched PLT emulation step 2 */
9670 + unsigned int save, call, nop;
9671 +
9672 + err = get_user(save, (unsigned int *)(regs->pc-4));
9673 + err |= get_user(call, (unsigned int *)regs->pc);
9674 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9675 + if (err)
9676 + break;
9677 +
9678 + if (save == 0x9DE3BFA8U &&
9679 + (call & 0xC0000000U) == 0x40000000U &&
9680 + nop == 0x01000000U)
9681 + {
9682 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9683 +
9684 + regs->u_regs[UREG_RETPC] = regs->pc;
9685 + regs->pc = dl_resolve;
9686 + regs->npc = dl_resolve+4;
9687 + return 3;
9688 + }
9689 + } while (0);
9690 +#endif
9691 +
9692 + return 1;
9693 +}
9694 +
9695 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9696 +{
9697 + unsigned long i;
9698 +
9699 + printk(KERN_ERR "PAX: bytes at PC: ");
9700 + for (i = 0; i < 8; i++) {
9701 + unsigned int c;
9702 + if (get_user(c, (unsigned int *)pc+i))
9703 + printk(KERN_CONT "???????? ");
9704 + else
9705 + printk(KERN_CONT "%08x ", c);
9706 + }
9707 + printk("\n");
9708 +}
9709 +#endif
9710 +
9711 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9712 int text_fault)
9713 {
9714 @@ -230,6 +504,24 @@ good_area:
9715 if (!(vma->vm_flags & VM_WRITE))
9716 goto bad_area;
9717 } else {
9718 +
9719 +#ifdef CONFIG_PAX_PAGEEXEC
9720 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9721 + up_read(&mm->mmap_sem);
9722 + switch (pax_handle_fetch_fault(regs)) {
9723 +
9724 +#ifdef CONFIG_PAX_EMUPLT
9725 + case 2:
9726 + case 3:
9727 + return;
9728 +#endif
9729 +
9730 + }
9731 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9732 + do_group_exit(SIGKILL);
9733 + }
9734 +#endif
9735 +
9736 /* Allow reads even for write-only mappings */
9737 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9738 goto bad_area;
9739 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9740 index 5062ff3..e0b75f3 100644
9741 --- a/arch/sparc/mm/fault_64.c
9742 +++ b/arch/sparc/mm/fault_64.c
9743 @@ -21,6 +21,9 @@
9744 #include <linux/kprobes.h>
9745 #include <linux/kdebug.h>
9746 #include <linux/percpu.h>
9747 +#include <linux/slab.h>
9748 +#include <linux/pagemap.h>
9749 +#include <linux/compiler.h>
9750
9751 #include <asm/page.h>
9752 #include <asm/pgtable.h>
9753 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9754 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9755 regs->tpc);
9756 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9757 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9758 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9759 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9760 dump_stack();
9761 unhandled_fault(regs->tpc, current, regs);
9762 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9763 show_regs(regs);
9764 }
9765
9766 +#ifdef CONFIG_PAX_PAGEEXEC
9767 +#ifdef CONFIG_PAX_DLRESOLVE
9768 +static void pax_emuplt_close(struct vm_area_struct *vma)
9769 +{
9770 + vma->vm_mm->call_dl_resolve = 0UL;
9771 +}
9772 +
9773 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9774 +{
9775 + unsigned int *kaddr;
9776 +
9777 + vmf->page = alloc_page(GFP_HIGHUSER);
9778 + if (!vmf->page)
9779 + return VM_FAULT_OOM;
9780 +
9781 + kaddr = kmap(vmf->page);
9782 + memset(kaddr, 0, PAGE_SIZE);
9783 + kaddr[0] = 0x9DE3BFA8U; /* save */
9784 + flush_dcache_page(vmf->page);
9785 + kunmap(vmf->page);
9786 + return VM_FAULT_MAJOR;
9787 +}
9788 +
9789 +static const struct vm_operations_struct pax_vm_ops = {
9790 + .close = pax_emuplt_close,
9791 + .fault = pax_emuplt_fault
9792 +};
9793 +
9794 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9795 +{
9796 + int ret;
9797 +
9798 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9799 + vma->vm_mm = current->mm;
9800 + vma->vm_start = addr;
9801 + vma->vm_end = addr + PAGE_SIZE;
9802 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9803 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9804 + vma->vm_ops = &pax_vm_ops;
9805 +
9806 + ret = insert_vm_struct(current->mm, vma);
9807 + if (ret)
9808 + return ret;
9809 +
9810 + ++current->mm->total_vm;
9811 + return 0;
9812 +}
9813 +#endif
9814 +
9815 +/*
9816 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9817 + *
9818 + * returns 1 when task should be killed
9819 + * 2 when patched PLT trampoline was detected
9820 + * 3 when unpatched PLT trampoline was detected
9821 + */
9822 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9823 +{
9824 +
9825 +#ifdef CONFIG_PAX_EMUPLT
9826 + int err;
9827 +
9828 + do { /* PaX: patched PLT emulation #1 */
9829 + unsigned int sethi1, sethi2, jmpl;
9830 +
9831 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9832 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9833 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9834 +
9835 + if (err)
9836 + break;
9837 +
9838 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9839 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9840 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9841 + {
9842 + unsigned long addr;
9843 +
9844 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9845 + addr = regs->u_regs[UREG_G1];
9846 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9847 +
9848 + if (test_thread_flag(TIF_32BIT))
9849 + addr &= 0xFFFFFFFFUL;
9850 +
9851 + regs->tpc = addr;
9852 + regs->tnpc = addr+4;
9853 + return 2;
9854 + }
9855 + } while (0);
9856 +
9857 + do { /* PaX: patched PLT emulation #2 */
9858 + unsigned int ba;
9859 +
9860 + err = get_user(ba, (unsigned int *)regs->tpc);
9861 +
9862 + if (err)
9863 + break;
9864 +
9865 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9866 + unsigned long addr;
9867 +
9868 + if ((ba & 0xFFC00000U) == 0x30800000U)
9869 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9870 + else
9871 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9872 +
9873 + if (test_thread_flag(TIF_32BIT))
9874 + addr &= 0xFFFFFFFFUL;
9875 +
9876 + regs->tpc = addr;
9877 + regs->tnpc = addr+4;
9878 + return 2;
9879 + }
9880 + } while (0);
9881 +
9882 + do { /* PaX: patched PLT emulation #3 */
9883 + unsigned int sethi, bajmpl, nop;
9884 +
9885 + err = get_user(sethi, (unsigned int *)regs->tpc);
9886 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9887 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9888 +
9889 + if (err)
9890 + break;
9891 +
9892 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9893 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9894 + nop == 0x01000000U)
9895 + {
9896 + unsigned long addr;
9897 +
9898 + addr = (sethi & 0x003FFFFFU) << 10;
9899 + regs->u_regs[UREG_G1] = addr;
9900 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9901 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9902 + else
9903 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9904 +
9905 + if (test_thread_flag(TIF_32BIT))
9906 + addr &= 0xFFFFFFFFUL;
9907 +
9908 + regs->tpc = addr;
9909 + regs->tnpc = addr+4;
9910 + return 2;
9911 + }
9912 + } while (0);
9913 +
9914 + do { /* PaX: patched PLT emulation #4 */
9915 + unsigned int sethi, mov1, call, mov2;
9916 +
9917 + err = get_user(sethi, (unsigned int *)regs->tpc);
9918 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9919 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9920 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9921 +
9922 + if (err)
9923 + break;
9924 +
9925 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9926 + mov1 == 0x8210000FU &&
9927 + (call & 0xC0000000U) == 0x40000000U &&
9928 + mov2 == 0x9E100001U)
9929 + {
9930 + unsigned long addr;
9931 +
9932 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9933 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9934 +
9935 + if (test_thread_flag(TIF_32BIT))
9936 + addr &= 0xFFFFFFFFUL;
9937 +
9938 + regs->tpc = addr;
9939 + regs->tnpc = addr+4;
9940 + return 2;
9941 + }
9942 + } while (0);
9943 +
9944 + do { /* PaX: patched PLT emulation #5 */
9945 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9946 +
9947 + err = get_user(sethi, (unsigned int *)regs->tpc);
9948 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9949 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9950 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9951 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9952 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9953 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9954 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9955 +
9956 + if (err)
9957 + break;
9958 +
9959 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9960 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9961 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9962 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9963 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9964 + sllx == 0x83287020U &&
9965 + jmpl == 0x81C04005U &&
9966 + nop == 0x01000000U)
9967 + {
9968 + unsigned long addr;
9969 +
9970 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9971 + regs->u_regs[UREG_G1] <<= 32;
9972 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9973 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9974 + regs->tpc = addr;
9975 + regs->tnpc = addr+4;
9976 + return 2;
9977 + }
9978 + } while (0);
9979 +
9980 + do { /* PaX: patched PLT emulation #6 */
9981 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9982 +
9983 + err = get_user(sethi, (unsigned int *)regs->tpc);
9984 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9985 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9986 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9987 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9988 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9989 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9990 +
9991 + if (err)
9992 + break;
9993 +
9994 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9995 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9996 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9997 + sllx == 0x83287020U &&
9998 + (or & 0xFFFFE000U) == 0x8A116000U &&
9999 + jmpl == 0x81C04005U &&
10000 + nop == 0x01000000U)
10001 + {
10002 + unsigned long addr;
10003 +
10004 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10005 + regs->u_regs[UREG_G1] <<= 32;
10006 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10007 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10008 + regs->tpc = addr;
10009 + regs->tnpc = addr+4;
10010 + return 2;
10011 + }
10012 + } while (0);
10013 +
10014 + do { /* PaX: unpatched PLT emulation step 1 */
10015 + unsigned int sethi, ba, nop;
10016 +
10017 + err = get_user(sethi, (unsigned int *)regs->tpc);
10018 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10019 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10020 +
10021 + if (err)
10022 + break;
10023 +
10024 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10025 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10026 + nop == 0x01000000U)
10027 + {
10028 + unsigned long addr;
10029 + unsigned int save, call;
10030 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10031 +
10032 + if ((ba & 0xFFC00000U) == 0x30800000U)
10033 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10034 + else
10035 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10036 +
10037 + if (test_thread_flag(TIF_32BIT))
10038 + addr &= 0xFFFFFFFFUL;
10039 +
10040 + err = get_user(save, (unsigned int *)addr);
10041 + err |= get_user(call, (unsigned int *)(addr+4));
10042 + err |= get_user(nop, (unsigned int *)(addr+8));
10043 + if (err)
10044 + break;
10045 +
10046 +#ifdef CONFIG_PAX_DLRESOLVE
10047 + if (save == 0x9DE3BFA8U &&
10048 + (call & 0xC0000000U) == 0x40000000U &&
10049 + nop == 0x01000000U)
10050 + {
10051 + struct vm_area_struct *vma;
10052 + unsigned long call_dl_resolve;
10053 +
10054 + down_read(&current->mm->mmap_sem);
10055 + call_dl_resolve = current->mm->call_dl_resolve;
10056 + up_read(&current->mm->mmap_sem);
10057 + if (likely(call_dl_resolve))
10058 + goto emulate;
10059 +
10060 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10061 +
10062 + down_write(&current->mm->mmap_sem);
10063 + if (current->mm->call_dl_resolve) {
10064 + call_dl_resolve = current->mm->call_dl_resolve;
10065 + up_write(&current->mm->mmap_sem);
10066 + if (vma)
10067 + kmem_cache_free(vm_area_cachep, vma);
10068 + goto emulate;
10069 + }
10070 +
10071 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10072 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10073 + up_write(&current->mm->mmap_sem);
10074 + if (vma)
10075 + kmem_cache_free(vm_area_cachep, vma);
10076 + return 1;
10077 + }
10078 +
10079 + if (pax_insert_vma(vma, call_dl_resolve)) {
10080 + up_write(&current->mm->mmap_sem);
10081 + kmem_cache_free(vm_area_cachep, vma);
10082 + return 1;
10083 + }
10084 +
10085 + current->mm->call_dl_resolve = call_dl_resolve;
10086 + up_write(&current->mm->mmap_sem);
10087 +
10088 +emulate:
10089 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10090 + regs->tpc = call_dl_resolve;
10091 + regs->tnpc = addr+4;
10092 + return 3;
10093 + }
10094 +#endif
10095 +
10096 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10097 + if ((save & 0xFFC00000U) == 0x05000000U &&
10098 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10099 + nop == 0x01000000U)
10100 + {
10101 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10102 + regs->u_regs[UREG_G2] = addr + 4;
10103 + addr = (save & 0x003FFFFFU) << 10;
10104 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10105 +
10106 + if (test_thread_flag(TIF_32BIT))
10107 + addr &= 0xFFFFFFFFUL;
10108 +
10109 + regs->tpc = addr;
10110 + regs->tnpc = addr+4;
10111 + return 3;
10112 + }
10113 +
10114 + /* PaX: 64-bit PLT stub */
10115 + err = get_user(sethi1, (unsigned int *)addr);
10116 + err |= get_user(sethi2, (unsigned int *)(addr+4));
10117 + err |= get_user(or1, (unsigned int *)(addr+8));
10118 + err |= get_user(or2, (unsigned int *)(addr+12));
10119 + err |= get_user(sllx, (unsigned int *)(addr+16));
10120 + err |= get_user(add, (unsigned int *)(addr+20));
10121 + err |= get_user(jmpl, (unsigned int *)(addr+24));
10122 + err |= get_user(nop, (unsigned int *)(addr+28));
10123 + if (err)
10124 + break;
10125 +
10126 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
10127 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10128 + (or1 & 0xFFFFE000U) == 0x88112000U &&
10129 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10130 + sllx == 0x89293020U &&
10131 + add == 0x8A010005U &&
10132 + jmpl == 0x89C14000U &&
10133 + nop == 0x01000000U)
10134 + {
10135 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10136 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10137 + regs->u_regs[UREG_G4] <<= 32;
10138 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10139 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
10140 + regs->u_regs[UREG_G4] = addr + 24;
10141 + addr = regs->u_regs[UREG_G5];
10142 + regs->tpc = addr;
10143 + regs->tnpc = addr+4;
10144 + return 3;
10145 + }
10146 + }
10147 + } while (0);
10148 +
10149 +#ifdef CONFIG_PAX_DLRESOLVE
10150 + do { /* PaX: unpatched PLT emulation step 2 */
10151 + unsigned int save, call, nop;
10152 +
10153 + err = get_user(save, (unsigned int *)(regs->tpc-4));
10154 + err |= get_user(call, (unsigned int *)regs->tpc);
10155 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
10156 + if (err)
10157 + break;
10158 +
10159 + if (save == 0x9DE3BFA8U &&
10160 + (call & 0xC0000000U) == 0x40000000U &&
10161 + nop == 0x01000000U)
10162 + {
10163 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10164 +
10165 + if (test_thread_flag(TIF_32BIT))
10166 + dl_resolve &= 0xFFFFFFFFUL;
10167 +
10168 + regs->u_regs[UREG_RETPC] = regs->tpc;
10169 + regs->tpc = dl_resolve;
10170 + regs->tnpc = dl_resolve+4;
10171 + return 3;
10172 + }
10173 + } while (0);
10174 +#endif
10175 +
10176 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
10177 + unsigned int sethi, ba, nop;
10178 +
10179 + err = get_user(sethi, (unsigned int *)regs->tpc);
10180 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10181 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10182 +
10183 + if (err)
10184 + break;
10185 +
10186 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10187 + (ba & 0xFFF00000U) == 0x30600000U &&
10188 + nop == 0x01000000U)
10189 + {
10190 + unsigned long addr;
10191 +
10192 + addr = (sethi & 0x003FFFFFU) << 10;
10193 + regs->u_regs[UREG_G1] = addr;
10194 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10195 +
10196 + if (test_thread_flag(TIF_32BIT))
10197 + addr &= 0xFFFFFFFFUL;
10198 +
10199 + regs->tpc = addr;
10200 + regs->tnpc = addr+4;
10201 + return 2;
10202 + }
10203 + } while (0);
10204 +
10205 +#endif
10206 +
10207 + return 1;
10208 +}
10209 +
10210 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10211 +{
10212 + unsigned long i;
10213 +
10214 + printk(KERN_ERR "PAX: bytes at PC: ");
10215 + for (i = 0; i < 8; i++) {
10216 + unsigned int c;
10217 + if (get_user(c, (unsigned int *)pc+i))
10218 + printk(KERN_CONT "???????? ");
10219 + else
10220 + printk(KERN_CONT "%08x ", c);
10221 + }
10222 + printk("\n");
10223 +}
10224 +#endif
10225 +
10226 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
10227 {
10228 struct mm_struct *mm = current->mm;
10229 @@ -341,6 +804,29 @@ retry:
10230 if (!vma)
10231 goto bad_area;
10232
10233 +#ifdef CONFIG_PAX_PAGEEXEC
10234 + /* PaX: detect ITLB misses on non-exec pages */
10235 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
10236 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
10237 + {
10238 + if (address != regs->tpc)
10239 + goto good_area;
10240 +
10241 + up_read(&mm->mmap_sem);
10242 + switch (pax_handle_fetch_fault(regs)) {
10243 +
10244 +#ifdef CONFIG_PAX_EMUPLT
10245 + case 2:
10246 + case 3:
10247 + return;
10248 +#endif
10249 +
10250 + }
10251 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
10252 + do_group_exit(SIGKILL);
10253 + }
10254 +#endif
10255 +
10256 /* Pure DTLB misses do not tell us whether the fault causing
10257 * load/store/atomic was a write or not, it only says that there
10258 * was no match. So in such a case we (carefully) read the
10259 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
10260 index d2b5944..bd813f2 100644
10261 --- a/arch/sparc/mm/hugetlbpage.c
10262 +++ b/arch/sparc/mm/hugetlbpage.c
10263 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10264
10265 info.flags = 0;
10266 info.length = len;
10267 - info.low_limit = TASK_UNMAPPED_BASE;
10268 + info.low_limit = mm->mmap_base;
10269 info.high_limit = min(task_size, VA_EXCLUDE_START);
10270 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10271 info.align_offset = 0;
10272 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10273 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10274 VM_BUG_ON(addr != -ENOMEM);
10275 info.low_limit = VA_EXCLUDE_END;
10276 +
10277 +#ifdef CONFIG_PAX_RANDMMAP
10278 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10279 + info.low_limit += mm->delta_mmap;
10280 +#endif
10281 +
10282 info.high_limit = task_size;
10283 addr = vm_unmapped_area(&info);
10284 }
10285 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10286 VM_BUG_ON(addr != -ENOMEM);
10287 info.flags = 0;
10288 info.low_limit = TASK_UNMAPPED_BASE;
10289 +
10290 +#ifdef CONFIG_PAX_RANDMMAP
10291 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10292 + info.low_limit += mm->delta_mmap;
10293 +#endif
10294 +
10295 info.high_limit = STACK_TOP32;
10296 addr = vm_unmapped_area(&info);
10297 }
10298 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10299 struct mm_struct *mm = current->mm;
10300 struct vm_area_struct *vma;
10301 unsigned long task_size = TASK_SIZE;
10302 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10303
10304 if (test_thread_flag(TIF_32BIT))
10305 task_size = STACK_TOP32;
10306 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10307 return addr;
10308 }
10309
10310 +#ifdef CONFIG_PAX_RANDMMAP
10311 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10312 +#endif
10313 +
10314 if (addr) {
10315 addr = ALIGN(addr, HPAGE_SIZE);
10316 vma = find_vma(mm, addr);
10317 - if (task_size - len >= addr &&
10318 - (!vma || addr + len <= vma->vm_start))
10319 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10320 return addr;
10321 }
10322 if (mm->get_unmapped_area == arch_get_unmapped_area)
10323 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10324 index f4500c6..889656c 100644
10325 --- a/arch/tile/include/asm/atomic_64.h
10326 +++ b/arch/tile/include/asm/atomic_64.h
10327 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10328
10329 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10330
10331 +#define atomic64_read_unchecked(v) atomic64_read(v)
10332 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10333 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10334 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10335 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10336 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10337 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10338 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10339 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10340 +
10341 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10342 #define smp_mb__before_atomic_dec() smp_mb()
10343 #define smp_mb__after_atomic_dec() smp_mb()
10344 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10345 index a9a5299..0fce79e 100644
10346 --- a/arch/tile/include/asm/cache.h
10347 +++ b/arch/tile/include/asm/cache.h
10348 @@ -15,11 +15,12 @@
10349 #ifndef _ASM_TILE_CACHE_H
10350 #define _ASM_TILE_CACHE_H
10351
10352 +#include <linux/const.h>
10353 #include <arch/chip.h>
10354
10355 /* bytes per L1 data cache line */
10356 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10357 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10358 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10359
10360 /* bytes per L2 cache line */
10361 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10362 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10363 index 9ab078a..d6635c2 100644
10364 --- a/arch/tile/include/asm/uaccess.h
10365 +++ b/arch/tile/include/asm/uaccess.h
10366 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10367 const void __user *from,
10368 unsigned long n)
10369 {
10370 - int sz = __compiletime_object_size(to);
10371 + size_t sz = __compiletime_object_size(to);
10372
10373 - if (likely(sz == -1 || sz >= n))
10374 + if (likely(sz == (size_t)-1 || sz >= n))
10375 n = _copy_from_user(to, from, n);
10376 else
10377 copy_from_user_overflow();
10378 diff --git a/arch/um/Makefile b/arch/um/Makefile
10379 index 133f7de..1d6f2f1 100644
10380 --- a/arch/um/Makefile
10381 +++ b/arch/um/Makefile
10382 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10383 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10384 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10385
10386 +ifdef CONSTIFY_PLUGIN
10387 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10388 +endif
10389 +
10390 #This will adjust *FLAGS accordingly to the platform.
10391 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10392
10393 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10394 index 19e1bdd..3665b77 100644
10395 --- a/arch/um/include/asm/cache.h
10396 +++ b/arch/um/include/asm/cache.h
10397 @@ -1,6 +1,7 @@
10398 #ifndef __UM_CACHE_H
10399 #define __UM_CACHE_H
10400
10401 +#include <linux/const.h>
10402
10403 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10404 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10405 @@ -12,6 +13,6 @@
10406 # define L1_CACHE_SHIFT 5
10407 #endif
10408
10409 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10410 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10411
10412 #endif
10413 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10414 index 2e0a6b1..a64d0f5 100644
10415 --- a/arch/um/include/asm/kmap_types.h
10416 +++ b/arch/um/include/asm/kmap_types.h
10417 @@ -8,6 +8,6 @@
10418
10419 /* No more #include "asm/arch/kmap_types.h" ! */
10420
10421 -#define KM_TYPE_NR 14
10422 +#define KM_TYPE_NR 15
10423
10424 #endif
10425 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10426 index 5ff53d9..5850cdf 100644
10427 --- a/arch/um/include/asm/page.h
10428 +++ b/arch/um/include/asm/page.h
10429 @@ -14,6 +14,9 @@
10430 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10431 #define PAGE_MASK (~(PAGE_SIZE-1))
10432
10433 +#define ktla_ktva(addr) (addr)
10434 +#define ktva_ktla(addr) (addr)
10435 +
10436 #ifndef __ASSEMBLY__
10437
10438 struct page;
10439 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10440 index 0032f92..cd151e0 100644
10441 --- a/arch/um/include/asm/pgtable-3level.h
10442 +++ b/arch/um/include/asm/pgtable-3level.h
10443 @@ -58,6 +58,7 @@
10444 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10445 #define pud_populate(mm, pud, pmd) \
10446 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10447 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10448
10449 #ifdef CONFIG_64BIT
10450 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10451 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10452 index b462b13..e7a19aa 100644
10453 --- a/arch/um/kernel/process.c
10454 +++ b/arch/um/kernel/process.c
10455 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10456 return 2;
10457 }
10458
10459 -/*
10460 - * Only x86 and x86_64 have an arch_align_stack().
10461 - * All other arches have "#define arch_align_stack(x) (x)"
10462 - * in their asm/system.h
10463 - * As this is included in UML from asm-um/system-generic.h,
10464 - * we can use it to behave as the subarch does.
10465 - */
10466 -#ifndef arch_align_stack
10467 -unsigned long arch_align_stack(unsigned long sp)
10468 -{
10469 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10470 - sp -= get_random_int() % 8192;
10471 - return sp & ~0xf;
10472 -}
10473 -#endif
10474 -
10475 unsigned long get_wchan(struct task_struct *p)
10476 {
10477 unsigned long stack_page, sp, ip;
10478 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10479 index ad8f795..2c7eec6 100644
10480 --- a/arch/unicore32/include/asm/cache.h
10481 +++ b/arch/unicore32/include/asm/cache.h
10482 @@ -12,8 +12,10 @@
10483 #ifndef __UNICORE_CACHE_H__
10484 #define __UNICORE_CACHE_H__
10485
10486 -#define L1_CACHE_SHIFT (5)
10487 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10488 +#include <linux/const.h>
10489 +
10490 +#define L1_CACHE_SHIFT 5
10491 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10492
10493 /*
10494 * Memory returned by kmalloc() may be used for DMA, so we must make
10495 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10496 index 0694d09..b58b3aa 100644
10497 --- a/arch/x86/Kconfig
10498 +++ b/arch/x86/Kconfig
10499 @@ -238,7 +238,7 @@ config X86_HT
10500
10501 config X86_32_LAZY_GS
10502 def_bool y
10503 - depends on X86_32 && !CC_STACKPROTECTOR
10504 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10505
10506 config ARCH_HWEIGHT_CFLAGS
10507 string
10508 @@ -1031,6 +1031,7 @@ config MICROCODE_OLD_INTERFACE
10509
10510 config X86_MSR
10511 tristate "/dev/cpu/*/msr - Model-specific register support"
10512 + depends on !GRKERNSEC_KMEM
10513 ---help---
10514 This device gives privileged processes access to the x86
10515 Model-Specific Registers (MSRs). It is a character device with
10516 @@ -1054,7 +1055,7 @@ choice
10517
10518 config NOHIGHMEM
10519 bool "off"
10520 - depends on !X86_NUMAQ
10521 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10522 ---help---
10523 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10524 However, the address space of 32-bit x86 processors is only 4
10525 @@ -1091,7 +1092,7 @@ config NOHIGHMEM
10526
10527 config HIGHMEM4G
10528 bool "4GB"
10529 - depends on !X86_NUMAQ
10530 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10531 ---help---
10532 Select this if you have a 32-bit processor and between 1 and 4
10533 gigabytes of physical RAM.
10534 @@ -1145,7 +1146,7 @@ config PAGE_OFFSET
10535 hex
10536 default 0xB0000000 if VMSPLIT_3G_OPT
10537 default 0x80000000 if VMSPLIT_2G
10538 - default 0x78000000 if VMSPLIT_2G_OPT
10539 + default 0x70000000 if VMSPLIT_2G_OPT
10540 default 0x40000000 if VMSPLIT_1G
10541 default 0xC0000000
10542 depends on X86_32
10543 @@ -1542,6 +1543,7 @@ config SECCOMP
10544
10545 config CC_STACKPROTECTOR
10546 bool "Enable -fstack-protector buffer overflow detection"
10547 + depends on X86_64 || !PAX_MEMORY_UDEREF
10548 ---help---
10549 This option turns on the -fstack-protector GCC feature. This
10550 feature puts, at the beginning of functions, a canary value on
10551 @@ -1599,6 +1601,7 @@ config KEXEC_JUMP
10552 config PHYSICAL_START
10553 hex "Physical address where the kernel is loaded" if (EXPERT || CRASH_DUMP)
10554 default "0x1000000"
10555 + range 0x400000 0x40000000
10556 ---help---
10557 This gives the physical address where the kernel is loaded.
10558
10559 @@ -1662,6 +1665,7 @@ config X86_NEED_RELOCS
10560 config PHYSICAL_ALIGN
10561 hex "Alignment value to which kernel should be aligned" if X86_32
10562 default "0x1000000"
10563 + range 0x400000 0x1000000 if PAX_KERNEXEC
10564 range 0x2000 0x1000000
10565 ---help---
10566 This value puts the alignment restrictions on physical address
10567 @@ -1737,9 +1741,10 @@ config DEBUG_HOTPLUG_CPU0
10568 If unsure, say N.
10569
10570 config COMPAT_VDSO
10571 - def_bool y
10572 + def_bool n
10573 prompt "Compat VDSO support"
10574 depends on X86_32 || IA32_EMULATION
10575 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10576 ---help---
10577 Map the 32-bit VDSO to the predictable old-style address too.
10578
10579 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10580 index c026cca..14657ae 100644
10581 --- a/arch/x86/Kconfig.cpu
10582 +++ b/arch/x86/Kconfig.cpu
10583 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10584
10585 config X86_F00F_BUG
10586 def_bool y
10587 - depends on M586MMX || M586TSC || M586 || M486
10588 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10589
10590 config X86_INVD_BUG
10591 def_bool y
10592 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10593
10594 config X86_ALIGNMENT_16
10595 def_bool y
10596 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10597 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10598
10599 config X86_INTEL_USERCOPY
10600 def_bool y
10601 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10602 # generates cmov.
10603 config X86_CMOV
10604 def_bool y
10605 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10606 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10607
10608 config X86_MINIMUM_CPU_FAMILY
10609 int
10610 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10611 index b322f12..652d0d9 100644
10612 --- a/arch/x86/Kconfig.debug
10613 +++ b/arch/x86/Kconfig.debug
10614 @@ -84,7 +84,7 @@ config X86_PTDUMP
10615 config DEBUG_RODATA
10616 bool "Write protect kernel read-only data structures"
10617 default y
10618 - depends on DEBUG_KERNEL
10619 + depends on DEBUG_KERNEL && BROKEN
10620 ---help---
10621 Mark the kernel read-only data as write-protected in the pagetables,
10622 in order to catch accidental (and incorrect) writes to such const
10623 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10624
10625 config DEBUG_SET_MODULE_RONX
10626 bool "Set loadable kernel module data as NX and text as RO"
10627 - depends on MODULES
10628 + depends on MODULES && BROKEN
10629 ---help---
10630 This option helps catch unintended modifications to loadable
10631 kernel module's text and read-only data. It also prevents execution
10632 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10633
10634 config DEBUG_STRICT_USER_COPY_CHECKS
10635 bool "Strict copy size checks"
10636 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10637 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10638 ---help---
10639 Enabling this option turns a certain set of sanity checks for user
10640 copy operations into compile time failures.
10641 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10642 index e71fc42..7829607 100644
10643 --- a/arch/x86/Makefile
10644 +++ b/arch/x86/Makefile
10645 @@ -50,6 +50,7 @@ else
10646 UTS_MACHINE := x86_64
10647 CHECKFLAGS += -D__x86_64__ -m64
10648
10649 + biarch := $(call cc-option,-m64)
10650 KBUILD_AFLAGS += -m64
10651 KBUILD_CFLAGS += -m64
10652
10653 @@ -230,3 +231,12 @@ define archhelp
10654 echo ' FDARGS="..." arguments for the booted kernel'
10655 echo ' FDINITRD=file initrd for the booted kernel'
10656 endef
10657 +
10658 +define OLD_LD
10659 +
10660 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10661 +*** Please upgrade your binutils to 2.18 or newer
10662 +endef
10663 +
10664 +archprepare:
10665 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10666 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10667 index 379814b..add62ce 100644
10668 --- a/arch/x86/boot/Makefile
10669 +++ b/arch/x86/boot/Makefile
10670 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10671 $(call cc-option, -fno-stack-protector) \
10672 $(call cc-option, -mpreferred-stack-boundary=2)
10673 KBUILD_CFLAGS += $(call cc-option, -m32)
10674 +ifdef CONSTIFY_PLUGIN
10675 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10676 +endif
10677 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10678 GCOV_PROFILE := n
10679
10680 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10681 index 878e4b9..20537ab 100644
10682 --- a/arch/x86/boot/bitops.h
10683 +++ b/arch/x86/boot/bitops.h
10684 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10685 u8 v;
10686 const u32 *p = (const u32 *)addr;
10687
10688 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10689 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10690 return v;
10691 }
10692
10693 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10694
10695 static inline void set_bit(int nr, void *addr)
10696 {
10697 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10698 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10699 }
10700
10701 #endif /* BOOT_BITOPS_H */
10702 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10703 index 18997e5..83d9c67 100644
10704 --- a/arch/x86/boot/boot.h
10705 +++ b/arch/x86/boot/boot.h
10706 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10707 static inline u16 ds(void)
10708 {
10709 u16 seg;
10710 - asm("movw %%ds,%0" : "=rm" (seg));
10711 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10712 return seg;
10713 }
10714
10715 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10716 static inline int memcmp(const void *s1, const void *s2, size_t len)
10717 {
10718 u8 diff;
10719 - asm("repe; cmpsb; setnz %0"
10720 + asm volatile("repe; cmpsb; setnz %0"
10721 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10722 return diff;
10723 }
10724 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10725 index 5ef205c..342191d 100644
10726 --- a/arch/x86/boot/compressed/Makefile
10727 +++ b/arch/x86/boot/compressed/Makefile
10728 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10729 KBUILD_CFLAGS += $(cflags-y)
10730 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10731 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10732 +ifdef CONSTIFY_PLUGIN
10733 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10734 +endif
10735
10736 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10737 GCOV_PROFILE := n
10738 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10739 index c205035..5853587 100644
10740 --- a/arch/x86/boot/compressed/eboot.c
10741 +++ b/arch/x86/boot/compressed/eboot.c
10742 @@ -150,7 +150,6 @@ again:
10743 *addr = max_addr;
10744 }
10745
10746 -free_pool:
10747 efi_call_phys1(sys_table->boottime->free_pool, map);
10748
10749 fail:
10750 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10751 if (i == map_size / desc_size)
10752 status = EFI_NOT_FOUND;
10753
10754 -free_pool:
10755 efi_call_phys1(sys_table->boottime->free_pool, map);
10756 fail:
10757 return status;
10758 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10759 index 1e3184f..0d11e2e 100644
10760 --- a/arch/x86/boot/compressed/head_32.S
10761 +++ b/arch/x86/boot/compressed/head_32.S
10762 @@ -118,7 +118,7 @@ preferred_addr:
10763 notl %eax
10764 andl %eax, %ebx
10765 #else
10766 - movl $LOAD_PHYSICAL_ADDR, %ebx
10767 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10768 #endif
10769
10770 /* Target address to relocate to for decompression */
10771 @@ -204,7 +204,7 @@ relocated:
10772 * and where it was actually loaded.
10773 */
10774 movl %ebp, %ebx
10775 - subl $LOAD_PHYSICAL_ADDR, %ebx
10776 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10777 jz 2f /* Nothing to be done if loaded at compiled addr. */
10778 /*
10779 * Process relocations.
10780 @@ -212,8 +212,7 @@ relocated:
10781
10782 1: subl $4, %edi
10783 movl (%edi), %ecx
10784 - testl %ecx, %ecx
10785 - jz 2f
10786 + jecxz 2f
10787 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10788 jmp 1b
10789 2:
10790 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10791 index f5d1aaa..cce11dc 100644
10792 --- a/arch/x86/boot/compressed/head_64.S
10793 +++ b/arch/x86/boot/compressed/head_64.S
10794 @@ -91,7 +91,7 @@ ENTRY(startup_32)
10795 notl %eax
10796 andl %eax, %ebx
10797 #else
10798 - movl $LOAD_PHYSICAL_ADDR, %ebx
10799 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10800 #endif
10801
10802 /* Target address to relocate to for decompression */
10803 @@ -273,7 +273,7 @@ preferred_addr:
10804 notq %rax
10805 andq %rax, %rbp
10806 #else
10807 - movq $LOAD_PHYSICAL_ADDR, %rbp
10808 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10809 #endif
10810
10811 /* Target address to relocate to for decompression */
10812 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10813 index 88f7ff6..ed695dd 100644
10814 --- a/arch/x86/boot/compressed/misc.c
10815 +++ b/arch/x86/boot/compressed/misc.c
10816 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10817 case PT_LOAD:
10818 #ifdef CONFIG_RELOCATABLE
10819 dest = output;
10820 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10821 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10822 #else
10823 dest = (void *)(phdr->p_paddr);
10824 #endif
10825 @@ -352,7 +352,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10826 error("Destination address too large");
10827 #endif
10828 #ifndef CONFIG_RELOCATABLE
10829 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10830 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10831 error("Wrong destination address");
10832 #endif
10833
10834 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10835 index 4d3ff03..e4972ff 100644
10836 --- a/arch/x86/boot/cpucheck.c
10837 +++ b/arch/x86/boot/cpucheck.c
10838 @@ -74,7 +74,7 @@ static int has_fpu(void)
10839 u16 fcw = -1, fsw = -1;
10840 u32 cr0;
10841
10842 - asm("movl %%cr0,%0" : "=r" (cr0));
10843 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10844 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10845 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10846 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10847 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10848 {
10849 u32 f0, f1;
10850
10851 - asm("pushfl ; "
10852 + asm volatile("pushfl ; "
10853 "pushfl ; "
10854 "popl %0 ; "
10855 "movl %0,%1 ; "
10856 @@ -115,7 +115,7 @@ static void get_flags(void)
10857 set_bit(X86_FEATURE_FPU, cpu.flags);
10858
10859 if (has_eflag(X86_EFLAGS_ID)) {
10860 - asm("cpuid"
10861 + asm volatile("cpuid"
10862 : "=a" (max_intel_level),
10863 "=b" (cpu_vendor[0]),
10864 "=d" (cpu_vendor[1]),
10865 @@ -124,7 +124,7 @@ static void get_flags(void)
10866
10867 if (max_intel_level >= 0x00000001 &&
10868 max_intel_level <= 0x0000ffff) {
10869 - asm("cpuid"
10870 + asm volatile("cpuid"
10871 : "=a" (tfms),
10872 "=c" (cpu.flags[4]),
10873 "=d" (cpu.flags[0])
10874 @@ -136,7 +136,7 @@ static void get_flags(void)
10875 cpu.model += ((tfms >> 16) & 0xf) << 4;
10876 }
10877
10878 - asm("cpuid"
10879 + asm volatile("cpuid"
10880 : "=a" (max_amd_level)
10881 : "a" (0x80000000)
10882 : "ebx", "ecx", "edx");
10883 @@ -144,7 +144,7 @@ static void get_flags(void)
10884 if (max_amd_level >= 0x80000001 &&
10885 max_amd_level <= 0x8000ffff) {
10886 u32 eax = 0x80000001;
10887 - asm("cpuid"
10888 + asm volatile("cpuid"
10889 : "+a" (eax),
10890 "=c" (cpu.flags[6]),
10891 "=d" (cpu.flags[1])
10892 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10893 u32 ecx = MSR_K7_HWCR;
10894 u32 eax, edx;
10895
10896 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10897 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10898 eax &= ~(1 << 15);
10899 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10900 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10901
10902 get_flags(); /* Make sure it really did something */
10903 err = check_flags();
10904 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10905 u32 ecx = MSR_VIA_FCR;
10906 u32 eax, edx;
10907
10908 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10909 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10910 eax |= (1<<1)|(1<<7);
10911 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10912 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10913
10914 set_bit(X86_FEATURE_CX8, cpu.flags);
10915 err = check_flags();
10916 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10917 u32 eax, edx;
10918 u32 level = 1;
10919
10920 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10921 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10922 - asm("cpuid"
10923 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10924 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10925 + asm volatile("cpuid"
10926 : "+a" (level), "=d" (cpu.flags[0])
10927 : : "ecx", "ebx");
10928 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10929 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10930
10931 err = check_flags();
10932 }
10933 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10934 index 944ce59..87ee37a 100644
10935 --- a/arch/x86/boot/header.S
10936 +++ b/arch/x86/boot/header.S
10937 @@ -401,10 +401,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10938 # single linked list of
10939 # struct setup_data
10940
10941 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10942 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10943
10944 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10945 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10946 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10947 +#else
10948 #define VO_INIT_SIZE (VO__end - VO__text)
10949 +#endif
10950 #if ZO_INIT_SIZE > VO_INIT_SIZE
10951 #define INIT_SIZE ZO_INIT_SIZE
10952 #else
10953 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10954 index db75d07..8e6d0af 100644
10955 --- a/arch/x86/boot/memory.c
10956 +++ b/arch/x86/boot/memory.c
10957 @@ -19,7 +19,7 @@
10958
10959 static int detect_memory_e820(void)
10960 {
10961 - int count = 0;
10962 + unsigned int count = 0;
10963 struct biosregs ireg, oreg;
10964 struct e820entry *desc = boot_params.e820_map;
10965 static struct e820entry buf; /* static so it is zeroed */
10966 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10967 index 11e8c6e..fdbb1ed 100644
10968 --- a/arch/x86/boot/video-vesa.c
10969 +++ b/arch/x86/boot/video-vesa.c
10970 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10971
10972 boot_params.screen_info.vesapm_seg = oreg.es;
10973 boot_params.screen_info.vesapm_off = oreg.di;
10974 + boot_params.screen_info.vesapm_size = oreg.cx;
10975 }
10976
10977 /*
10978 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10979 index 43eda28..5ab5fdb 100644
10980 --- a/arch/x86/boot/video.c
10981 +++ b/arch/x86/boot/video.c
10982 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10983 static unsigned int get_entry(void)
10984 {
10985 char entry_buf[4];
10986 - int i, len = 0;
10987 + unsigned int i, len = 0;
10988 int key;
10989 unsigned int v;
10990
10991 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10992 index 5b577d5..3c1fed4 100644
10993 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10994 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10995 @@ -8,6 +8,8 @@
10996 * including this sentence is retained in full.
10997 */
10998
10999 +#include <asm/alternative-asm.h>
11000 +
11001 .extern crypto_ft_tab
11002 .extern crypto_it_tab
11003 .extern crypto_fl_tab
11004 @@ -71,6 +73,8 @@ FUNC: movq r1,r2; \
11005 je B192; \
11006 leaq 32(r9),r9;
11007
11008 +#define ret pax_force_retaddr 0, 1; ret
11009 +
11010 #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
11011 movq r1,r2; \
11012 movq r3,r4; \
11013 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
11014 index 3470624..201259d 100644
11015 --- a/arch/x86/crypto/aesni-intel_asm.S
11016 +++ b/arch/x86/crypto/aesni-intel_asm.S
11017 @@ -31,6 +31,7 @@
11018
11019 #include <linux/linkage.h>
11020 #include <asm/inst.h>
11021 +#include <asm/alternative-asm.h>
11022
11023 #ifdef __x86_64__
11024 .data
11025 @@ -1436,7 +1437,9 @@ _return_T_done_decrypt:
11026 pop %r14
11027 pop %r13
11028 pop %r12
11029 + pax_force_retaddr 0, 1
11030 ret
11031 +ENDPROC(aesni_gcm_dec)
11032
11033
11034 /*****************************************************************************
11035 @@ -1699,7 +1702,9 @@ _return_T_done_encrypt:
11036 pop %r14
11037 pop %r13
11038 pop %r12
11039 + pax_force_retaddr 0, 1
11040 ret
11041 +ENDPROC(aesni_gcm_enc)
11042
11043 #endif
11044
11045 @@ -1714,6 +1719,7 @@ _key_expansion_256a:
11046 pxor %xmm1, %xmm0
11047 movaps %xmm0, (TKEYP)
11048 add $0x10, TKEYP
11049 + pax_force_retaddr_bts
11050 ret
11051
11052 .align 4
11053 @@ -1738,6 +1744,7 @@ _key_expansion_192a:
11054 shufps $0b01001110, %xmm2, %xmm1
11055 movaps %xmm1, 0x10(TKEYP)
11056 add $0x20, TKEYP
11057 + pax_force_retaddr_bts
11058 ret
11059
11060 .align 4
11061 @@ -1757,6 +1764,7 @@ _key_expansion_192b:
11062
11063 movaps %xmm0, (TKEYP)
11064 add $0x10, TKEYP
11065 + pax_force_retaddr_bts
11066 ret
11067
11068 .align 4
11069 @@ -1769,6 +1777,7 @@ _key_expansion_256b:
11070 pxor %xmm1, %xmm2
11071 movaps %xmm2, (TKEYP)
11072 add $0x10, TKEYP
11073 + pax_force_retaddr_bts
11074 ret
11075
11076 /*
11077 @@ -1881,7 +1890,9 @@ ENTRY(aesni_set_key)
11078 #ifndef __x86_64__
11079 popl KEYP
11080 #endif
11081 + pax_force_retaddr 0, 1
11082 ret
11083 +ENDPROC(aesni_set_key)
11084
11085 /*
11086 * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
11087 @@ -1902,7 +1913,9 @@ ENTRY(aesni_enc)
11088 popl KLEN
11089 popl KEYP
11090 #endif
11091 + pax_force_retaddr 0, 1
11092 ret
11093 +ENDPROC(aesni_enc)
11094
11095 /*
11096 * _aesni_enc1: internal ABI
11097 @@ -1959,6 +1972,7 @@ _aesni_enc1:
11098 AESENC KEY STATE
11099 movaps 0x70(TKEYP), KEY
11100 AESENCLAST KEY STATE
11101 + pax_force_retaddr_bts
11102 ret
11103
11104 /*
11105 @@ -2067,6 +2081,7 @@ _aesni_enc4:
11106 AESENCLAST KEY STATE2
11107 AESENCLAST KEY STATE3
11108 AESENCLAST KEY STATE4
11109 + pax_force_retaddr_bts
11110 ret
11111
11112 /*
11113 @@ -2089,7 +2104,9 @@ ENTRY(aesni_dec)
11114 popl KLEN
11115 popl KEYP
11116 #endif
11117 + pax_force_retaddr 0, 1
11118 ret
11119 +ENDPROC(aesni_dec)
11120
11121 /*
11122 * _aesni_dec1: internal ABI
11123 @@ -2146,6 +2163,7 @@ _aesni_dec1:
11124 AESDEC KEY STATE
11125 movaps 0x70(TKEYP), KEY
11126 AESDECLAST KEY STATE
11127 + pax_force_retaddr_bts
11128 ret
11129
11130 /*
11131 @@ -2254,6 +2272,7 @@ _aesni_dec4:
11132 AESDECLAST KEY STATE2
11133 AESDECLAST KEY STATE3
11134 AESDECLAST KEY STATE4
11135 + pax_force_retaddr_bts
11136 ret
11137
11138 /*
11139 @@ -2311,7 +2330,9 @@ ENTRY(aesni_ecb_enc)
11140 popl KEYP
11141 popl LEN
11142 #endif
11143 + pax_force_retaddr 0, 1
11144 ret
11145 +ENDPROC(aesni_ecb_enc)
11146
11147 /*
11148 * void aesni_ecb_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11149 @@ -2369,7 +2390,9 @@ ENTRY(aesni_ecb_dec)
11150 popl KEYP
11151 popl LEN
11152 #endif
11153 + pax_force_retaddr 0, 1
11154 ret
11155 +ENDPROC(aesni_ecb_dec)
11156
11157 /*
11158 * void aesni_cbc_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11159 @@ -2410,7 +2433,9 @@ ENTRY(aesni_cbc_enc)
11160 popl LEN
11161 popl IVP
11162 #endif
11163 + pax_force_retaddr 0, 1
11164 ret
11165 +ENDPROC(aesni_cbc_enc)
11166
11167 /*
11168 * void aesni_cbc_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11169 @@ -2500,7 +2525,9 @@ ENTRY(aesni_cbc_dec)
11170 popl LEN
11171 popl IVP
11172 #endif
11173 + pax_force_retaddr 0, 1
11174 ret
11175 +ENDPROC(aesni_cbc_dec)
11176
11177 #ifdef __x86_64__
11178 .align 16
11179 @@ -2526,6 +2553,7 @@ _aesni_inc_init:
11180 mov $1, TCTR_LOW
11181 MOVQ_R64_XMM TCTR_LOW INC
11182 MOVQ_R64_XMM CTR TCTR_LOW
11183 + pax_force_retaddr_bts
11184 ret
11185
11186 /*
11187 @@ -2554,6 +2582,7 @@ _aesni_inc:
11188 .Linc_low:
11189 movaps CTR, IV
11190 PSHUFB_XMM BSWAP_MASK IV
11191 + pax_force_retaddr_bts
11192 ret
11193
11194 /*
11195 @@ -2614,5 +2643,7 @@ ENTRY(aesni_ctr_enc)
11196 .Lctr_enc_ret:
11197 movups IV, (IVP)
11198 .Lctr_enc_just_ret:
11199 + pax_force_retaddr 0, 1
11200 ret
11201 +ENDPROC(aesni_ctr_enc)
11202 #endif
11203 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11204 index 391d245..67f35c2 100644
11205 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
11206 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11207 @@ -20,6 +20,8 @@
11208 *
11209 */
11210
11211 +#include <asm/alternative-asm.h>
11212 +
11213 .file "blowfish-x86_64-asm.S"
11214 .text
11215
11216 @@ -151,9 +153,11 @@ __blowfish_enc_blk:
11217 jnz __enc_xor;
11218
11219 write_block();
11220 + pax_force_retaddr 0, 1
11221 ret;
11222 __enc_xor:
11223 xor_block();
11224 + pax_force_retaddr 0, 1
11225 ret;
11226
11227 .align 8
11228 @@ -188,6 +192,7 @@ blowfish_dec_blk:
11229
11230 movq %r11, %rbp;
11231
11232 + pax_force_retaddr 0, 1
11233 ret;
11234
11235 /**********************************************************************
11236 @@ -342,6 +347,7 @@ __blowfish_enc_blk_4way:
11237
11238 popq %rbx;
11239 popq %rbp;
11240 + pax_force_retaddr 0, 1
11241 ret;
11242
11243 __enc_xor4:
11244 @@ -349,6 +355,7 @@ __enc_xor4:
11245
11246 popq %rbx;
11247 popq %rbp;
11248 + pax_force_retaddr 0, 1
11249 ret;
11250
11251 .align 8
11252 @@ -386,5 +393,6 @@ blowfish_dec_blk_4way:
11253 popq %rbx;
11254 popq %rbp;
11255
11256 + pax_force_retaddr 0, 1
11257 ret;
11258
11259 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11260 index 0b33743..7a56206 100644
11261 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11262 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11263 @@ -20,6 +20,8 @@
11264 *
11265 */
11266
11267 +#include <asm/alternative-asm.h>
11268 +
11269 .file "camellia-x86_64-asm_64.S"
11270 .text
11271
11272 @@ -229,12 +231,14 @@ __enc_done:
11273 enc_outunpack(mov, RT1);
11274
11275 movq RRBP, %rbp;
11276 + pax_force_retaddr 0, 1
11277 ret;
11278
11279 __enc_xor:
11280 enc_outunpack(xor, RT1);
11281
11282 movq RRBP, %rbp;
11283 + pax_force_retaddr 0, 1
11284 ret;
11285
11286 .global camellia_dec_blk;
11287 @@ -275,6 +279,7 @@ __dec_rounds16:
11288 dec_outunpack();
11289
11290 movq RRBP, %rbp;
11291 + pax_force_retaddr 0, 1
11292 ret;
11293
11294 /**********************************************************************
11295 @@ -468,6 +473,7 @@ __enc2_done:
11296
11297 movq RRBP, %rbp;
11298 popq %rbx;
11299 + pax_force_retaddr 0, 1
11300 ret;
11301
11302 __enc2_xor:
11303 @@ -475,6 +481,7 @@ __enc2_xor:
11304
11305 movq RRBP, %rbp;
11306 popq %rbx;
11307 + pax_force_retaddr 0, 1
11308 ret;
11309
11310 .global camellia_dec_blk_2way;
11311 @@ -517,4 +524,5 @@ __dec2_rounds16:
11312
11313 movq RRBP, %rbp;
11314 movq RXOR, %rbx;
11315 + pax_force_retaddr 0, 1
11316 ret;
11317 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11318 index 15b00ac..2071784 100644
11319 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11320 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11321 @@ -23,6 +23,8 @@
11322 *
11323 */
11324
11325 +#include <asm/alternative-asm.h>
11326 +
11327 .file "cast5-avx-x86_64-asm_64.S"
11328
11329 .extern cast_s1
11330 @@ -281,6 +283,7 @@ __skip_enc:
11331 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11332 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11333
11334 + pax_force_retaddr 0, 1
11335 ret;
11336
11337 .align 16
11338 @@ -353,6 +356,7 @@ __dec_tail:
11339 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11340 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11341
11342 + pax_force_retaddr 0, 1
11343 ret;
11344
11345 __skip_dec:
11346 @@ -392,6 +396,7 @@ cast5_ecb_enc_16way:
11347 vmovdqu RR4, (6*4*4)(%r11);
11348 vmovdqu RL4, (7*4*4)(%r11);
11349
11350 + pax_force_retaddr
11351 ret;
11352
11353 .align 16
11354 @@ -427,6 +432,7 @@ cast5_ecb_dec_16way:
11355 vmovdqu RR4, (6*4*4)(%r11);
11356 vmovdqu RL4, (7*4*4)(%r11);
11357
11358 + pax_force_retaddr
11359 ret;
11360
11361 .align 16
11362 @@ -479,6 +485,7 @@ cast5_cbc_dec_16way:
11363
11364 popq %r12;
11365
11366 + pax_force_retaddr
11367 ret;
11368
11369 .align 16
11370 @@ -555,4 +562,5 @@ cast5_ctr_16way:
11371
11372 popq %r12;
11373
11374 + pax_force_retaddr
11375 ret;
11376 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11377 index 2569d0d..637c289 100644
11378 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11379 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11380 @@ -23,6 +23,8 @@
11381 *
11382 */
11383
11384 +#include <asm/alternative-asm.h>
11385 +
11386 #include "glue_helper-asm-avx.S"
11387
11388 .file "cast6-avx-x86_64-asm_64.S"
11389 @@ -294,6 +296,7 @@ __cast6_enc_blk8:
11390 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11391 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11392
11393 + pax_force_retaddr 0, 1
11394 ret;
11395
11396 .align 8
11397 @@ -340,6 +343,7 @@ __cast6_dec_blk8:
11398 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11399 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11400
11401 + pax_force_retaddr 0, 1
11402 ret;
11403
11404 .align 8
11405 @@ -361,6 +365,7 @@ cast6_ecb_enc_8way:
11406
11407 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11408
11409 + pax_force_retaddr
11410 ret;
11411
11412 .align 8
11413 @@ -382,6 +387,7 @@ cast6_ecb_dec_8way:
11414
11415 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11416
11417 + pax_force_retaddr
11418 ret;
11419
11420 .align 8
11421 @@ -408,6 +414,7 @@ cast6_cbc_dec_8way:
11422
11423 popq %r12;
11424
11425 + pax_force_retaddr
11426 ret;
11427
11428 .align 8
11429 @@ -436,4 +443,5 @@ cast6_ctr_8way:
11430
11431 popq %r12;
11432
11433 + pax_force_retaddr
11434 ret;
11435 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11436 index 6214a9b..1f4fc9a 100644
11437 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11438 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11439 @@ -1,3 +1,5 @@
11440 +#include <asm/alternative-asm.h>
11441 +
11442 # enter ECRYPT_encrypt_bytes
11443 .text
11444 .p2align 5
11445 @@ -790,6 +792,7 @@ ECRYPT_encrypt_bytes:
11446 add %r11,%rsp
11447 mov %rdi,%rax
11448 mov %rsi,%rdx
11449 + pax_force_retaddr 0, 1
11450 ret
11451 # bytesatleast65:
11452 ._bytesatleast65:
11453 @@ -891,6 +894,7 @@ ECRYPT_keysetup:
11454 add %r11,%rsp
11455 mov %rdi,%rax
11456 mov %rsi,%rdx
11457 + pax_force_retaddr
11458 ret
11459 # enter ECRYPT_ivsetup
11460 .text
11461 @@ -917,4 +921,5 @@ ECRYPT_ivsetup:
11462 add %r11,%rsp
11463 mov %rdi,%rax
11464 mov %rsi,%rdx
11465 + pax_force_retaddr
11466 ret
11467 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11468 index 02b0e9f..cf4cf5c 100644
11469 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11470 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11471 @@ -24,6 +24,8 @@
11472 *
11473 */
11474
11475 +#include <asm/alternative-asm.h>
11476 +
11477 #include "glue_helper-asm-avx.S"
11478
11479 .file "serpent-avx-x86_64-asm_64.S"
11480 @@ -618,6 +620,7 @@ __serpent_enc_blk8_avx:
11481 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11482 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11483
11484 + pax_force_retaddr
11485 ret;
11486
11487 .align 8
11488 @@ -673,6 +676,7 @@ __serpent_dec_blk8_avx:
11489 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11490 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11491
11492 + pax_force_retaddr
11493 ret;
11494
11495 .align 8
11496 @@ -692,6 +696,7 @@ serpent_ecb_enc_8way_avx:
11497
11498 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11499
11500 + pax_force_retaddr
11501 ret;
11502
11503 .align 8
11504 @@ -711,6 +716,7 @@ serpent_ecb_dec_8way_avx:
11505
11506 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11507
11508 + pax_force_retaddr
11509 ret;
11510
11511 .align 8
11512 @@ -730,6 +736,7 @@ serpent_cbc_dec_8way_avx:
11513
11514 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11515
11516 + pax_force_retaddr
11517 ret;
11518
11519 .align 8
11520 @@ -751,4 +758,5 @@ serpent_ctr_8way_avx:
11521
11522 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11523
11524 + pax_force_retaddr
11525 ret;
11526 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11527 index 3ee1ff0..cbc568b 100644
11528 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11529 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11530 @@ -24,6 +24,8 @@
11531 *
11532 */
11533
11534 +#include <asm/alternative-asm.h>
11535 +
11536 .file "serpent-sse2-x86_64-asm_64.S"
11537 .text
11538
11539 @@ -692,12 +694,14 @@ __serpent_enc_blk_8way:
11540 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11541 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11542
11543 + pax_force_retaddr
11544 ret;
11545
11546 __enc_xor8:
11547 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11548 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11549
11550 + pax_force_retaddr
11551 ret;
11552
11553 .align 8
11554 @@ -755,4 +759,5 @@ serpent_dec_blk_8way:
11555 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11556 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11557
11558 + pax_force_retaddr
11559 ret;
11560 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11561 index 49d6987..df66bd4 100644
11562 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11563 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11564 @@ -28,6 +28,8 @@
11565 * (at your option) any later version.
11566 */
11567
11568 +#include <asm/alternative-asm.h>
11569 +
11570 #define CTX %rdi // arg1
11571 #define BUF %rsi // arg2
11572 #define CNT %rdx // arg3
11573 @@ -104,6 +106,7 @@
11574 pop %r12
11575 pop %rbp
11576 pop %rbx
11577 + pax_force_retaddr 0, 1
11578 ret
11579
11580 .size \name, .-\name
11581 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11582 index ebac16b..8092eb9 100644
11583 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11584 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11585 @@ -23,6 +23,8 @@
11586 *
11587 */
11588
11589 +#include <asm/alternative-asm.h>
11590 +
11591 #include "glue_helper-asm-avx.S"
11592
11593 .file "twofish-avx-x86_64-asm_64.S"
11594 @@ -283,6 +285,7 @@ __twofish_enc_blk8:
11595 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11596 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11597
11598 + pax_force_retaddr 0, 1
11599 ret;
11600
11601 .align 8
11602 @@ -324,6 +327,7 @@ __twofish_dec_blk8:
11603 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11604 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11605
11606 + pax_force_retaddr 0, 1
11607 ret;
11608
11609 .align 8
11610 @@ -345,6 +349,7 @@ twofish_ecb_enc_8way:
11611
11612 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11613
11614 + pax_force_retaddr 0, 1
11615 ret;
11616
11617 .align 8
11618 @@ -366,6 +371,7 @@ twofish_ecb_dec_8way:
11619
11620 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11621
11622 + pax_force_retaddr 0, 1
11623 ret;
11624
11625 .align 8
11626 @@ -392,6 +398,7 @@ twofish_cbc_dec_8way:
11627
11628 popq %r12;
11629
11630 + pax_force_retaddr 0, 1
11631 ret;
11632
11633 .align 8
11634 @@ -420,4 +427,5 @@ twofish_ctr_8way:
11635
11636 popq %r12;
11637
11638 + pax_force_retaddr 0, 1
11639 ret;
11640 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11641 index 5b012a2..36d5364 100644
11642 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11643 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11644 @@ -20,6 +20,8 @@
11645 *
11646 */
11647
11648 +#include <asm/alternative-asm.h>
11649 +
11650 .file "twofish-x86_64-asm-3way.S"
11651 .text
11652
11653 @@ -260,6 +262,7 @@ __twofish_enc_blk_3way:
11654 popq %r13;
11655 popq %r14;
11656 popq %r15;
11657 + pax_force_retaddr 0, 1
11658 ret;
11659
11660 __enc_xor3:
11661 @@ -271,6 +274,7 @@ __enc_xor3:
11662 popq %r13;
11663 popq %r14;
11664 popq %r15;
11665 + pax_force_retaddr 0, 1
11666 ret;
11667
11668 .global twofish_dec_blk_3way
11669 @@ -312,5 +316,6 @@ twofish_dec_blk_3way:
11670 popq %r13;
11671 popq %r14;
11672 popq %r15;
11673 + pax_force_retaddr 0, 1
11674 ret;
11675
11676 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11677 index 7bcf3fc..f53832f 100644
11678 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11679 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11680 @@ -21,6 +21,7 @@
11681 .text
11682
11683 #include <asm/asm-offsets.h>
11684 +#include <asm/alternative-asm.h>
11685
11686 #define a_offset 0
11687 #define b_offset 4
11688 @@ -268,6 +269,7 @@ twofish_enc_blk:
11689
11690 popq R1
11691 movq $1,%rax
11692 + pax_force_retaddr 0, 1
11693 ret
11694
11695 twofish_dec_blk:
11696 @@ -319,4 +321,5 @@ twofish_dec_blk:
11697
11698 popq R1
11699 movq $1,%rax
11700 + pax_force_retaddr 0, 1
11701 ret
11702 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11703 index a703af1..f5b9c36 100644
11704 --- a/arch/x86/ia32/ia32_aout.c
11705 +++ b/arch/x86/ia32/ia32_aout.c
11706 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11707 unsigned long dump_start, dump_size;
11708 struct user32 dump;
11709
11710 + memset(&dump, 0, sizeof(dump));
11711 +
11712 fs = get_fs();
11713 set_fs(KERNEL_DS);
11714 has_dumped = 1;
11715 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11716 index a1daf4a..f8c4537 100644
11717 --- a/arch/x86/ia32/ia32_signal.c
11718 +++ b/arch/x86/ia32/ia32_signal.c
11719 @@ -348,7 +348,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
11720 sp -= frame_size;
11721 /* Align the stack pointer according to the i386 ABI,
11722 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11723 - sp = ((sp + 4) & -16ul) - 4;
11724 + sp = ((sp - 12) & -16ul) - 4;
11725 return (void __user *) sp;
11726 }
11727
11728 @@ -406,7 +406,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
11729 * These are actually not used anymore, but left because some
11730 * gdb versions depend on them as a marker.
11731 */
11732 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11733 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11734 } put_user_catch(err);
11735
11736 if (err)
11737 @@ -448,7 +448,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11738 0xb8,
11739 __NR_ia32_rt_sigreturn,
11740 0x80cd,
11741 - 0,
11742 + 0
11743 };
11744
11745 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
11746 @@ -471,16 +471,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11747
11748 if (ka->sa.sa_flags & SA_RESTORER)
11749 restorer = ka->sa.sa_restorer;
11750 + else if (current->mm->context.vdso)
11751 + /* Return stub is in 32bit vsyscall page */
11752 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11753 else
11754 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11755 - rt_sigreturn);
11756 + restorer = &frame->retcode;
11757 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11758
11759 /*
11760 * Not actually used anymore, but left because some gdb
11761 * versions need it.
11762 */
11763 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11764 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11765 } put_user_catch(err);
11766
11767 err |= copy_siginfo_to_user32(&frame->info, info);
11768 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11769 index 142c4ce..19b683f 100644
11770 --- a/arch/x86/ia32/ia32entry.S
11771 +++ b/arch/x86/ia32/ia32entry.S
11772 @@ -15,8 +15,10 @@
11773 #include <asm/irqflags.h>
11774 #include <asm/asm.h>
11775 #include <asm/smap.h>
11776 +#include <asm/pgtable.h>
11777 #include <linux/linkage.h>
11778 #include <linux/err.h>
11779 +#include <asm/alternative-asm.h>
11780
11781 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11782 #include <linux/elf-em.h>
11783 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11784 ENDPROC(native_irq_enable_sysexit)
11785 #endif
11786
11787 + .macro pax_enter_kernel_user
11788 + pax_set_fptr_mask
11789 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11790 + call pax_enter_kernel_user
11791 +#endif
11792 + .endm
11793 +
11794 + .macro pax_exit_kernel_user
11795 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11796 + call pax_exit_kernel_user
11797 +#endif
11798 +#ifdef CONFIG_PAX_RANDKSTACK
11799 + pushq %rax
11800 + pushq %r11
11801 + call pax_randomize_kstack
11802 + popq %r11
11803 + popq %rax
11804 +#endif
11805 + .endm
11806 +
11807 +.macro pax_erase_kstack
11808 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11809 + call pax_erase_kstack
11810 +#endif
11811 +.endm
11812 +
11813 /*
11814 * 32bit SYSENTER instruction entry.
11815 *
11816 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11817 CFI_REGISTER rsp,rbp
11818 SWAPGS_UNSAFE_STACK
11819 movq PER_CPU_VAR(kernel_stack), %rsp
11820 - addq $(KERNEL_STACK_OFFSET),%rsp
11821 - /*
11822 - * No need to follow this irqs on/off section: the syscall
11823 - * disabled irqs, here we enable it straight after entry:
11824 - */
11825 - ENABLE_INTERRUPTS(CLBR_NONE)
11826 movl %ebp,%ebp /* zero extension */
11827 pushq_cfi $__USER32_DS
11828 /*CFI_REL_OFFSET ss,0*/
11829 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11830 CFI_REL_OFFSET rsp,0
11831 pushfq_cfi
11832 /*CFI_REL_OFFSET rflags,0*/
11833 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11834 - CFI_REGISTER rip,r10
11835 + orl $X86_EFLAGS_IF,(%rsp)
11836 + GET_THREAD_INFO(%r11)
11837 + movl TI_sysenter_return(%r11), %r11d
11838 + CFI_REGISTER rip,r11
11839 pushq_cfi $__USER32_CS
11840 /*CFI_REL_OFFSET cs,0*/
11841 movl %eax, %eax
11842 - pushq_cfi %r10
11843 + pushq_cfi %r11
11844 CFI_REL_OFFSET rip,0
11845 pushq_cfi %rax
11846 cld
11847 SAVE_ARGS 0,1,0
11848 + pax_enter_kernel_user
11849 +
11850 +#ifdef CONFIG_PAX_RANDKSTACK
11851 + pax_erase_kstack
11852 +#endif
11853 +
11854 + /*
11855 + * No need to follow this irqs on/off section: the syscall
11856 + * disabled irqs, here we enable it straight after entry:
11857 + */
11858 + ENABLE_INTERRUPTS(CLBR_NONE)
11859 /* no need to do an access_ok check here because rbp has been
11860 32bit zero extended */
11861 +
11862 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11863 + mov $PAX_USER_SHADOW_BASE,%r11
11864 + add %r11,%rbp
11865 +#endif
11866 +
11867 ASM_STAC
11868 1: movl (%rbp),%ebp
11869 _ASM_EXTABLE(1b,ia32_badarg)
11870 ASM_CLAC
11871 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11872 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11873 + GET_THREAD_INFO(%r11)
11874 + orl $TS_COMPAT,TI_status(%r11)
11875 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11876 CFI_REMEMBER_STATE
11877 jnz sysenter_tracesys
11878 cmpq $(IA32_NR_syscalls-1),%rax
11879 @@ -162,12 +204,15 @@ sysenter_do_call:
11880 sysenter_dispatch:
11881 call *ia32_sys_call_table(,%rax,8)
11882 movq %rax,RAX-ARGOFFSET(%rsp)
11883 + GET_THREAD_INFO(%r11)
11884 DISABLE_INTERRUPTS(CLBR_NONE)
11885 TRACE_IRQS_OFF
11886 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11887 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11888 jnz sysexit_audit
11889 sysexit_from_sys_call:
11890 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11891 + pax_exit_kernel_user
11892 + pax_erase_kstack
11893 + andl $~TS_COMPAT,TI_status(%r11)
11894 /* clear IF, that popfq doesn't enable interrupts early */
11895 andl $~0x200,EFLAGS-R11(%rsp)
11896 movl RIP-R11(%rsp),%edx /* User %eip */
11897 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11898 movl %eax,%esi /* 2nd arg: syscall number */
11899 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11900 call __audit_syscall_entry
11901 +
11902 + pax_erase_kstack
11903 +
11904 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11905 cmpq $(IA32_NR_syscalls-1),%rax
11906 ja ia32_badsys
11907 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11908 .endm
11909
11910 .macro auditsys_exit exit
11911 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11912 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11913 jnz ia32_ret_from_sys_call
11914 TRACE_IRQS_ON
11915 ENABLE_INTERRUPTS(CLBR_NONE)
11916 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11917 1: setbe %al /* 1 if error, 0 if not */
11918 movzbl %al,%edi /* zero-extend that into %edi */
11919 call __audit_syscall_exit
11920 + GET_THREAD_INFO(%r11)
11921 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11922 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11923 DISABLE_INTERRUPTS(CLBR_NONE)
11924 TRACE_IRQS_OFF
11925 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11926 + testl %edi,TI_flags(%r11)
11927 jz \exit
11928 CLEAR_RREGS -ARGOFFSET
11929 jmp int_with_check
11930 @@ -237,7 +286,7 @@ sysexit_audit:
11931
11932 sysenter_tracesys:
11933 #ifdef CONFIG_AUDITSYSCALL
11934 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11935 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11936 jz sysenter_auditsys
11937 #endif
11938 SAVE_REST
11939 @@ -249,6 +298,9 @@ sysenter_tracesys:
11940 RESTORE_REST
11941 cmpq $(IA32_NR_syscalls-1),%rax
11942 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11943 +
11944 + pax_erase_kstack
11945 +
11946 jmp sysenter_do_call
11947 CFI_ENDPROC
11948 ENDPROC(ia32_sysenter_target)
11949 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11950 ENTRY(ia32_cstar_target)
11951 CFI_STARTPROC32 simple
11952 CFI_SIGNAL_FRAME
11953 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11954 + CFI_DEF_CFA rsp,0
11955 CFI_REGISTER rip,rcx
11956 /*CFI_REGISTER rflags,r11*/
11957 SWAPGS_UNSAFE_STACK
11958 movl %esp,%r8d
11959 CFI_REGISTER rsp,r8
11960 movq PER_CPU_VAR(kernel_stack),%rsp
11961 + SAVE_ARGS 8*6,0,0
11962 + pax_enter_kernel_user
11963 +
11964 +#ifdef CONFIG_PAX_RANDKSTACK
11965 + pax_erase_kstack
11966 +#endif
11967 +
11968 /*
11969 * No need to follow this irqs on/off section: the syscall
11970 * disabled irqs and here we enable it straight after entry:
11971 */
11972 ENABLE_INTERRUPTS(CLBR_NONE)
11973 - SAVE_ARGS 8,0,0
11974 movl %eax,%eax /* zero extension */
11975 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11976 movq %rcx,RIP-ARGOFFSET(%rsp)
11977 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11978 /* no need to do an access_ok check here because r8 has been
11979 32bit zero extended */
11980 /* hardware stack frame is complete now */
11981 +
11982 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11983 + mov $PAX_USER_SHADOW_BASE,%r11
11984 + add %r11,%r8
11985 +#endif
11986 +
11987 ASM_STAC
11988 1: movl (%r8),%r9d
11989 _ASM_EXTABLE(1b,ia32_badarg)
11990 ASM_CLAC
11991 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11992 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11993 + GET_THREAD_INFO(%r11)
11994 + orl $TS_COMPAT,TI_status(%r11)
11995 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11996 CFI_REMEMBER_STATE
11997 jnz cstar_tracesys
11998 cmpq $IA32_NR_syscalls-1,%rax
11999 @@ -319,12 +384,15 @@ cstar_do_call:
12000 cstar_dispatch:
12001 call *ia32_sys_call_table(,%rax,8)
12002 movq %rax,RAX-ARGOFFSET(%rsp)
12003 + GET_THREAD_INFO(%r11)
12004 DISABLE_INTERRUPTS(CLBR_NONE)
12005 TRACE_IRQS_OFF
12006 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12007 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
12008 jnz sysretl_audit
12009 sysretl_from_sys_call:
12010 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12011 + pax_exit_kernel_user
12012 + pax_erase_kstack
12013 + andl $~TS_COMPAT,TI_status(%r11)
12014 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
12015 movl RIP-ARGOFFSET(%rsp),%ecx
12016 CFI_REGISTER rip,rcx
12017 @@ -352,7 +420,7 @@ sysretl_audit:
12018
12019 cstar_tracesys:
12020 #ifdef CONFIG_AUDITSYSCALL
12021 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12022 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12023 jz cstar_auditsys
12024 #endif
12025 xchgl %r9d,%ebp
12026 @@ -366,6 +434,9 @@ cstar_tracesys:
12027 xchgl %ebp,%r9d
12028 cmpq $(IA32_NR_syscalls-1),%rax
12029 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
12030 +
12031 + pax_erase_kstack
12032 +
12033 jmp cstar_do_call
12034 END(ia32_cstar_target)
12035
12036 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
12037 CFI_REL_OFFSET rip,RIP-RIP
12038 PARAVIRT_ADJUST_EXCEPTION_FRAME
12039 SWAPGS
12040 - /*
12041 - * No need to follow this irqs on/off section: the syscall
12042 - * disabled irqs and here we enable it straight after entry:
12043 - */
12044 - ENABLE_INTERRUPTS(CLBR_NONE)
12045 movl %eax,%eax
12046 pushq_cfi %rax
12047 cld
12048 /* note the registers are not zero extended to the sf.
12049 this could be a problem. */
12050 SAVE_ARGS 0,1,0
12051 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12052 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12053 + pax_enter_kernel_user
12054 +
12055 +#ifdef CONFIG_PAX_RANDKSTACK
12056 + pax_erase_kstack
12057 +#endif
12058 +
12059 + /*
12060 + * No need to follow this irqs on/off section: the syscall
12061 + * disabled irqs and here we enable it straight after entry:
12062 + */
12063 + ENABLE_INTERRUPTS(CLBR_NONE)
12064 + GET_THREAD_INFO(%r11)
12065 + orl $TS_COMPAT,TI_status(%r11)
12066 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12067 jnz ia32_tracesys
12068 cmpq $(IA32_NR_syscalls-1),%rax
12069 ja ia32_badsys
12070 @@ -442,6 +520,9 @@ ia32_tracesys:
12071 RESTORE_REST
12072 cmpq $(IA32_NR_syscalls-1),%rax
12073 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
12074 +
12075 + pax_erase_kstack
12076 +
12077 jmp ia32_do_call
12078 END(ia32_syscall)
12079
12080 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
12081 index d0b689b..6811ddc 100644
12082 --- a/arch/x86/ia32/sys_ia32.c
12083 +++ b/arch/x86/ia32/sys_ia32.c
12084 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
12085 */
12086 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
12087 {
12088 - typeof(ubuf->st_uid) uid = 0;
12089 - typeof(ubuf->st_gid) gid = 0;
12090 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
12091 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
12092 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
12093 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
12094 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
12095 @@ -303,7 +303,7 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12096 mm_segment_t old_fs = get_fs();
12097
12098 set_fs(KERNEL_DS);
12099 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
12100 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
12101 set_fs(old_fs);
12102 if (put_compat_timespec(&t, interval))
12103 return -EFAULT;
12104 @@ -313,13 +313,13 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12105 asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
12106 compat_size_t sigsetsize)
12107 {
12108 - sigset_t s;
12109 + sigset_t s = { };
12110 compat_sigset_t s32;
12111 int ret;
12112 mm_segment_t old_fs = get_fs();
12113
12114 set_fs(KERNEL_DS);
12115 - ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
12116 + ret = sys_rt_sigpending((sigset_t __force_user *)&s, sigsetsize);
12117 set_fs(old_fs);
12118 if (!ret) {
12119 switch (_NSIG_WORDS) {
12120 @@ -344,7 +344,7 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
12121 if (copy_siginfo_from_user32(&info, uinfo))
12122 return -EFAULT;
12123 set_fs(KERNEL_DS);
12124 - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
12125 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __force_user *)&info);
12126 set_fs(old_fs);
12127 return ret;
12128 }
12129 @@ -376,7 +376,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
12130 return -EFAULT;
12131
12132 set_fs(KERNEL_DS);
12133 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
12134 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
12135 count);
12136 set_fs(old_fs);
12137
12138 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
12139 index 372231c..a5aa1a1 100644
12140 --- a/arch/x86/include/asm/alternative-asm.h
12141 +++ b/arch/x86/include/asm/alternative-asm.h
12142 @@ -18,6 +18,45 @@
12143 .endm
12144 #endif
12145
12146 +#ifdef KERNEXEC_PLUGIN
12147 + .macro pax_force_retaddr_bts rip=0
12148 + btsq $63,\rip(%rsp)
12149 + .endm
12150 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
12151 + .macro pax_force_retaddr rip=0, reload=0
12152 + btsq $63,\rip(%rsp)
12153 + .endm
12154 + .macro pax_force_fptr ptr
12155 + btsq $63,\ptr
12156 + .endm
12157 + .macro pax_set_fptr_mask
12158 + .endm
12159 +#endif
12160 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
12161 + .macro pax_force_retaddr rip=0, reload=0
12162 + .if \reload
12163 + pax_set_fptr_mask
12164 + .endif
12165 + orq %r10,\rip(%rsp)
12166 + .endm
12167 + .macro pax_force_fptr ptr
12168 + orq %r10,\ptr
12169 + .endm
12170 + .macro pax_set_fptr_mask
12171 + movabs $0x8000000000000000,%r10
12172 + .endm
12173 +#endif
12174 +#else
12175 + .macro pax_force_retaddr rip=0, reload=0
12176 + .endm
12177 + .macro pax_force_fptr ptr
12178 + .endm
12179 + .macro pax_force_retaddr_bts rip=0
12180 + .endm
12181 + .macro pax_set_fptr_mask
12182 + .endm
12183 +#endif
12184 +
12185 .macro altinstruction_entry orig alt feature orig_len alt_len
12186 .long \orig - .
12187 .long \alt - .
12188 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
12189 index 58ed6d9..f1cbe58 100644
12190 --- a/arch/x86/include/asm/alternative.h
12191 +++ b/arch/x86/include/asm/alternative.h
12192 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12193 ".pushsection .discard,\"aw\",@progbits\n" \
12194 DISCARD_ENTRY(1) \
12195 ".popsection\n" \
12196 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12197 + ".pushsection .altinstr_replacement, \"a\"\n" \
12198 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
12199 ".popsection"
12200
12201 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12202 DISCARD_ENTRY(1) \
12203 DISCARD_ENTRY(2) \
12204 ".popsection\n" \
12205 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12206 + ".pushsection .altinstr_replacement, \"a\"\n" \
12207 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
12208 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
12209 ".popsection"
12210 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
12211 index 3388034..050f0b9 100644
12212 --- a/arch/x86/include/asm/apic.h
12213 +++ b/arch/x86/include/asm/apic.h
12214 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
12215
12216 #ifdef CONFIG_X86_LOCAL_APIC
12217
12218 -extern unsigned int apic_verbosity;
12219 +extern int apic_verbosity;
12220 extern int local_apic_timer_c2_ok;
12221
12222 extern int disable_apic;
12223 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
12224 index 20370c6..a2eb9b0 100644
12225 --- a/arch/x86/include/asm/apm.h
12226 +++ b/arch/x86/include/asm/apm.h
12227 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
12228 __asm__ __volatile__(APM_DO_ZERO_SEGS
12229 "pushl %%edi\n\t"
12230 "pushl %%ebp\n\t"
12231 - "lcall *%%cs:apm_bios_entry\n\t"
12232 + "lcall *%%ss:apm_bios_entry\n\t"
12233 "setc %%al\n\t"
12234 "popl %%ebp\n\t"
12235 "popl %%edi\n\t"
12236 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
12237 __asm__ __volatile__(APM_DO_ZERO_SEGS
12238 "pushl %%edi\n\t"
12239 "pushl %%ebp\n\t"
12240 - "lcall *%%cs:apm_bios_entry\n\t"
12241 + "lcall *%%ss:apm_bios_entry\n\t"
12242 "setc %%bl\n\t"
12243 "popl %%ebp\n\t"
12244 "popl %%edi\n\t"
12245 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
12246 index 722aa3b..3a0bb27 100644
12247 --- a/arch/x86/include/asm/atomic.h
12248 +++ b/arch/x86/include/asm/atomic.h
12249 @@ -22,7 +22,18 @@
12250 */
12251 static inline int atomic_read(const atomic_t *v)
12252 {
12253 - return (*(volatile int *)&(v)->counter);
12254 + return (*(volatile const int *)&(v)->counter);
12255 +}
12256 +
12257 +/**
12258 + * atomic_read_unchecked - read atomic variable
12259 + * @v: pointer of type atomic_unchecked_t
12260 + *
12261 + * Atomically reads the value of @v.
12262 + */
12263 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12264 +{
12265 + return (*(volatile const int *)&(v)->counter);
12266 }
12267
12268 /**
12269 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12270 }
12271
12272 /**
12273 + * atomic_set_unchecked - set atomic variable
12274 + * @v: pointer of type atomic_unchecked_t
12275 + * @i: required value
12276 + *
12277 + * Atomically sets the value of @v to @i.
12278 + */
12279 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12280 +{
12281 + v->counter = i;
12282 +}
12283 +
12284 +/**
12285 * atomic_add - add integer to atomic variable
12286 * @i: integer value to add
12287 * @v: pointer of type atomic_t
12288 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12289 */
12290 static inline void atomic_add(int i, atomic_t *v)
12291 {
12292 - asm volatile(LOCK_PREFIX "addl %1,%0"
12293 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12294 +
12295 +#ifdef CONFIG_PAX_REFCOUNT
12296 + "jno 0f\n"
12297 + LOCK_PREFIX "subl %1,%0\n"
12298 + "int $4\n0:\n"
12299 + _ASM_EXTABLE(0b, 0b)
12300 +#endif
12301 +
12302 + : "+m" (v->counter)
12303 + : "ir" (i));
12304 +}
12305 +
12306 +/**
12307 + * atomic_add_unchecked - add integer to atomic variable
12308 + * @i: integer value to add
12309 + * @v: pointer of type atomic_unchecked_t
12310 + *
12311 + * Atomically adds @i to @v.
12312 + */
12313 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12314 +{
12315 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12316 : "+m" (v->counter)
12317 : "ir" (i));
12318 }
12319 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12320 */
12321 static inline void atomic_sub(int i, atomic_t *v)
12322 {
12323 - asm volatile(LOCK_PREFIX "subl %1,%0"
12324 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12325 +
12326 +#ifdef CONFIG_PAX_REFCOUNT
12327 + "jno 0f\n"
12328 + LOCK_PREFIX "addl %1,%0\n"
12329 + "int $4\n0:\n"
12330 + _ASM_EXTABLE(0b, 0b)
12331 +#endif
12332 +
12333 + : "+m" (v->counter)
12334 + : "ir" (i));
12335 +}
12336 +
12337 +/**
12338 + * atomic_sub_unchecked - subtract integer from atomic variable
12339 + * @i: integer value to subtract
12340 + * @v: pointer of type atomic_unchecked_t
12341 + *
12342 + * Atomically subtracts @i from @v.
12343 + */
12344 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12345 +{
12346 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12347 : "+m" (v->counter)
12348 : "ir" (i));
12349 }
12350 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12351 {
12352 unsigned char c;
12353
12354 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12355 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12356 +
12357 +#ifdef CONFIG_PAX_REFCOUNT
12358 + "jno 0f\n"
12359 + LOCK_PREFIX "addl %2,%0\n"
12360 + "int $4\n0:\n"
12361 + _ASM_EXTABLE(0b, 0b)
12362 +#endif
12363 +
12364 + "sete %1\n"
12365 : "+m" (v->counter), "=qm" (c)
12366 : "ir" (i) : "memory");
12367 return c;
12368 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12369 */
12370 static inline void atomic_inc(atomic_t *v)
12371 {
12372 - asm volatile(LOCK_PREFIX "incl %0"
12373 + asm volatile(LOCK_PREFIX "incl %0\n"
12374 +
12375 +#ifdef CONFIG_PAX_REFCOUNT
12376 + "jno 0f\n"
12377 + LOCK_PREFIX "decl %0\n"
12378 + "int $4\n0:\n"
12379 + _ASM_EXTABLE(0b, 0b)
12380 +#endif
12381 +
12382 + : "+m" (v->counter));
12383 +}
12384 +
12385 +/**
12386 + * atomic_inc_unchecked - increment atomic variable
12387 + * @v: pointer of type atomic_unchecked_t
12388 + *
12389 + * Atomically increments @v by 1.
12390 + */
12391 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12392 +{
12393 + asm volatile(LOCK_PREFIX "incl %0\n"
12394 : "+m" (v->counter));
12395 }
12396
12397 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12398 */
12399 static inline void atomic_dec(atomic_t *v)
12400 {
12401 - asm volatile(LOCK_PREFIX "decl %0"
12402 + asm volatile(LOCK_PREFIX "decl %0\n"
12403 +
12404 +#ifdef CONFIG_PAX_REFCOUNT
12405 + "jno 0f\n"
12406 + LOCK_PREFIX "incl %0\n"
12407 + "int $4\n0:\n"
12408 + _ASM_EXTABLE(0b, 0b)
12409 +#endif
12410 +
12411 + : "+m" (v->counter));
12412 +}
12413 +
12414 +/**
12415 + * atomic_dec_unchecked - decrement atomic variable
12416 + * @v: pointer of type atomic_unchecked_t
12417 + *
12418 + * Atomically decrements @v by 1.
12419 + */
12420 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12421 +{
12422 + asm volatile(LOCK_PREFIX "decl %0\n"
12423 : "+m" (v->counter));
12424 }
12425
12426 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12427 {
12428 unsigned char c;
12429
12430 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12431 + asm volatile(LOCK_PREFIX "decl %0\n"
12432 +
12433 +#ifdef CONFIG_PAX_REFCOUNT
12434 + "jno 0f\n"
12435 + LOCK_PREFIX "incl %0\n"
12436 + "int $4\n0:\n"
12437 + _ASM_EXTABLE(0b, 0b)
12438 +#endif
12439 +
12440 + "sete %1\n"
12441 : "+m" (v->counter), "=qm" (c)
12442 : : "memory");
12443 return c != 0;
12444 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12445 {
12446 unsigned char c;
12447
12448 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12449 + asm volatile(LOCK_PREFIX "incl %0\n"
12450 +
12451 +#ifdef CONFIG_PAX_REFCOUNT
12452 + "jno 0f\n"
12453 + LOCK_PREFIX "decl %0\n"
12454 + "int $4\n0:\n"
12455 + _ASM_EXTABLE(0b, 0b)
12456 +#endif
12457 +
12458 + "sete %1\n"
12459 + : "+m" (v->counter), "=qm" (c)
12460 + : : "memory");
12461 + return c != 0;
12462 +}
12463 +
12464 +/**
12465 + * atomic_inc_and_test_unchecked - increment and test
12466 + * @v: pointer of type atomic_unchecked_t
12467 + *
12468 + * Atomically increments @v by 1
12469 + * and returns true if the result is zero, or false for all
12470 + * other cases.
12471 + */
12472 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12473 +{
12474 + unsigned char c;
12475 +
12476 + asm volatile(LOCK_PREFIX "incl %0\n"
12477 + "sete %1\n"
12478 : "+m" (v->counter), "=qm" (c)
12479 : : "memory");
12480 return c != 0;
12481 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12482 {
12483 unsigned char c;
12484
12485 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12486 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12487 +
12488 +#ifdef CONFIG_PAX_REFCOUNT
12489 + "jno 0f\n"
12490 + LOCK_PREFIX "subl %2,%0\n"
12491 + "int $4\n0:\n"
12492 + _ASM_EXTABLE(0b, 0b)
12493 +#endif
12494 +
12495 + "sets %1\n"
12496 : "+m" (v->counter), "=qm" (c)
12497 : "ir" (i) : "memory");
12498 return c;
12499 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12500 */
12501 static inline int atomic_add_return(int i, atomic_t *v)
12502 {
12503 + return i + xadd_check_overflow(&v->counter, i);
12504 +}
12505 +
12506 +/**
12507 + * atomic_add_return_unchecked - add integer and return
12508 + * @i: integer value to add
12509 + * @v: pointer of type atomic_unchecked_t
12510 + *
12511 + * Atomically adds @i to @v and returns @i + @v
12512 + */
12513 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12514 +{
12515 return i + xadd(&v->counter, i);
12516 }
12517
12518 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12519 }
12520
12521 #define atomic_inc_return(v) (atomic_add_return(1, v))
12522 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12523 +{
12524 + return atomic_add_return_unchecked(1, v);
12525 +}
12526 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12527
12528 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12529 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12530 return cmpxchg(&v->counter, old, new);
12531 }
12532
12533 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12534 +{
12535 + return cmpxchg(&v->counter, old, new);
12536 +}
12537 +
12538 static inline int atomic_xchg(atomic_t *v, int new)
12539 {
12540 return xchg(&v->counter, new);
12541 }
12542
12543 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12544 +{
12545 + return xchg(&v->counter, new);
12546 +}
12547 +
12548 /**
12549 * __atomic_add_unless - add unless the number is already a given value
12550 * @v: pointer of type atomic_t
12551 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12552 */
12553 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12554 {
12555 - int c, old;
12556 + int c, old, new;
12557 c = atomic_read(v);
12558 for (;;) {
12559 - if (unlikely(c == (u)))
12560 + if (unlikely(c == u))
12561 break;
12562 - old = atomic_cmpxchg((v), c, c + (a));
12563 +
12564 + asm volatile("addl %2,%0\n"
12565 +
12566 +#ifdef CONFIG_PAX_REFCOUNT
12567 + "jno 0f\n"
12568 + "subl %2,%0\n"
12569 + "int $4\n0:\n"
12570 + _ASM_EXTABLE(0b, 0b)
12571 +#endif
12572 +
12573 + : "=r" (new)
12574 + : "0" (c), "ir" (a));
12575 +
12576 + old = atomic_cmpxchg(v, c, new);
12577 if (likely(old == c))
12578 break;
12579 c = old;
12580 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12581 }
12582
12583 /**
12584 + * atomic_inc_not_zero_hint - increment if not null
12585 + * @v: pointer of type atomic_t
12586 + * @hint: probable value of the atomic before the increment
12587 + *
12588 + * This version of atomic_inc_not_zero() gives a hint of probable
12589 + * value of the atomic. This helps processor to not read the memory
12590 + * before doing the atomic read/modify/write cycle, lowering
12591 + * number of bus transactions on some arches.
12592 + *
12593 + * Returns: 0 if increment was not done, 1 otherwise.
12594 + */
12595 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12596 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12597 +{
12598 + int val, c = hint, new;
12599 +
12600 + /* sanity test, should be removed by compiler if hint is a constant */
12601 + if (!hint)
12602 + return __atomic_add_unless(v, 1, 0);
12603 +
12604 + do {
12605 + asm volatile("incl %0\n"
12606 +
12607 +#ifdef CONFIG_PAX_REFCOUNT
12608 + "jno 0f\n"
12609 + "decl %0\n"
12610 + "int $4\n0:\n"
12611 + _ASM_EXTABLE(0b, 0b)
12612 +#endif
12613 +
12614 + : "=r" (new)
12615 + : "0" (c));
12616 +
12617 + val = atomic_cmpxchg(v, c, new);
12618 + if (val == c)
12619 + return 1;
12620 + c = val;
12621 + } while (c);
12622 +
12623 + return 0;
12624 +}
12625 +
12626 +/**
12627 * atomic_inc_short - increment of a short integer
12628 * @v: pointer to type int
12629 *
12630 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12631 #endif
12632
12633 /* These are x86-specific, used by some header files */
12634 -#define atomic_clear_mask(mask, addr) \
12635 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12636 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12637 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12638 +{
12639 + asm volatile(LOCK_PREFIX "andl %1,%0"
12640 + : "+m" (v->counter)
12641 + : "r" (~(mask))
12642 + : "memory");
12643 +}
12644
12645 -#define atomic_set_mask(mask, addr) \
12646 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12647 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12648 - : "memory")
12649 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12650 +{
12651 + asm volatile(LOCK_PREFIX "andl %1,%0"
12652 + : "+m" (v->counter)
12653 + : "r" (~(mask))
12654 + : "memory");
12655 +}
12656 +
12657 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12658 +{
12659 + asm volatile(LOCK_PREFIX "orl %1,%0"
12660 + : "+m" (v->counter)
12661 + : "r" (mask)
12662 + : "memory");
12663 +}
12664 +
12665 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12666 +{
12667 + asm volatile(LOCK_PREFIX "orl %1,%0"
12668 + : "+m" (v->counter)
12669 + : "r" (mask)
12670 + : "memory");
12671 +}
12672
12673 /* Atomic operations are already serializing on x86 */
12674 #define smp_mb__before_atomic_dec() barrier()
12675 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12676 index b154de7..aadebd8 100644
12677 --- a/arch/x86/include/asm/atomic64_32.h
12678 +++ b/arch/x86/include/asm/atomic64_32.h
12679 @@ -12,6 +12,14 @@ typedef struct {
12680 u64 __aligned(8) counter;
12681 } atomic64_t;
12682
12683 +#ifdef CONFIG_PAX_REFCOUNT
12684 +typedef struct {
12685 + u64 __aligned(8) counter;
12686 +} atomic64_unchecked_t;
12687 +#else
12688 +typedef atomic64_t atomic64_unchecked_t;
12689 +#endif
12690 +
12691 #define ATOMIC64_INIT(val) { (val) }
12692
12693 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12694 @@ -37,21 +45,31 @@ typedef struct {
12695 ATOMIC64_DECL_ONE(sym##_386)
12696
12697 ATOMIC64_DECL_ONE(add_386);
12698 +ATOMIC64_DECL_ONE(add_unchecked_386);
12699 ATOMIC64_DECL_ONE(sub_386);
12700 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12701 ATOMIC64_DECL_ONE(inc_386);
12702 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12703 ATOMIC64_DECL_ONE(dec_386);
12704 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12705 #endif
12706
12707 #define alternative_atomic64(f, out, in...) \
12708 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12709
12710 ATOMIC64_DECL(read);
12711 +ATOMIC64_DECL(read_unchecked);
12712 ATOMIC64_DECL(set);
12713 +ATOMIC64_DECL(set_unchecked);
12714 ATOMIC64_DECL(xchg);
12715 ATOMIC64_DECL(add_return);
12716 +ATOMIC64_DECL(add_return_unchecked);
12717 ATOMIC64_DECL(sub_return);
12718 +ATOMIC64_DECL(sub_return_unchecked);
12719 ATOMIC64_DECL(inc_return);
12720 +ATOMIC64_DECL(inc_return_unchecked);
12721 ATOMIC64_DECL(dec_return);
12722 +ATOMIC64_DECL(dec_return_unchecked);
12723 ATOMIC64_DECL(dec_if_positive);
12724 ATOMIC64_DECL(inc_not_zero);
12725 ATOMIC64_DECL(add_unless);
12726 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12727 }
12728
12729 /**
12730 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12731 + * @p: pointer to type atomic64_unchecked_t
12732 + * @o: expected value
12733 + * @n: new value
12734 + *
12735 + * Atomically sets @v to @n if it was equal to @o and returns
12736 + * the old value.
12737 + */
12738 +
12739 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12740 +{
12741 + return cmpxchg64(&v->counter, o, n);
12742 +}
12743 +
12744 +/**
12745 * atomic64_xchg - xchg atomic64 variable
12746 * @v: pointer to type atomic64_t
12747 * @n: value to assign
12748 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12749 }
12750
12751 /**
12752 + * atomic64_set_unchecked - set atomic64 variable
12753 + * @v: pointer to type atomic64_unchecked_t
12754 + * @n: value to assign
12755 + *
12756 + * Atomically sets the value of @v to @n.
12757 + */
12758 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12759 +{
12760 + unsigned high = (unsigned)(i >> 32);
12761 + unsigned low = (unsigned)i;
12762 + alternative_atomic64(set, /* no output */,
12763 + "S" (v), "b" (low), "c" (high)
12764 + : "eax", "edx", "memory");
12765 +}
12766 +
12767 +/**
12768 * atomic64_read - read atomic64 variable
12769 * @v: pointer to type atomic64_t
12770 *
12771 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12772 }
12773
12774 /**
12775 + * atomic64_read_unchecked - read atomic64 variable
12776 + * @v: pointer to type atomic64_unchecked_t
12777 + *
12778 + * Atomically reads the value of @v and returns it.
12779 + */
12780 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12781 +{
12782 + long long r;
12783 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12784 + return r;
12785 + }
12786 +
12787 +/**
12788 * atomic64_add_return - add and return
12789 * @i: integer value to add
12790 * @v: pointer to type atomic64_t
12791 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12792 return i;
12793 }
12794
12795 +/**
12796 + * atomic64_add_return_unchecked - add and return
12797 + * @i: integer value to add
12798 + * @v: pointer to type atomic64_unchecked_t
12799 + *
12800 + * Atomically adds @i to @v and returns @i + *@v
12801 + */
12802 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12803 +{
12804 + alternative_atomic64(add_return_unchecked,
12805 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12806 + ASM_NO_INPUT_CLOBBER("memory"));
12807 + return i;
12808 +}
12809 +
12810 /*
12811 * Other variants with different arithmetic operators:
12812 */
12813 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12814 return a;
12815 }
12816
12817 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12818 +{
12819 + long long a;
12820 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12821 + "S" (v) : "memory", "ecx");
12822 + return a;
12823 +}
12824 +
12825 static inline long long atomic64_dec_return(atomic64_t *v)
12826 {
12827 long long a;
12828 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12829 }
12830
12831 /**
12832 + * atomic64_add_unchecked - add integer to atomic64 variable
12833 + * @i: integer value to add
12834 + * @v: pointer to type atomic64_unchecked_t
12835 + *
12836 + * Atomically adds @i to @v.
12837 + */
12838 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12839 +{
12840 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12841 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12842 + ASM_NO_INPUT_CLOBBER("memory"));
12843 + return i;
12844 +}
12845 +
12846 +/**
12847 * atomic64_sub - subtract the atomic64 variable
12848 * @i: integer value to subtract
12849 * @v: pointer to type atomic64_t
12850 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12851 index 0e1cbfc..5623683 100644
12852 --- a/arch/x86/include/asm/atomic64_64.h
12853 +++ b/arch/x86/include/asm/atomic64_64.h
12854 @@ -18,7 +18,19 @@
12855 */
12856 static inline long atomic64_read(const atomic64_t *v)
12857 {
12858 - return (*(volatile long *)&(v)->counter);
12859 + return (*(volatile const long *)&(v)->counter);
12860 +}
12861 +
12862 +/**
12863 + * atomic64_read_unchecked - read atomic64 variable
12864 + * @v: pointer of type atomic64_unchecked_t
12865 + *
12866 + * Atomically reads the value of @v.
12867 + * Doesn't imply a read memory barrier.
12868 + */
12869 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12870 +{
12871 + return (*(volatile const long *)&(v)->counter);
12872 }
12873
12874 /**
12875 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12876 }
12877
12878 /**
12879 + * atomic64_set_unchecked - set atomic64 variable
12880 + * @v: pointer to type atomic64_unchecked_t
12881 + * @i: required value
12882 + *
12883 + * Atomically sets the value of @v to @i.
12884 + */
12885 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12886 +{
12887 + v->counter = i;
12888 +}
12889 +
12890 +/**
12891 * atomic64_add - add integer to atomic64 variable
12892 * @i: integer value to add
12893 * @v: pointer to type atomic64_t
12894 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12895 */
12896 static inline void atomic64_add(long i, atomic64_t *v)
12897 {
12898 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12899 +
12900 +#ifdef CONFIG_PAX_REFCOUNT
12901 + "jno 0f\n"
12902 + LOCK_PREFIX "subq %1,%0\n"
12903 + "int $4\n0:\n"
12904 + _ASM_EXTABLE(0b, 0b)
12905 +#endif
12906 +
12907 + : "=m" (v->counter)
12908 + : "er" (i), "m" (v->counter));
12909 +}
12910 +
12911 +/**
12912 + * atomic64_add_unchecked - add integer to atomic64 variable
12913 + * @i: integer value to add
12914 + * @v: pointer to type atomic64_unchecked_t
12915 + *
12916 + * Atomically adds @i to @v.
12917 + */
12918 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12919 +{
12920 asm volatile(LOCK_PREFIX "addq %1,%0"
12921 : "=m" (v->counter)
12922 : "er" (i), "m" (v->counter));
12923 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12924 */
12925 static inline void atomic64_sub(long i, atomic64_t *v)
12926 {
12927 - asm volatile(LOCK_PREFIX "subq %1,%0"
12928 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12929 +
12930 +#ifdef CONFIG_PAX_REFCOUNT
12931 + "jno 0f\n"
12932 + LOCK_PREFIX "addq %1,%0\n"
12933 + "int $4\n0:\n"
12934 + _ASM_EXTABLE(0b, 0b)
12935 +#endif
12936 +
12937 + : "=m" (v->counter)
12938 + : "er" (i), "m" (v->counter));
12939 +}
12940 +
12941 +/**
12942 + * atomic64_sub_unchecked - subtract the atomic64 variable
12943 + * @i: integer value to subtract
12944 + * @v: pointer to type atomic64_unchecked_t
12945 + *
12946 + * Atomically subtracts @i from @v.
12947 + */
12948 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12949 +{
12950 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12951 : "=m" (v->counter)
12952 : "er" (i), "m" (v->counter));
12953 }
12954 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12955 {
12956 unsigned char c;
12957
12958 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12959 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12960 +
12961 +#ifdef CONFIG_PAX_REFCOUNT
12962 + "jno 0f\n"
12963 + LOCK_PREFIX "addq %2,%0\n"
12964 + "int $4\n0:\n"
12965 + _ASM_EXTABLE(0b, 0b)
12966 +#endif
12967 +
12968 + "sete %1\n"
12969 : "=m" (v->counter), "=qm" (c)
12970 : "er" (i), "m" (v->counter) : "memory");
12971 return c;
12972 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12973 */
12974 static inline void atomic64_inc(atomic64_t *v)
12975 {
12976 + asm volatile(LOCK_PREFIX "incq %0\n"
12977 +
12978 +#ifdef CONFIG_PAX_REFCOUNT
12979 + "jno 0f\n"
12980 + LOCK_PREFIX "decq %0\n"
12981 + "int $4\n0:\n"
12982 + _ASM_EXTABLE(0b, 0b)
12983 +#endif
12984 +
12985 + : "=m" (v->counter)
12986 + : "m" (v->counter));
12987 +}
12988 +
12989 +/**
12990 + * atomic64_inc_unchecked - increment atomic64 variable
12991 + * @v: pointer to type atomic64_unchecked_t
12992 + *
12993 + * Atomically increments @v by 1.
12994 + */
12995 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12996 +{
12997 asm volatile(LOCK_PREFIX "incq %0"
12998 : "=m" (v->counter)
12999 : "m" (v->counter));
13000 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
13001 */
13002 static inline void atomic64_dec(atomic64_t *v)
13003 {
13004 - asm volatile(LOCK_PREFIX "decq %0"
13005 + asm volatile(LOCK_PREFIX "decq %0\n"
13006 +
13007 +#ifdef CONFIG_PAX_REFCOUNT
13008 + "jno 0f\n"
13009 + LOCK_PREFIX "incq %0\n"
13010 + "int $4\n0:\n"
13011 + _ASM_EXTABLE(0b, 0b)
13012 +#endif
13013 +
13014 + : "=m" (v->counter)
13015 + : "m" (v->counter));
13016 +}
13017 +
13018 +/**
13019 + * atomic64_dec_unchecked - decrement atomic64 variable
13020 + * @v: pointer to type atomic64_t
13021 + *
13022 + * Atomically decrements @v by 1.
13023 + */
13024 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
13025 +{
13026 + asm volatile(LOCK_PREFIX "decq %0\n"
13027 : "=m" (v->counter)
13028 : "m" (v->counter));
13029 }
13030 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
13031 {
13032 unsigned char c;
13033
13034 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
13035 + asm volatile(LOCK_PREFIX "decq %0\n"
13036 +
13037 +#ifdef CONFIG_PAX_REFCOUNT
13038 + "jno 0f\n"
13039 + LOCK_PREFIX "incq %0\n"
13040 + "int $4\n0:\n"
13041 + _ASM_EXTABLE(0b, 0b)
13042 +#endif
13043 +
13044 + "sete %1\n"
13045 : "=m" (v->counter), "=qm" (c)
13046 : "m" (v->counter) : "memory");
13047 return c != 0;
13048 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
13049 {
13050 unsigned char c;
13051
13052 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
13053 + asm volatile(LOCK_PREFIX "incq %0\n"
13054 +
13055 +#ifdef CONFIG_PAX_REFCOUNT
13056 + "jno 0f\n"
13057 + LOCK_PREFIX "decq %0\n"
13058 + "int $4\n0:\n"
13059 + _ASM_EXTABLE(0b, 0b)
13060 +#endif
13061 +
13062 + "sete %1\n"
13063 : "=m" (v->counter), "=qm" (c)
13064 : "m" (v->counter) : "memory");
13065 return c != 0;
13066 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13067 {
13068 unsigned char c;
13069
13070 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
13071 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
13072 +
13073 +#ifdef CONFIG_PAX_REFCOUNT
13074 + "jno 0f\n"
13075 + LOCK_PREFIX "subq %2,%0\n"
13076 + "int $4\n0:\n"
13077 + _ASM_EXTABLE(0b, 0b)
13078 +#endif
13079 +
13080 + "sets %1\n"
13081 : "=m" (v->counter), "=qm" (c)
13082 : "er" (i), "m" (v->counter) : "memory");
13083 return c;
13084 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13085 */
13086 static inline long atomic64_add_return(long i, atomic64_t *v)
13087 {
13088 + return i + xadd_check_overflow(&v->counter, i);
13089 +}
13090 +
13091 +/**
13092 + * atomic64_add_return_unchecked - add and return
13093 + * @i: integer value to add
13094 + * @v: pointer to type atomic64_unchecked_t
13095 + *
13096 + * Atomically adds @i to @v and returns @i + @v
13097 + */
13098 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
13099 +{
13100 return i + xadd(&v->counter, i);
13101 }
13102
13103 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
13104 }
13105
13106 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
13107 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
13108 +{
13109 + return atomic64_add_return_unchecked(1, v);
13110 +}
13111 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
13112
13113 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13114 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13115 return cmpxchg(&v->counter, old, new);
13116 }
13117
13118 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
13119 +{
13120 + return cmpxchg(&v->counter, old, new);
13121 +}
13122 +
13123 static inline long atomic64_xchg(atomic64_t *v, long new)
13124 {
13125 return xchg(&v->counter, new);
13126 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
13127 */
13128 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
13129 {
13130 - long c, old;
13131 + long c, old, new;
13132 c = atomic64_read(v);
13133 for (;;) {
13134 - if (unlikely(c == (u)))
13135 + if (unlikely(c == u))
13136 break;
13137 - old = atomic64_cmpxchg((v), c, c + (a));
13138 +
13139 + asm volatile("add %2,%0\n"
13140 +
13141 +#ifdef CONFIG_PAX_REFCOUNT
13142 + "jno 0f\n"
13143 + "sub %2,%0\n"
13144 + "int $4\n0:\n"
13145 + _ASM_EXTABLE(0b, 0b)
13146 +#endif
13147 +
13148 + : "=r" (new)
13149 + : "0" (c), "ir" (a));
13150 +
13151 + old = atomic64_cmpxchg(v, c, new);
13152 if (likely(old == c))
13153 break;
13154 c = old;
13155 }
13156 - return c != (u);
13157 + return c != u;
13158 }
13159
13160 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
13161 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
13162 index 6dfd019..28e188d 100644
13163 --- a/arch/x86/include/asm/bitops.h
13164 +++ b/arch/x86/include/asm/bitops.h
13165 @@ -40,7 +40,7 @@
13166 * a mask operation on a byte.
13167 */
13168 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
13169 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
13170 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
13171 #define CONST_MASK(nr) (1 << ((nr) & 7))
13172
13173 /**
13174 @@ -486,7 +486,7 @@ static inline int fls(int x)
13175 * at position 64.
13176 */
13177 #ifdef CONFIG_X86_64
13178 -static __always_inline int fls64(__u64 x)
13179 +static __always_inline long fls64(__u64 x)
13180 {
13181 int bitpos = -1;
13182 /*
13183 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
13184 index 4fa687a..60f2d39 100644
13185 --- a/arch/x86/include/asm/boot.h
13186 +++ b/arch/x86/include/asm/boot.h
13187 @@ -6,10 +6,15 @@
13188 #include <uapi/asm/boot.h>
13189
13190 /* Physical address where kernel should be loaded. */
13191 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13192 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13193 + (CONFIG_PHYSICAL_ALIGN - 1)) \
13194 & ~(CONFIG_PHYSICAL_ALIGN - 1))
13195
13196 +#ifndef __ASSEMBLY__
13197 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
13198 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
13199 +#endif
13200 +
13201 /* Minimum kernel alignment, as a power of two */
13202 #ifdef CONFIG_X86_64
13203 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
13204 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
13205 index 48f99f1..d78ebf9 100644
13206 --- a/arch/x86/include/asm/cache.h
13207 +++ b/arch/x86/include/asm/cache.h
13208 @@ -5,12 +5,13 @@
13209
13210 /* L1 cache line size */
13211 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
13212 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
13213 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
13214
13215 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
13216 +#define __read_only __attribute__((__section__(".data..read_only")))
13217
13218 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
13219 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
13220 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
13221
13222 #ifdef CONFIG_X86_VSMP
13223 #ifdef CONFIG_SMP
13224 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
13225 index 9863ee3..4a1f8e1 100644
13226 --- a/arch/x86/include/asm/cacheflush.h
13227 +++ b/arch/x86/include/asm/cacheflush.h
13228 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
13229 unsigned long pg_flags = pg->flags & _PGMT_MASK;
13230
13231 if (pg_flags == _PGMT_DEFAULT)
13232 - return -1;
13233 + return ~0UL;
13234 else if (pg_flags == _PGMT_WC)
13235 return _PAGE_CACHE_WC;
13236 else if (pg_flags == _PGMT_UC_MINUS)
13237 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
13238 index 46fc474..b02b0f9 100644
13239 --- a/arch/x86/include/asm/checksum_32.h
13240 +++ b/arch/x86/include/asm/checksum_32.h
13241 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
13242 int len, __wsum sum,
13243 int *src_err_ptr, int *dst_err_ptr);
13244
13245 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
13246 + int len, __wsum sum,
13247 + int *src_err_ptr, int *dst_err_ptr);
13248 +
13249 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
13250 + int len, __wsum sum,
13251 + int *src_err_ptr, int *dst_err_ptr);
13252 +
13253 /*
13254 * Note: when you get a NULL pointer exception here this means someone
13255 * passed in an incorrect kernel address to one of these functions.
13256 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13257 int *err_ptr)
13258 {
13259 might_sleep();
13260 - return csum_partial_copy_generic((__force void *)src, dst,
13261 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13262 len, sum, err_ptr, NULL);
13263 }
13264
13265 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13266 {
13267 might_sleep();
13268 if (access_ok(VERIFY_WRITE, dst, len))
13269 - return csum_partial_copy_generic(src, (__force void *)dst,
13270 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13271 len, sum, NULL, err_ptr);
13272
13273 if (len)
13274 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13275 index 8d871ea..c1a0dc9 100644
13276 --- a/arch/x86/include/asm/cmpxchg.h
13277 +++ b/arch/x86/include/asm/cmpxchg.h
13278 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13279 __compiletime_error("Bad argument size for cmpxchg");
13280 extern void __xadd_wrong_size(void)
13281 __compiletime_error("Bad argument size for xadd");
13282 +extern void __xadd_check_overflow_wrong_size(void)
13283 + __compiletime_error("Bad argument size for xadd_check_overflow");
13284 extern void __add_wrong_size(void)
13285 __compiletime_error("Bad argument size for add");
13286 +extern void __add_check_overflow_wrong_size(void)
13287 + __compiletime_error("Bad argument size for add_check_overflow");
13288
13289 /*
13290 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13291 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13292 __ret; \
13293 })
13294
13295 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13296 + ({ \
13297 + __typeof__ (*(ptr)) __ret = (arg); \
13298 + switch (sizeof(*(ptr))) { \
13299 + case __X86_CASE_L: \
13300 + asm volatile (lock #op "l %0, %1\n" \
13301 + "jno 0f\n" \
13302 + "mov %0,%1\n" \
13303 + "int $4\n0:\n" \
13304 + _ASM_EXTABLE(0b, 0b) \
13305 + : "+r" (__ret), "+m" (*(ptr)) \
13306 + : : "memory", "cc"); \
13307 + break; \
13308 + case __X86_CASE_Q: \
13309 + asm volatile (lock #op "q %q0, %1\n" \
13310 + "jno 0f\n" \
13311 + "mov %0,%1\n" \
13312 + "int $4\n0:\n" \
13313 + _ASM_EXTABLE(0b, 0b) \
13314 + : "+r" (__ret), "+m" (*(ptr)) \
13315 + : : "memory", "cc"); \
13316 + break; \
13317 + default: \
13318 + __ ## op ## _check_overflow_wrong_size(); \
13319 + } \
13320 + __ret; \
13321 + })
13322 +
13323 /*
13324 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13325 * Since this is generally used to protect other memory information, we
13326 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13327 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13328 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13329
13330 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13331 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13332 +
13333 #define __add(ptr, inc, lock) \
13334 ({ \
13335 __typeof__ (*(ptr)) __ret = (inc); \
13336 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13337 index 59c6c40..5e0b22c 100644
13338 --- a/arch/x86/include/asm/compat.h
13339 +++ b/arch/x86/include/asm/compat.h
13340 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13341 typedef u32 compat_uint_t;
13342 typedef u32 compat_ulong_t;
13343 typedef u64 __attribute__((aligned(4))) compat_u64;
13344 -typedef u32 compat_uptr_t;
13345 +typedef u32 __user compat_uptr_t;
13346
13347 struct compat_timespec {
13348 compat_time_t tv_sec;
13349 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13350 index 2d9075e..b75a844 100644
13351 --- a/arch/x86/include/asm/cpufeature.h
13352 +++ b/arch/x86/include/asm/cpufeature.h
13353 @@ -206,7 +206,7 @@
13354 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13355 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13356 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13357 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13358 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13359 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13360 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13361 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13362 @@ -375,7 +375,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13363 ".section .discard,\"aw\",@progbits\n"
13364 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13365 ".previous\n"
13366 - ".section .altinstr_replacement,\"ax\"\n"
13367 + ".section .altinstr_replacement,\"a\"\n"
13368 "3: movb $1,%0\n"
13369 "4:\n"
13370 ".previous\n"
13371 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13372 index 8bf1c06..b6ae785 100644
13373 --- a/arch/x86/include/asm/desc.h
13374 +++ b/arch/x86/include/asm/desc.h
13375 @@ -4,6 +4,7 @@
13376 #include <asm/desc_defs.h>
13377 #include <asm/ldt.h>
13378 #include <asm/mmu.h>
13379 +#include <asm/pgtable.h>
13380
13381 #include <linux/smp.h>
13382 #include <linux/percpu.h>
13383 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13384
13385 desc->type = (info->read_exec_only ^ 1) << 1;
13386 desc->type |= info->contents << 2;
13387 + desc->type |= info->seg_not_present ^ 1;
13388
13389 desc->s = 1;
13390 desc->dpl = 0x3;
13391 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13392 }
13393
13394 extern struct desc_ptr idt_descr;
13395 -extern gate_desc idt_table[];
13396 extern struct desc_ptr nmi_idt_descr;
13397 -extern gate_desc nmi_idt_table[];
13398 -
13399 -struct gdt_page {
13400 - struct desc_struct gdt[GDT_ENTRIES];
13401 -} __attribute__((aligned(PAGE_SIZE)));
13402 -
13403 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13404 +extern gate_desc idt_table[256];
13405 +extern gate_desc nmi_idt_table[256];
13406
13407 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13408 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13409 {
13410 - return per_cpu(gdt_page, cpu).gdt;
13411 + return cpu_gdt_table[cpu];
13412 }
13413
13414 #ifdef CONFIG_X86_64
13415 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13416 unsigned long base, unsigned dpl, unsigned flags,
13417 unsigned short seg)
13418 {
13419 - gate->a = (seg << 16) | (base & 0xffff);
13420 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13421 + gate->gate.offset_low = base;
13422 + gate->gate.seg = seg;
13423 + gate->gate.reserved = 0;
13424 + gate->gate.type = type;
13425 + gate->gate.s = 0;
13426 + gate->gate.dpl = dpl;
13427 + gate->gate.p = 1;
13428 + gate->gate.offset_high = base >> 16;
13429 }
13430
13431 #endif
13432 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13433
13434 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13435 {
13436 + pax_open_kernel();
13437 memcpy(&idt[entry], gate, sizeof(*gate));
13438 + pax_close_kernel();
13439 }
13440
13441 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13442 {
13443 + pax_open_kernel();
13444 memcpy(&ldt[entry], desc, 8);
13445 + pax_close_kernel();
13446 }
13447
13448 static inline void
13449 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13450 default: size = sizeof(*gdt); break;
13451 }
13452
13453 + pax_open_kernel();
13454 memcpy(&gdt[entry], desc, size);
13455 + pax_close_kernel();
13456 }
13457
13458 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13459 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13460
13461 static inline void native_load_tr_desc(void)
13462 {
13463 + pax_open_kernel();
13464 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13465 + pax_close_kernel();
13466 }
13467
13468 static inline void native_load_gdt(const struct desc_ptr *dtr)
13469 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13470 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13471 unsigned int i;
13472
13473 + pax_open_kernel();
13474 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13475 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13476 + pax_close_kernel();
13477 }
13478
13479 #define _LDT_empty(info) \
13480 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13481 preempt_enable();
13482 }
13483
13484 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13485 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13486 {
13487 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13488 }
13489 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13490 }
13491
13492 #ifdef CONFIG_X86_64
13493 -static inline void set_nmi_gate(int gate, void *addr)
13494 +static inline void set_nmi_gate(int gate, const void *addr)
13495 {
13496 gate_desc s;
13497
13498 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13499 }
13500 #endif
13501
13502 -static inline void _set_gate(int gate, unsigned type, void *addr,
13503 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13504 unsigned dpl, unsigned ist, unsigned seg)
13505 {
13506 gate_desc s;
13507 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13508 * Pentium F0 0F bugfix can have resulted in the mapped
13509 * IDT being write-protected.
13510 */
13511 -static inline void set_intr_gate(unsigned int n, void *addr)
13512 +static inline void set_intr_gate(unsigned int n, const void *addr)
13513 {
13514 BUG_ON((unsigned)n > 0xFF);
13515 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13516 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13517 /*
13518 * This routine sets up an interrupt gate at directory privilege level 3.
13519 */
13520 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13521 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13522 {
13523 BUG_ON((unsigned)n > 0xFF);
13524 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13525 }
13526
13527 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13528 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13529 {
13530 BUG_ON((unsigned)n > 0xFF);
13531 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13532 }
13533
13534 -static inline void set_trap_gate(unsigned int n, void *addr)
13535 +static inline void set_trap_gate(unsigned int n, const void *addr)
13536 {
13537 BUG_ON((unsigned)n > 0xFF);
13538 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13539 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13540 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13541 {
13542 BUG_ON((unsigned)n > 0xFF);
13543 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13544 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13545 }
13546
13547 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13548 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13549 {
13550 BUG_ON((unsigned)n > 0xFF);
13551 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13552 }
13553
13554 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13555 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13556 {
13557 BUG_ON((unsigned)n > 0xFF);
13558 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13559 }
13560
13561 +#ifdef CONFIG_X86_32
13562 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13563 +{
13564 + struct desc_struct d;
13565 +
13566 + if (likely(limit))
13567 + limit = (limit - 1UL) >> PAGE_SHIFT;
13568 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13569 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13570 +}
13571 +#endif
13572 +
13573 #endif /* _ASM_X86_DESC_H */
13574 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13575 index 278441f..b95a174 100644
13576 --- a/arch/x86/include/asm/desc_defs.h
13577 +++ b/arch/x86/include/asm/desc_defs.h
13578 @@ -31,6 +31,12 @@ struct desc_struct {
13579 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13580 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13581 };
13582 + struct {
13583 + u16 offset_low;
13584 + u16 seg;
13585 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13586 + unsigned offset_high: 16;
13587 + } gate;
13588 };
13589 } __attribute__((packed));
13590
13591 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13592 index ced283a..ffe04cc 100644
13593 --- a/arch/x86/include/asm/div64.h
13594 +++ b/arch/x86/include/asm/div64.h
13595 @@ -39,7 +39,7 @@
13596 __mod; \
13597 })
13598
13599 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13600 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13601 {
13602 union {
13603 u64 v64;
13604 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13605 index 9c999c1..3860cb8 100644
13606 --- a/arch/x86/include/asm/elf.h
13607 +++ b/arch/x86/include/asm/elf.h
13608 @@ -243,7 +243,25 @@ extern int force_personality32;
13609 the loader. We need to make sure that it is out of the way of the program
13610 that it will "exec", and that there is sufficient room for the brk. */
13611
13612 +#ifdef CONFIG_PAX_SEGMEXEC
13613 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13614 +#else
13615 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13616 +#endif
13617 +
13618 +#ifdef CONFIG_PAX_ASLR
13619 +#ifdef CONFIG_X86_32
13620 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13621 +
13622 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13623 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13624 +#else
13625 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13626 +
13627 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13628 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13629 +#endif
13630 +#endif
13631
13632 /* This yields a mask that user programs can use to figure out what
13633 instruction set this CPU supports. This could be done in user space,
13634 @@ -296,16 +314,12 @@ do { \
13635
13636 #define ARCH_DLINFO \
13637 do { \
13638 - if (vdso_enabled) \
13639 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13640 - (unsigned long)current->mm->context.vdso); \
13641 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13642 } while (0)
13643
13644 #define ARCH_DLINFO_X32 \
13645 do { \
13646 - if (vdso_enabled) \
13647 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13648 - (unsigned long)current->mm->context.vdso); \
13649 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13650 } while (0)
13651
13652 #define AT_SYSINFO 32
13653 @@ -320,7 +334,7 @@ else \
13654
13655 #endif /* !CONFIG_X86_32 */
13656
13657 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13658 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13659
13660 #define VDSO_ENTRY \
13661 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13662 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13663 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13664 #define compat_arch_setup_additional_pages syscall32_setup_pages
13665
13666 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13667 -#define arch_randomize_brk arch_randomize_brk
13668 -
13669 /*
13670 * True on X86_32 or when emulating IA32 on X86_64
13671 */
13672 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13673 index 75ce3f4..882e801 100644
13674 --- a/arch/x86/include/asm/emergency-restart.h
13675 +++ b/arch/x86/include/asm/emergency-restart.h
13676 @@ -13,6 +13,6 @@ enum reboot_type {
13677
13678 extern enum reboot_type reboot_type;
13679
13680 -extern void machine_emergency_restart(void);
13681 +extern void machine_emergency_restart(void) __noreturn;
13682
13683 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13684 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13685 index 41ab26e..a88c9e6 100644
13686 --- a/arch/x86/include/asm/fpu-internal.h
13687 +++ b/arch/x86/include/asm/fpu-internal.h
13688 @@ -126,7 +126,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13689 ({ \
13690 int err; \
13691 asm volatile(ASM_STAC "\n" \
13692 - "1:" #insn "\n\t" \
13693 + "1:" \
13694 + __copyuser_seg \
13695 + #insn "\n\t" \
13696 "2: " ASM_CLAC "\n" \
13697 ".section .fixup,\"ax\"\n" \
13698 "3: movl $-1,%[err]\n" \
13699 @@ -299,7 +301,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13700 "emms\n\t" /* clear stack tags */
13701 "fildl %P[addr]", /* set F?P to defined value */
13702 X86_FEATURE_FXSAVE_LEAK,
13703 - [addr] "m" (tsk->thread.fpu.has_fpu));
13704 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13705
13706 return fpu_restore_checking(&tsk->thread.fpu);
13707 }
13708 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13709 index be27ba1..8f13ff9 100644
13710 --- a/arch/x86/include/asm/futex.h
13711 +++ b/arch/x86/include/asm/futex.h
13712 @@ -12,6 +12,7 @@
13713 #include <asm/smap.h>
13714
13715 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13716 + typecheck(u32 __user *, uaddr); \
13717 asm volatile("\t" ASM_STAC "\n" \
13718 "1:\t" insn "\n" \
13719 "2:\t" ASM_CLAC "\n" \
13720 @@ -20,15 +21,16 @@
13721 "\tjmp\t2b\n" \
13722 "\t.previous\n" \
13723 _ASM_EXTABLE(1b, 3b) \
13724 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13725 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13726 : "i" (-EFAULT), "0" (oparg), "1" (0))
13727
13728 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13729 + typecheck(u32 __user *, uaddr); \
13730 asm volatile("\t" ASM_STAC "\n" \
13731 "1:\tmovl %2, %0\n" \
13732 "\tmovl\t%0, %3\n" \
13733 "\t" insn "\n" \
13734 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13735 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13736 "\tjnz\t1b\n" \
13737 "3:\t" ASM_CLAC "\n" \
13738 "\t.section .fixup,\"ax\"\n" \
13739 @@ -38,7 +40,7 @@
13740 _ASM_EXTABLE(1b, 4b) \
13741 _ASM_EXTABLE(2b, 4b) \
13742 : "=&a" (oldval), "=&r" (ret), \
13743 - "+m" (*uaddr), "=&r" (tem) \
13744 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13745 : "r" (oparg), "i" (-EFAULT), "1" (0))
13746
13747 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13748 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13749
13750 switch (op) {
13751 case FUTEX_OP_SET:
13752 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13753 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13754 break;
13755 case FUTEX_OP_ADD:
13756 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13757 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13758 uaddr, oparg);
13759 break;
13760 case FUTEX_OP_OR:
13761 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13762 return -EFAULT;
13763
13764 asm volatile("\t" ASM_STAC "\n"
13765 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13766 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13767 "2:\t" ASM_CLAC "\n"
13768 "\t.section .fixup, \"ax\"\n"
13769 "3:\tmov %3, %0\n"
13770 "\tjmp 2b\n"
13771 "\t.previous\n"
13772 _ASM_EXTABLE(1b, 3b)
13773 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13774 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13775 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13776 : "memory"
13777 );
13778 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13779 index eb92a6e..b98b2f4 100644
13780 --- a/arch/x86/include/asm/hw_irq.h
13781 +++ b/arch/x86/include/asm/hw_irq.h
13782 @@ -136,8 +136,8 @@ extern void setup_ioapic_dest(void);
13783 extern void enable_IO_APIC(void);
13784
13785 /* Statistics */
13786 -extern atomic_t irq_err_count;
13787 -extern atomic_t irq_mis_count;
13788 +extern atomic_unchecked_t irq_err_count;
13789 +extern atomic_unchecked_t irq_mis_count;
13790
13791 /* EISA */
13792 extern void eisa_set_level_irq(unsigned int irq);
13793 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13794 index a203659..9889f1c 100644
13795 --- a/arch/x86/include/asm/i8259.h
13796 +++ b/arch/x86/include/asm/i8259.h
13797 @@ -62,7 +62,7 @@ struct legacy_pic {
13798 void (*init)(int auto_eoi);
13799 int (*irq_pending)(unsigned int irq);
13800 void (*make_irq)(unsigned int irq);
13801 -};
13802 +} __do_const;
13803
13804 extern struct legacy_pic *legacy_pic;
13805 extern struct legacy_pic null_legacy_pic;
13806 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13807 index d8e8eef..1765f78 100644
13808 --- a/arch/x86/include/asm/io.h
13809 +++ b/arch/x86/include/asm/io.h
13810 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13811 "m" (*(volatile type __force *)addr) barrier); }
13812
13813 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13814 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13815 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13816 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13817 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13818
13819 build_mmio_read(__readb, "b", unsigned char, "=q", )
13820 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13821 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13822 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13823 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13824
13825 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13826 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13827 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13828 return ioremap_nocache(offset, size);
13829 }
13830
13831 -extern void iounmap(volatile void __iomem *addr);
13832 +extern void iounmap(const volatile void __iomem *addr);
13833
13834 extern void set_iounmap_nonlazy(void);
13835
13836 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13837
13838 #include <linux/vmalloc.h>
13839
13840 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13841 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13842 +{
13843 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13844 +}
13845 +
13846 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13847 +{
13848 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13849 +}
13850 +
13851 /*
13852 * Convert a virtual cached pointer to an uncached pointer
13853 */
13854 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13855 index bba3cf8..06bc8da 100644
13856 --- a/arch/x86/include/asm/irqflags.h
13857 +++ b/arch/x86/include/asm/irqflags.h
13858 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13859 sti; \
13860 sysexit
13861
13862 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13863 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13864 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13865 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13866 +
13867 #else
13868 #define INTERRUPT_RETURN iret
13869 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13870 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13871 index d3ddd17..c9fb0cc 100644
13872 --- a/arch/x86/include/asm/kprobes.h
13873 +++ b/arch/x86/include/asm/kprobes.h
13874 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13875 #define RELATIVEJUMP_SIZE 5
13876 #define RELATIVECALL_OPCODE 0xe8
13877 #define RELATIVE_ADDR_SIZE 4
13878 -#define MAX_STACK_SIZE 64
13879 -#define MIN_STACK_SIZE(ADDR) \
13880 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13881 - THREAD_SIZE - (unsigned long)(ADDR))) \
13882 - ? (MAX_STACK_SIZE) \
13883 - : (((unsigned long)current_thread_info()) + \
13884 - THREAD_SIZE - (unsigned long)(ADDR)))
13885 +#define MAX_STACK_SIZE 64UL
13886 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13887
13888 #define flush_insn_slot(p) do { } while (0)
13889
13890 diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
13891 index dc87b65..85039f9 100644
13892 --- a/arch/x86/include/asm/kvm_host.h
13893 +++ b/arch/x86/include/asm/kvm_host.h
13894 @@ -419,8 +419,8 @@ struct kvm_vcpu_arch {
13895 gpa_t time;
13896 struct pvclock_vcpu_time_info hv_clock;
13897 unsigned int hw_tsc_khz;
13898 - unsigned int time_offset;
13899 - struct page *time_page;
13900 + struct gfn_to_hva_cache pv_time;
13901 + bool pv_time_enabled;
13902 /* set guest stopped flag in pvclock flags field */
13903 bool pvclock_set_guest_stopped_request;
13904
13905 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13906 index 2d89e39..baee879 100644
13907 --- a/arch/x86/include/asm/local.h
13908 +++ b/arch/x86/include/asm/local.h
13909 @@ -10,33 +10,97 @@ typedef struct {
13910 atomic_long_t a;
13911 } local_t;
13912
13913 +typedef struct {
13914 + atomic_long_unchecked_t a;
13915 +} local_unchecked_t;
13916 +
13917 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13918
13919 #define local_read(l) atomic_long_read(&(l)->a)
13920 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13921 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13922 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13923
13924 static inline void local_inc(local_t *l)
13925 {
13926 - asm volatile(_ASM_INC "%0"
13927 + asm volatile(_ASM_INC "%0\n"
13928 +
13929 +#ifdef CONFIG_PAX_REFCOUNT
13930 + "jno 0f\n"
13931 + _ASM_DEC "%0\n"
13932 + "int $4\n0:\n"
13933 + _ASM_EXTABLE(0b, 0b)
13934 +#endif
13935 +
13936 + : "+m" (l->a.counter));
13937 +}
13938 +
13939 +static inline void local_inc_unchecked(local_unchecked_t *l)
13940 +{
13941 + asm volatile(_ASM_INC "%0\n"
13942 : "+m" (l->a.counter));
13943 }
13944
13945 static inline void local_dec(local_t *l)
13946 {
13947 - asm volatile(_ASM_DEC "%0"
13948 + asm volatile(_ASM_DEC "%0\n"
13949 +
13950 +#ifdef CONFIG_PAX_REFCOUNT
13951 + "jno 0f\n"
13952 + _ASM_INC "%0\n"
13953 + "int $4\n0:\n"
13954 + _ASM_EXTABLE(0b, 0b)
13955 +#endif
13956 +
13957 + : "+m" (l->a.counter));
13958 +}
13959 +
13960 +static inline void local_dec_unchecked(local_unchecked_t *l)
13961 +{
13962 + asm volatile(_ASM_DEC "%0\n"
13963 : "+m" (l->a.counter));
13964 }
13965
13966 static inline void local_add(long i, local_t *l)
13967 {
13968 - asm volatile(_ASM_ADD "%1,%0"
13969 + asm volatile(_ASM_ADD "%1,%0\n"
13970 +
13971 +#ifdef CONFIG_PAX_REFCOUNT
13972 + "jno 0f\n"
13973 + _ASM_SUB "%1,%0\n"
13974 + "int $4\n0:\n"
13975 + _ASM_EXTABLE(0b, 0b)
13976 +#endif
13977 +
13978 + : "+m" (l->a.counter)
13979 + : "ir" (i));
13980 +}
13981 +
13982 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13983 +{
13984 + asm volatile(_ASM_ADD "%1,%0\n"
13985 : "+m" (l->a.counter)
13986 : "ir" (i));
13987 }
13988
13989 static inline void local_sub(long i, local_t *l)
13990 {
13991 - asm volatile(_ASM_SUB "%1,%0"
13992 + asm volatile(_ASM_SUB "%1,%0\n"
13993 +
13994 +#ifdef CONFIG_PAX_REFCOUNT
13995 + "jno 0f\n"
13996 + _ASM_ADD "%1,%0\n"
13997 + "int $4\n0:\n"
13998 + _ASM_EXTABLE(0b, 0b)
13999 +#endif
14000 +
14001 + : "+m" (l->a.counter)
14002 + : "ir" (i));
14003 +}
14004 +
14005 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
14006 +{
14007 + asm volatile(_ASM_SUB "%1,%0\n"
14008 : "+m" (l->a.counter)
14009 : "ir" (i));
14010 }
14011 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
14012 {
14013 unsigned char c;
14014
14015 - asm volatile(_ASM_SUB "%2,%0; sete %1"
14016 + asm volatile(_ASM_SUB "%2,%0\n"
14017 +
14018 +#ifdef CONFIG_PAX_REFCOUNT
14019 + "jno 0f\n"
14020 + _ASM_ADD "%2,%0\n"
14021 + "int $4\n0:\n"
14022 + _ASM_EXTABLE(0b, 0b)
14023 +#endif
14024 +
14025 + "sete %1\n"
14026 : "+m" (l->a.counter), "=qm" (c)
14027 : "ir" (i) : "memory");
14028 return c;
14029 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
14030 {
14031 unsigned char c;
14032
14033 - asm volatile(_ASM_DEC "%0; sete %1"
14034 + asm volatile(_ASM_DEC "%0\n"
14035 +
14036 +#ifdef CONFIG_PAX_REFCOUNT
14037 + "jno 0f\n"
14038 + _ASM_INC "%0\n"
14039 + "int $4\n0:\n"
14040 + _ASM_EXTABLE(0b, 0b)
14041 +#endif
14042 +
14043 + "sete %1\n"
14044 : "+m" (l->a.counter), "=qm" (c)
14045 : : "memory");
14046 return c != 0;
14047 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
14048 {
14049 unsigned char c;
14050
14051 - asm volatile(_ASM_INC "%0; sete %1"
14052 + asm volatile(_ASM_INC "%0\n"
14053 +
14054 +#ifdef CONFIG_PAX_REFCOUNT
14055 + "jno 0f\n"
14056 + _ASM_DEC "%0\n"
14057 + "int $4\n0:\n"
14058 + _ASM_EXTABLE(0b, 0b)
14059 +#endif
14060 +
14061 + "sete %1\n"
14062 : "+m" (l->a.counter), "=qm" (c)
14063 : : "memory");
14064 return c != 0;
14065 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
14066 {
14067 unsigned char c;
14068
14069 - asm volatile(_ASM_ADD "%2,%0; sets %1"
14070 + asm volatile(_ASM_ADD "%2,%0\n"
14071 +
14072 +#ifdef CONFIG_PAX_REFCOUNT
14073 + "jno 0f\n"
14074 + _ASM_SUB "%2,%0\n"
14075 + "int $4\n0:\n"
14076 + _ASM_EXTABLE(0b, 0b)
14077 +#endif
14078 +
14079 + "sets %1\n"
14080 : "+m" (l->a.counter), "=qm" (c)
14081 : "ir" (i) : "memory");
14082 return c;
14083 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
14084 static inline long local_add_return(long i, local_t *l)
14085 {
14086 long __i = i;
14087 + asm volatile(_ASM_XADD "%0, %1\n"
14088 +
14089 +#ifdef CONFIG_PAX_REFCOUNT
14090 + "jno 0f\n"
14091 + _ASM_MOV "%0,%1\n"
14092 + "int $4\n0:\n"
14093 + _ASM_EXTABLE(0b, 0b)
14094 +#endif
14095 +
14096 + : "+r" (i), "+m" (l->a.counter)
14097 + : : "memory");
14098 + return i + __i;
14099 +}
14100 +
14101 +/**
14102 + * local_add_return_unchecked - add and return
14103 + * @i: integer value to add
14104 + * @l: pointer to type local_unchecked_t
14105 + *
14106 + * Atomically adds @i to @l and returns @i + @l
14107 + */
14108 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
14109 +{
14110 + long __i = i;
14111 asm volatile(_ASM_XADD "%0, %1;"
14112 : "+r" (i), "+m" (l->a.counter)
14113 : : "memory");
14114 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
14115
14116 #define local_cmpxchg(l, o, n) \
14117 (cmpxchg_local(&((l)->a.counter), (o), (n)))
14118 +#define local_cmpxchg_unchecked(l, o, n) \
14119 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
14120 /* Always has a lock prefix */
14121 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
14122
14123 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
14124 new file mode 100644
14125 index 0000000..2bfd3ba
14126 --- /dev/null
14127 +++ b/arch/x86/include/asm/mman.h
14128 @@ -0,0 +1,15 @@
14129 +#ifndef _X86_MMAN_H
14130 +#define _X86_MMAN_H
14131 +
14132 +#include <uapi/asm/mman.h>
14133 +
14134 +#ifdef __KERNEL__
14135 +#ifndef __ASSEMBLY__
14136 +#ifdef CONFIG_X86_32
14137 +#define arch_mmap_check i386_mmap_check
14138 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
14139 +#endif
14140 +#endif
14141 +#endif
14142 +
14143 +#endif /* X86_MMAN_H */
14144 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
14145 index 5f55e69..e20bfb1 100644
14146 --- a/arch/x86/include/asm/mmu.h
14147 +++ b/arch/x86/include/asm/mmu.h
14148 @@ -9,7 +9,7 @@
14149 * we put the segment information here.
14150 */
14151 typedef struct {
14152 - void *ldt;
14153 + struct desc_struct *ldt;
14154 int size;
14155
14156 #ifdef CONFIG_X86_64
14157 @@ -18,7 +18,19 @@ typedef struct {
14158 #endif
14159
14160 struct mutex lock;
14161 - void *vdso;
14162 + unsigned long vdso;
14163 +
14164 +#ifdef CONFIG_X86_32
14165 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
14166 + unsigned long user_cs_base;
14167 + unsigned long user_cs_limit;
14168 +
14169 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14170 + cpumask_t cpu_user_cs_mask;
14171 +#endif
14172 +
14173 +#endif
14174 +#endif
14175 } mm_context_t;
14176
14177 #ifdef CONFIG_SMP
14178 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
14179 index cdbf367..adb37ac 100644
14180 --- a/arch/x86/include/asm/mmu_context.h
14181 +++ b/arch/x86/include/asm/mmu_context.h
14182 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
14183
14184 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
14185 {
14186 +
14187 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14188 + unsigned int i;
14189 + pgd_t *pgd;
14190 +
14191 + pax_open_kernel();
14192 + pgd = get_cpu_pgd(smp_processor_id());
14193 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
14194 + set_pgd_batched(pgd+i, native_make_pgd(0));
14195 + pax_close_kernel();
14196 +#endif
14197 +
14198 #ifdef CONFIG_SMP
14199 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
14200 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
14201 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14202 struct task_struct *tsk)
14203 {
14204 unsigned cpu = smp_processor_id();
14205 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14206 + int tlbstate = TLBSTATE_OK;
14207 +#endif
14208
14209 if (likely(prev != next)) {
14210 #ifdef CONFIG_SMP
14211 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14212 + tlbstate = this_cpu_read(cpu_tlbstate.state);
14213 +#endif
14214 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14215 this_cpu_write(cpu_tlbstate.active_mm, next);
14216 #endif
14217 cpumask_set_cpu(cpu, mm_cpumask(next));
14218
14219 /* Re-load page tables */
14220 +#ifdef CONFIG_PAX_PER_CPU_PGD
14221 + pax_open_kernel();
14222 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14223 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14224 + pax_close_kernel();
14225 + load_cr3(get_cpu_pgd(cpu));
14226 +#else
14227 load_cr3(next->pgd);
14228 +#endif
14229
14230 /* stop flush ipis for the previous mm */
14231 cpumask_clear_cpu(cpu, mm_cpumask(prev));
14232 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14233 */
14234 if (unlikely(prev->context.ldt != next->context.ldt))
14235 load_LDT_nolock(&next->context);
14236 - }
14237 +
14238 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14239 + if (!(__supported_pte_mask & _PAGE_NX)) {
14240 + smp_mb__before_clear_bit();
14241 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
14242 + smp_mb__after_clear_bit();
14243 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14244 + }
14245 +#endif
14246 +
14247 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14248 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
14249 + prev->context.user_cs_limit != next->context.user_cs_limit))
14250 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14251 #ifdef CONFIG_SMP
14252 + else if (unlikely(tlbstate != TLBSTATE_OK))
14253 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14254 +#endif
14255 +#endif
14256 +
14257 + }
14258 else {
14259 +
14260 +#ifdef CONFIG_PAX_PER_CPU_PGD
14261 + pax_open_kernel();
14262 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14263 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14264 + pax_close_kernel();
14265 + load_cr3(get_cpu_pgd(cpu));
14266 +#endif
14267 +
14268 +#ifdef CONFIG_SMP
14269 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14270 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14271
14272 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14273 * tlb flush IPI delivery. We must reload CR3
14274 * to make sure to use no freed page tables.
14275 */
14276 +
14277 +#ifndef CONFIG_PAX_PER_CPU_PGD
14278 load_cr3(next->pgd);
14279 +#endif
14280 +
14281 load_LDT_nolock(&next->context);
14282 +
14283 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14284 + if (!(__supported_pte_mask & _PAGE_NX))
14285 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14286 +#endif
14287 +
14288 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14289 +#ifdef CONFIG_PAX_PAGEEXEC
14290 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14291 +#endif
14292 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14293 +#endif
14294 +
14295 }
14296 +#endif
14297 }
14298 -#endif
14299 }
14300
14301 #define activate_mm(prev, next) \
14302 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14303 index e3b7819..b257c64 100644
14304 --- a/arch/x86/include/asm/module.h
14305 +++ b/arch/x86/include/asm/module.h
14306 @@ -5,6 +5,7 @@
14307
14308 #ifdef CONFIG_X86_64
14309 /* X86_64 does not define MODULE_PROC_FAMILY */
14310 +#define MODULE_PROC_FAMILY ""
14311 #elif defined CONFIG_M486
14312 #define MODULE_PROC_FAMILY "486 "
14313 #elif defined CONFIG_M586
14314 @@ -57,8 +58,20 @@
14315 #error unknown processor family
14316 #endif
14317
14318 -#ifdef CONFIG_X86_32
14319 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14320 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14321 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14322 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14323 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14324 +#else
14325 +#define MODULE_PAX_KERNEXEC ""
14326 #endif
14327
14328 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14329 +#define MODULE_PAX_UDEREF "UDEREF "
14330 +#else
14331 +#define MODULE_PAX_UDEREF ""
14332 +#endif
14333 +
14334 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14335 +
14336 #endif /* _ASM_X86_MODULE_H */
14337 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14338 index c0fa356..07a498a 100644
14339 --- a/arch/x86/include/asm/nmi.h
14340 +++ b/arch/x86/include/asm/nmi.h
14341 @@ -42,11 +42,11 @@ struct nmiaction {
14342 nmi_handler_t handler;
14343 unsigned long flags;
14344 const char *name;
14345 -};
14346 +} __do_const;
14347
14348 #define register_nmi_handler(t, fn, fg, n, init...) \
14349 ({ \
14350 - static struct nmiaction init fn##_na = { \
14351 + static const struct nmiaction init fn##_na = { \
14352 .handler = (fn), \
14353 .name = (n), \
14354 .flags = (fg), \
14355 @@ -54,7 +54,7 @@ struct nmiaction {
14356 __register_nmi_handler((t), &fn##_na); \
14357 })
14358
14359 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14360 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14361
14362 void unregister_nmi_handler(unsigned int, const char *);
14363
14364 diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
14365 index 320f7bb..e89f8f8 100644
14366 --- a/arch/x86/include/asm/page_64_types.h
14367 +++ b/arch/x86/include/asm/page_64_types.h
14368 @@ -56,7 +56,7 @@ void copy_page(void *to, void *from);
14369
14370 /* duplicated to the one in bootmem.h */
14371 extern unsigned long max_pfn;
14372 -extern unsigned long phys_base;
14373 +extern const unsigned long phys_base;
14374
14375 extern unsigned long __phys_addr(unsigned long);
14376 #define __phys_reloc_hide(x) (x)
14377 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14378 index 5edd174..c395822 100644
14379 --- a/arch/x86/include/asm/paravirt.h
14380 +++ b/arch/x86/include/asm/paravirt.h
14381 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14382 return (pmd_t) { ret };
14383 }
14384
14385 -static inline pmdval_t pmd_val(pmd_t pmd)
14386 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14387 {
14388 pmdval_t ret;
14389
14390 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14391 val);
14392 }
14393
14394 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14395 +{
14396 + pgdval_t val = native_pgd_val(pgd);
14397 +
14398 + if (sizeof(pgdval_t) > sizeof(long))
14399 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14400 + val, (u64)val >> 32);
14401 + else
14402 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14403 + val);
14404 +}
14405 +
14406 static inline void pgd_clear(pgd_t *pgdp)
14407 {
14408 set_pgd(pgdp, __pgd(0));
14409 @@ -711,6 +723,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14410 pv_mmu_ops.set_fixmap(idx, phys, flags);
14411 }
14412
14413 +#ifdef CONFIG_PAX_KERNEXEC
14414 +static inline unsigned long pax_open_kernel(void)
14415 +{
14416 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14417 +}
14418 +
14419 +static inline unsigned long pax_close_kernel(void)
14420 +{
14421 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14422 +}
14423 +#else
14424 +static inline unsigned long pax_open_kernel(void) { return 0; }
14425 +static inline unsigned long pax_close_kernel(void) { return 0; }
14426 +#endif
14427 +
14428 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14429
14430 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14431 @@ -927,7 +954,7 @@ extern void default_banner(void);
14432
14433 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14434 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14435 -#define PARA_INDIRECT(addr) *%cs:addr
14436 +#define PARA_INDIRECT(addr) *%ss:addr
14437 #endif
14438
14439 #define INTERRUPT_RETURN \
14440 @@ -1002,6 +1029,21 @@ extern void default_banner(void);
14441 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14442 CLBR_NONE, \
14443 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14444 +
14445 +#define GET_CR0_INTO_RDI \
14446 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14447 + mov %rax,%rdi
14448 +
14449 +#define SET_RDI_INTO_CR0 \
14450 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14451 +
14452 +#define GET_CR3_INTO_RDI \
14453 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14454 + mov %rax,%rdi
14455 +
14456 +#define SET_RDI_INTO_CR3 \
14457 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14458 +
14459 #endif /* CONFIG_X86_32 */
14460
14461 #endif /* __ASSEMBLY__ */
14462 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14463 index 142236e..5446ffbc 100644
14464 --- a/arch/x86/include/asm/paravirt_types.h
14465 +++ b/arch/x86/include/asm/paravirt_types.h
14466 @@ -84,7 +84,7 @@ struct pv_init_ops {
14467 */
14468 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14469 unsigned long addr, unsigned len);
14470 -};
14471 +} __no_const;
14472
14473
14474 struct pv_lazy_ops {
14475 @@ -97,7 +97,7 @@ struct pv_time_ops {
14476 unsigned long long (*sched_clock)(void);
14477 unsigned long long (*steal_clock)(int cpu);
14478 unsigned long (*get_tsc_khz)(void);
14479 -};
14480 +} __no_const;
14481
14482 struct pv_cpu_ops {
14483 /* hooks for various privileged instructions */
14484 @@ -191,7 +191,7 @@ struct pv_cpu_ops {
14485
14486 void (*start_context_switch)(struct task_struct *prev);
14487 void (*end_context_switch)(struct task_struct *next);
14488 -};
14489 +} __no_const;
14490
14491 struct pv_irq_ops {
14492 /*
14493 @@ -222,7 +222,7 @@ struct pv_apic_ops {
14494 unsigned long start_eip,
14495 unsigned long start_esp);
14496 #endif
14497 -};
14498 +} __no_const;
14499
14500 struct pv_mmu_ops {
14501 unsigned long (*read_cr2)(void);
14502 @@ -312,6 +312,7 @@ struct pv_mmu_ops {
14503 struct paravirt_callee_save make_pud;
14504
14505 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14506 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14507 #endif /* PAGETABLE_LEVELS == 4 */
14508 #endif /* PAGETABLE_LEVELS >= 3 */
14509
14510 @@ -323,6 +324,12 @@ struct pv_mmu_ops {
14511 an mfn. We can tell which is which from the index. */
14512 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14513 phys_addr_t phys, pgprot_t flags);
14514 +
14515 +#ifdef CONFIG_PAX_KERNEXEC
14516 + unsigned long (*pax_open_kernel)(void);
14517 + unsigned long (*pax_close_kernel)(void);
14518 +#endif
14519 +
14520 };
14521
14522 struct arch_spinlock;
14523 @@ -333,7 +340,7 @@ struct pv_lock_ops {
14524 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14525 int (*spin_trylock)(struct arch_spinlock *lock);
14526 void (*spin_unlock)(struct arch_spinlock *lock);
14527 -};
14528 +} __no_const;
14529
14530 /* This contains all the paravirt structures: we get a convenient
14531 * number for each function using the offset which we use to indicate
14532 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14533 index b4389a4..7024269 100644
14534 --- a/arch/x86/include/asm/pgalloc.h
14535 +++ b/arch/x86/include/asm/pgalloc.h
14536 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14537 pmd_t *pmd, pte_t *pte)
14538 {
14539 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14540 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14541 +}
14542 +
14543 +static inline void pmd_populate_user(struct mm_struct *mm,
14544 + pmd_t *pmd, pte_t *pte)
14545 +{
14546 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14547 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14548 }
14549
14550 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14551
14552 #ifdef CONFIG_X86_PAE
14553 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14554 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14555 +{
14556 + pud_populate(mm, pudp, pmd);
14557 +}
14558 #else /* !CONFIG_X86_PAE */
14559 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14560 {
14561 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14562 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14563 }
14564 +
14565 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14566 +{
14567 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14568 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14569 +}
14570 #endif /* CONFIG_X86_PAE */
14571
14572 #if PAGETABLE_LEVELS > 3
14573 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14574 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14575 }
14576
14577 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14578 +{
14579 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14580 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14581 +}
14582 +
14583 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14584 {
14585 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14586 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14587 index f2b489c..4f7e2e5 100644
14588 --- a/arch/x86/include/asm/pgtable-2level.h
14589 +++ b/arch/x86/include/asm/pgtable-2level.h
14590 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14591
14592 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14593 {
14594 + pax_open_kernel();
14595 *pmdp = pmd;
14596 + pax_close_kernel();
14597 }
14598
14599 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14600 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14601 index 4cc9f2b..5fd9226 100644
14602 --- a/arch/x86/include/asm/pgtable-3level.h
14603 +++ b/arch/x86/include/asm/pgtable-3level.h
14604 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14605
14606 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14607 {
14608 + pax_open_kernel();
14609 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14610 + pax_close_kernel();
14611 }
14612
14613 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14614 {
14615 + pax_open_kernel();
14616 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14617 + pax_close_kernel();
14618 }
14619
14620 /*
14621 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14622 index 1c1a955..50f828c 100644
14623 --- a/arch/x86/include/asm/pgtable.h
14624 +++ b/arch/x86/include/asm/pgtable.h
14625 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14626
14627 #ifndef __PAGETABLE_PUD_FOLDED
14628 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14629 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14630 #define pgd_clear(pgd) native_pgd_clear(pgd)
14631 #endif
14632
14633 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14634
14635 #define arch_end_context_switch(prev) do {} while(0)
14636
14637 +#define pax_open_kernel() native_pax_open_kernel()
14638 +#define pax_close_kernel() native_pax_close_kernel()
14639 #endif /* CONFIG_PARAVIRT */
14640
14641 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14642 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14643 +
14644 +#ifdef CONFIG_PAX_KERNEXEC
14645 +static inline unsigned long native_pax_open_kernel(void)
14646 +{
14647 + unsigned long cr0;
14648 +
14649 + preempt_disable();
14650 + barrier();
14651 + cr0 = read_cr0() ^ X86_CR0_WP;
14652 + BUG_ON(cr0 & X86_CR0_WP);
14653 + write_cr0(cr0);
14654 + return cr0 ^ X86_CR0_WP;
14655 +}
14656 +
14657 +static inline unsigned long native_pax_close_kernel(void)
14658 +{
14659 + unsigned long cr0;
14660 +
14661 + cr0 = read_cr0() ^ X86_CR0_WP;
14662 + BUG_ON(!(cr0 & X86_CR0_WP));
14663 + write_cr0(cr0);
14664 + barrier();
14665 + preempt_enable_no_resched();
14666 + return cr0 ^ X86_CR0_WP;
14667 +}
14668 +#else
14669 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14670 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14671 +#endif
14672 +
14673 /*
14674 * The following only work if pte_present() is true.
14675 * Undefined behaviour if not..
14676 */
14677 +static inline int pte_user(pte_t pte)
14678 +{
14679 + return pte_val(pte) & _PAGE_USER;
14680 +}
14681 +
14682 static inline int pte_dirty(pte_t pte)
14683 {
14684 return pte_flags(pte) & _PAGE_DIRTY;
14685 @@ -200,9 +240,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14686 return pte_clear_flags(pte, _PAGE_RW);
14687 }
14688
14689 +static inline pte_t pte_mkread(pte_t pte)
14690 +{
14691 + return __pte(pte_val(pte) | _PAGE_USER);
14692 +}
14693 +
14694 static inline pte_t pte_mkexec(pte_t pte)
14695 {
14696 - return pte_clear_flags(pte, _PAGE_NX);
14697 +#ifdef CONFIG_X86_PAE
14698 + if (__supported_pte_mask & _PAGE_NX)
14699 + return pte_clear_flags(pte, _PAGE_NX);
14700 + else
14701 +#endif
14702 + return pte_set_flags(pte, _PAGE_USER);
14703 +}
14704 +
14705 +static inline pte_t pte_exprotect(pte_t pte)
14706 +{
14707 +#ifdef CONFIG_X86_PAE
14708 + if (__supported_pte_mask & _PAGE_NX)
14709 + return pte_set_flags(pte, _PAGE_NX);
14710 + else
14711 +#endif
14712 + return pte_clear_flags(pte, _PAGE_USER);
14713 }
14714
14715 static inline pte_t pte_mkdirty(pte_t pte)
14716 @@ -394,6 +454,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14717 #endif
14718
14719 #ifndef __ASSEMBLY__
14720 +
14721 +#ifdef CONFIG_PAX_PER_CPU_PGD
14722 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14723 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14724 +{
14725 + return cpu_pgd[cpu];
14726 +}
14727 +#endif
14728 +
14729 #include <linux/mm_types.h>
14730
14731 static inline int pte_none(pte_t pte)
14732 @@ -583,7 +652,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14733
14734 static inline int pgd_bad(pgd_t pgd)
14735 {
14736 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14737 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14738 }
14739
14740 static inline int pgd_none(pgd_t pgd)
14741 @@ -606,7 +675,12 @@ static inline int pgd_none(pgd_t pgd)
14742 * pgd_offset() returns a (pgd_t *)
14743 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14744 */
14745 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14746 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14747 +
14748 +#ifdef CONFIG_PAX_PER_CPU_PGD
14749 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14750 +#endif
14751 +
14752 /*
14753 * a shortcut which implies the use of the kernel's pgd, instead
14754 * of a process's
14755 @@ -617,6 +691,20 @@ static inline int pgd_none(pgd_t pgd)
14756 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14757 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14758
14759 +#ifdef CONFIG_X86_32
14760 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14761 +#else
14762 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14763 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14764 +
14765 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14766 +#define PAX_USER_SHADOW_BASE (_AC(1,UL) << TASK_SIZE_MAX_SHIFT)
14767 +#else
14768 +#define PAX_USER_SHADOW_BASE (_AC(0,UL))
14769 +#endif
14770 +
14771 +#endif
14772 +
14773 #ifndef __ASSEMBLY__
14774
14775 extern int direct_gbpages;
14776 @@ -781,11 +869,23 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14777 * dst and src can be on the same page, but the range must not overlap,
14778 * and must not cross a page boundary.
14779 */
14780 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14781 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14782 {
14783 - memcpy(dst, src, count * sizeof(pgd_t));
14784 + pax_open_kernel();
14785 + while (count--)
14786 + *dst++ = *src++;
14787 + pax_close_kernel();
14788 }
14789
14790 +#ifdef CONFIG_PAX_PER_CPU_PGD
14791 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14792 +#endif
14793 +
14794 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14795 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14796 +#else
14797 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14798 +#endif
14799
14800 #include <asm-generic/pgtable.h>
14801 #endif /* __ASSEMBLY__ */
14802 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14803 index 8faa215..a8a17ea 100644
14804 --- a/arch/x86/include/asm/pgtable_32.h
14805 +++ b/arch/x86/include/asm/pgtable_32.h
14806 @@ -25,9 +25,6 @@
14807 struct mm_struct;
14808 struct vm_area_struct;
14809
14810 -extern pgd_t swapper_pg_dir[1024];
14811 -extern pgd_t initial_page_table[1024];
14812 -
14813 static inline void pgtable_cache_init(void) { }
14814 static inline void check_pgt_cache(void) { }
14815 void paging_init(void);
14816 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14817 # include <asm/pgtable-2level.h>
14818 #endif
14819
14820 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14821 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14822 +#ifdef CONFIG_X86_PAE
14823 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14824 +#endif
14825 +
14826 #if defined(CONFIG_HIGHPTE)
14827 #define pte_offset_map(dir, address) \
14828 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14829 @@ -62,7 +65,9 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14830 /* Clear a kernel PTE and flush it from the TLB */
14831 #define kpte_clear_flush(ptep, vaddr) \
14832 do { \
14833 + pax_open_kernel(); \
14834 pte_clear(&init_mm, (vaddr), (ptep)); \
14835 + pax_close_kernel(); \
14836 __flush_tlb_one((vaddr)); \
14837 } while (0)
14838
14839 @@ -75,6 +80,9 @@ do { \
14840
14841 #endif /* !__ASSEMBLY__ */
14842
14843 +#define HAVE_ARCH_UNMAPPED_AREA
14844 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14845 +
14846 /*
14847 * kern_addr_valid() is (1) for FLATMEM and (0) for
14848 * SPARSEMEM and DISCONTIGMEM
14849 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14850 index ed5903b..c7fe163 100644
14851 --- a/arch/x86/include/asm/pgtable_32_types.h
14852 +++ b/arch/x86/include/asm/pgtable_32_types.h
14853 @@ -8,7 +8,7 @@
14854 */
14855 #ifdef CONFIG_X86_PAE
14856 # include <asm/pgtable-3level_types.h>
14857 -# define PMD_SIZE (1UL << PMD_SHIFT)
14858 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14859 # define PMD_MASK (~(PMD_SIZE - 1))
14860 #else
14861 # include <asm/pgtable-2level_types.h>
14862 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14863 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14864 #endif
14865
14866 +#ifdef CONFIG_PAX_KERNEXEC
14867 +#ifndef __ASSEMBLY__
14868 +extern unsigned char MODULES_EXEC_VADDR[];
14869 +extern unsigned char MODULES_EXEC_END[];
14870 +#endif
14871 +#include <asm/boot.h>
14872 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14873 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14874 +#else
14875 +#define ktla_ktva(addr) (addr)
14876 +#define ktva_ktla(addr) (addr)
14877 +#endif
14878 +
14879 #define MODULES_VADDR VMALLOC_START
14880 #define MODULES_END VMALLOC_END
14881 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14882 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14883 index 47356f9..deb94a2 100644
14884 --- a/arch/x86/include/asm/pgtable_64.h
14885 +++ b/arch/x86/include/asm/pgtable_64.h
14886 @@ -16,10 +16,14 @@
14887
14888 extern pud_t level3_kernel_pgt[512];
14889 extern pud_t level3_ident_pgt[512];
14890 +extern pud_t level3_vmalloc_start_pgt[512];
14891 +extern pud_t level3_vmalloc_end_pgt[512];
14892 +extern pud_t level3_vmemmap_pgt[512];
14893 +extern pud_t level2_vmemmap_pgt[512];
14894 extern pmd_t level2_kernel_pgt[512];
14895 extern pmd_t level2_fixmap_pgt[512];
14896 -extern pmd_t level2_ident_pgt[512];
14897 -extern pgd_t init_level4_pgt[];
14898 +extern pmd_t level2_ident_pgt[512*2];
14899 +extern pgd_t init_level4_pgt[512];
14900
14901 #define swapper_pg_dir init_level4_pgt
14902
14903 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14904
14905 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14906 {
14907 + pax_open_kernel();
14908 *pmdp = pmd;
14909 + pax_close_kernel();
14910 }
14911
14912 static inline void native_pmd_clear(pmd_t *pmd)
14913 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14914
14915 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14916 {
14917 + pax_open_kernel();
14918 *pudp = pud;
14919 + pax_close_kernel();
14920 }
14921
14922 static inline void native_pud_clear(pud_t *pud)
14923 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14924
14925 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14926 {
14927 + pax_open_kernel();
14928 + *pgdp = pgd;
14929 + pax_close_kernel();
14930 +}
14931 +
14932 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14933 +{
14934 *pgdp = pgd;
14935 }
14936
14937 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14938 index 766ea16..5b96cb3 100644
14939 --- a/arch/x86/include/asm/pgtable_64_types.h
14940 +++ b/arch/x86/include/asm/pgtable_64_types.h
14941 @@ -59,5 +59,10 @@ typedef struct { pteval_t pte; } pte_t;
14942 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14943 #define MODULES_END _AC(0xffffffffff000000, UL)
14944 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14945 +#define MODULES_EXEC_VADDR MODULES_VADDR
14946 +#define MODULES_EXEC_END MODULES_END
14947 +
14948 +#define ktla_ktva(addr) (addr)
14949 +#define ktva_ktla(addr) (addr)
14950
14951 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
14952 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14953 index 3c32db8..1ddccf5 100644
14954 --- a/arch/x86/include/asm/pgtable_types.h
14955 +++ b/arch/x86/include/asm/pgtable_types.h
14956 @@ -16,13 +16,12 @@
14957 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14958 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14959 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14960 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14961 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14962 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14963 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14964 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14965 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14966 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14967 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14968 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14969 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14970 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14971
14972 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14973 @@ -40,7 +39,6 @@
14974 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14975 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14976 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14977 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14978 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14979 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14980 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14981 @@ -57,8 +55,10 @@
14982
14983 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14984 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14985 -#else
14986 +#elif defined(CONFIG_KMEMCHECK)
14987 #define _PAGE_NX (_AT(pteval_t, 0))
14988 +#else
14989 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14990 #endif
14991
14992 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14993 @@ -116,6 +116,9 @@
14994 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14995 _PAGE_ACCESSED)
14996
14997 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14998 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14999 +
15000 #define __PAGE_KERNEL_EXEC \
15001 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
15002 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
15003 @@ -126,7 +129,7 @@
15004 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
15005 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
15006 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
15007 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
15008 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
15009 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
15010 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
15011 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
15012 @@ -188,8 +191,8 @@
15013 * bits are combined, this will alow user to access the high address mapped
15014 * VDSO in the presence of CONFIG_COMPAT_VDSO
15015 */
15016 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
15017 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
15018 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15019 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15020 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
15021 #endif
15022
15023 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
15024 {
15025 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
15026 }
15027 +#endif
15028
15029 +#if PAGETABLE_LEVELS == 3
15030 +#include <asm-generic/pgtable-nopud.h>
15031 +#endif
15032 +
15033 +#if PAGETABLE_LEVELS == 2
15034 +#include <asm-generic/pgtable-nopmd.h>
15035 +#endif
15036 +
15037 +#ifndef __ASSEMBLY__
15038 #if PAGETABLE_LEVELS > 3
15039 typedef struct { pudval_t pud; } pud_t;
15040
15041 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
15042 return pud.pud;
15043 }
15044 #else
15045 -#include <asm-generic/pgtable-nopud.h>
15046 -
15047 static inline pudval_t native_pud_val(pud_t pud)
15048 {
15049 return native_pgd_val(pud.pgd);
15050 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
15051 return pmd.pmd;
15052 }
15053 #else
15054 -#include <asm-generic/pgtable-nopmd.h>
15055 -
15056 static inline pmdval_t native_pmd_val(pmd_t pmd)
15057 {
15058 return native_pgd_val(pmd.pud.pgd);
15059 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
15060
15061 extern pteval_t __supported_pte_mask;
15062 extern void set_nx(void);
15063 -extern int nx_enabled;
15064
15065 #define pgprot_writecombine pgprot_writecombine
15066 extern pgprot_t pgprot_writecombine(pgprot_t prot);
15067 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
15068 index 888184b..a07ac89 100644
15069 --- a/arch/x86/include/asm/processor.h
15070 +++ b/arch/x86/include/asm/processor.h
15071 @@ -287,7 +287,7 @@ struct tss_struct {
15072
15073 } ____cacheline_aligned;
15074
15075 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
15076 +extern struct tss_struct init_tss[NR_CPUS];
15077
15078 /*
15079 * Save the original ist values for checking stack pointers during debugging
15080 @@ -827,11 +827,18 @@ static inline void spin_lock_prefetch(const void *x)
15081 */
15082 #define TASK_SIZE PAGE_OFFSET
15083 #define TASK_SIZE_MAX TASK_SIZE
15084 +
15085 +#ifdef CONFIG_PAX_SEGMEXEC
15086 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
15087 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
15088 +#else
15089 #define STACK_TOP TASK_SIZE
15090 -#define STACK_TOP_MAX STACK_TOP
15091 +#endif
15092 +
15093 +#define STACK_TOP_MAX TASK_SIZE
15094
15095 #define INIT_THREAD { \
15096 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15097 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15098 .vm86_info = NULL, \
15099 .sysenter_cs = __KERNEL_CS, \
15100 .io_bitmap_ptr = NULL, \
15101 @@ -845,7 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
15102 */
15103 #define INIT_TSS { \
15104 .x86_tss = { \
15105 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15106 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15107 .ss0 = __KERNEL_DS, \
15108 .ss1 = __KERNEL_CS, \
15109 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
15110 @@ -856,11 +863,7 @@ static inline void spin_lock_prefetch(const void *x)
15111 extern unsigned long thread_saved_pc(struct task_struct *tsk);
15112
15113 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
15114 -#define KSTK_TOP(info) \
15115 -({ \
15116 - unsigned long *__ptr = (unsigned long *)(info); \
15117 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
15118 -})
15119 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
15120
15121 /*
15122 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
15123 @@ -875,7 +878,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15124 #define task_pt_regs(task) \
15125 ({ \
15126 struct pt_regs *__regs__; \
15127 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
15128 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
15129 __regs__ - 1; \
15130 })
15131
15132 @@ -885,13 +888,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15133 /*
15134 * User space process size. 47bits minus one guard page.
15135 */
15136 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
15137 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
15138
15139 /* This decides where the kernel will search for a free chunk of vm
15140 * space during mmap's.
15141 */
15142 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
15143 - 0xc0000000 : 0xFFFFe000)
15144 + 0xc0000000 : 0xFFFFf000)
15145
15146 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
15147 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
15148 @@ -902,11 +905,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15149 #define STACK_TOP_MAX TASK_SIZE_MAX
15150
15151 #define INIT_THREAD { \
15152 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15153 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15154 }
15155
15156 #define INIT_TSS { \
15157 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15158 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15159 }
15160
15161 /*
15162 @@ -934,6 +937,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
15163 */
15164 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
15165
15166 +#ifdef CONFIG_PAX_SEGMEXEC
15167 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
15168 +#endif
15169 +
15170 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
15171
15172 /* Get/set a process' ability to use the timestamp counter instruction */
15173 @@ -994,12 +1001,12 @@ extern bool cpu_has_amd_erratum(const int *);
15174 #define cpu_has_amd_erratum(x) (false)
15175 #endif /* CONFIG_CPU_SUP_AMD */
15176
15177 -extern unsigned long arch_align_stack(unsigned long sp);
15178 +#define arch_align_stack(x) ((x) & ~0xfUL)
15179 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
15180
15181 void default_idle(void);
15182 bool set_pm_idle_to_default(void);
15183
15184 -void stop_this_cpu(void *dummy);
15185 +void stop_this_cpu(void *dummy) __noreturn;
15186
15187 #endif /* _ASM_X86_PROCESSOR_H */
15188 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
15189 index 942a086..6c26446 100644
15190 --- a/arch/x86/include/asm/ptrace.h
15191 +++ b/arch/x86/include/asm/ptrace.h
15192 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
15193 }
15194
15195 /*
15196 - * user_mode_vm(regs) determines whether a register set came from user mode.
15197 + * user_mode(regs) determines whether a register set came from user mode.
15198 * This is true if V8086 mode was enabled OR if the register set was from
15199 * protected mode with RPL-3 CS value. This tricky test checks that with
15200 * one comparison. Many places in the kernel can bypass this full check
15201 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
15202 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
15203 + * be used.
15204 */
15205 -static inline int user_mode(struct pt_regs *regs)
15206 +static inline int user_mode_novm(struct pt_regs *regs)
15207 {
15208 #ifdef CONFIG_X86_32
15209 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
15210 #else
15211 - return !!(regs->cs & 3);
15212 + return !!(regs->cs & SEGMENT_RPL_MASK);
15213 #endif
15214 }
15215
15216 -static inline int user_mode_vm(struct pt_regs *regs)
15217 +static inline int user_mode(struct pt_regs *regs)
15218 {
15219 #ifdef CONFIG_X86_32
15220 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
15221 USER_RPL;
15222 #else
15223 - return user_mode(regs);
15224 + return user_mode_novm(regs);
15225 #endif
15226 }
15227
15228 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
15229 #ifdef CONFIG_X86_64
15230 static inline bool user_64bit_mode(struct pt_regs *regs)
15231 {
15232 + unsigned long cs = regs->cs & 0xffff;
15233 #ifndef CONFIG_PARAVIRT
15234 /*
15235 * On non-paravirt systems, this is the only long mode CPL 3
15236 * selector. We do not allow long mode selectors in the LDT.
15237 */
15238 - return regs->cs == __USER_CS;
15239 + return cs == __USER_CS;
15240 #else
15241 /* Headers are too twisted for this to go in paravirt.h. */
15242 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15243 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15244 #endif
15245 }
15246
15247 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15248 * Traps from the kernel do not save sp and ss.
15249 * Use the helper function to retrieve sp.
15250 */
15251 - if (offset == offsetof(struct pt_regs, sp) &&
15252 - regs->cs == __KERNEL_CS)
15253 - return kernel_stack_pointer(regs);
15254 + if (offset == offsetof(struct pt_regs, sp)) {
15255 + unsigned long cs = regs->cs & 0xffff;
15256 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15257 + return kernel_stack_pointer(regs);
15258 + }
15259 #endif
15260 return *(unsigned long *)((unsigned long)regs + offset);
15261 }
15262 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15263 index fe1ec5b..dc5c3fe 100644
15264 --- a/arch/x86/include/asm/realmode.h
15265 +++ b/arch/x86/include/asm/realmode.h
15266 @@ -22,16 +22,14 @@ struct real_mode_header {
15267 #endif
15268 /* APM/BIOS reboot */
15269 u32 machine_real_restart_asm;
15270 -#ifdef CONFIG_X86_64
15271 u32 machine_real_restart_seg;
15272 -#endif
15273 };
15274
15275 /* This must match data at trampoline_32/64.S */
15276 struct trampoline_header {
15277 #ifdef CONFIG_X86_32
15278 u32 start;
15279 - u16 gdt_pad;
15280 + u16 boot_cs;
15281 u16 gdt_limit;
15282 u32 gdt_base;
15283 #else
15284 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15285 index a82c4f1..ac45053 100644
15286 --- a/arch/x86/include/asm/reboot.h
15287 +++ b/arch/x86/include/asm/reboot.h
15288 @@ -6,13 +6,13 @@
15289 struct pt_regs;
15290
15291 struct machine_ops {
15292 - void (*restart)(char *cmd);
15293 - void (*halt)(void);
15294 - void (*power_off)(void);
15295 + void (* __noreturn restart)(char *cmd);
15296 + void (* __noreturn halt)(void);
15297 + void (* __noreturn power_off)(void);
15298 void (*shutdown)(void);
15299 void (*crash_shutdown)(struct pt_regs *);
15300 - void (*emergency_restart)(void);
15301 -};
15302 + void (* __noreturn emergency_restart)(void);
15303 +} __no_const;
15304
15305 extern struct machine_ops machine_ops;
15306
15307 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15308 index 2dbe4a7..ce1db00 100644
15309 --- a/arch/x86/include/asm/rwsem.h
15310 +++ b/arch/x86/include/asm/rwsem.h
15311 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15312 {
15313 asm volatile("# beginning down_read\n\t"
15314 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15315 +
15316 +#ifdef CONFIG_PAX_REFCOUNT
15317 + "jno 0f\n"
15318 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15319 + "int $4\n0:\n"
15320 + _ASM_EXTABLE(0b, 0b)
15321 +#endif
15322 +
15323 /* adds 0x00000001 */
15324 " jns 1f\n"
15325 " call call_rwsem_down_read_failed\n"
15326 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15327 "1:\n\t"
15328 " mov %1,%2\n\t"
15329 " add %3,%2\n\t"
15330 +
15331 +#ifdef CONFIG_PAX_REFCOUNT
15332 + "jno 0f\n"
15333 + "sub %3,%2\n"
15334 + "int $4\n0:\n"
15335 + _ASM_EXTABLE(0b, 0b)
15336 +#endif
15337 +
15338 " jle 2f\n\t"
15339 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15340 " jnz 1b\n\t"
15341 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15342 long tmp;
15343 asm volatile("# beginning down_write\n\t"
15344 LOCK_PREFIX " xadd %1,(%2)\n\t"
15345 +
15346 +#ifdef CONFIG_PAX_REFCOUNT
15347 + "jno 0f\n"
15348 + "mov %1,(%2)\n"
15349 + "int $4\n0:\n"
15350 + _ASM_EXTABLE(0b, 0b)
15351 +#endif
15352 +
15353 /* adds 0xffff0001, returns the old value */
15354 " test %1,%1\n\t"
15355 /* was the count 0 before? */
15356 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15357 long tmp;
15358 asm volatile("# beginning __up_read\n\t"
15359 LOCK_PREFIX " xadd %1,(%2)\n\t"
15360 +
15361 +#ifdef CONFIG_PAX_REFCOUNT
15362 + "jno 0f\n"
15363 + "mov %1,(%2)\n"
15364 + "int $4\n0:\n"
15365 + _ASM_EXTABLE(0b, 0b)
15366 +#endif
15367 +
15368 /* subtracts 1, returns the old value */
15369 " jns 1f\n\t"
15370 " call call_rwsem_wake\n" /* expects old value in %edx */
15371 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15372 long tmp;
15373 asm volatile("# beginning __up_write\n\t"
15374 LOCK_PREFIX " xadd %1,(%2)\n\t"
15375 +
15376 +#ifdef CONFIG_PAX_REFCOUNT
15377 + "jno 0f\n"
15378 + "mov %1,(%2)\n"
15379 + "int $4\n0:\n"
15380 + _ASM_EXTABLE(0b, 0b)
15381 +#endif
15382 +
15383 /* subtracts 0xffff0001, returns the old value */
15384 " jns 1f\n\t"
15385 " call call_rwsem_wake\n" /* expects old value in %edx */
15386 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15387 {
15388 asm volatile("# beginning __downgrade_write\n\t"
15389 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15390 +
15391 +#ifdef CONFIG_PAX_REFCOUNT
15392 + "jno 0f\n"
15393 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15394 + "int $4\n0:\n"
15395 + _ASM_EXTABLE(0b, 0b)
15396 +#endif
15397 +
15398 /*
15399 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15400 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15401 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15402 */
15403 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15404 {
15405 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15406 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15407 +
15408 +#ifdef CONFIG_PAX_REFCOUNT
15409 + "jno 0f\n"
15410 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15411 + "int $4\n0:\n"
15412 + _ASM_EXTABLE(0b, 0b)
15413 +#endif
15414 +
15415 : "+m" (sem->count)
15416 : "er" (delta));
15417 }
15418 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15419 */
15420 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15421 {
15422 - return delta + xadd(&sem->count, delta);
15423 + return delta + xadd_check_overflow(&sem->count, delta);
15424 }
15425
15426 #endif /* __KERNEL__ */
15427 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15428 index c48a950..c6d7468 100644
15429 --- a/arch/x86/include/asm/segment.h
15430 +++ b/arch/x86/include/asm/segment.h
15431 @@ -64,10 +64,15 @@
15432 * 26 - ESPFIX small SS
15433 * 27 - per-cpu [ offset to per-cpu data area ]
15434 * 28 - stack_canary-20 [ for stack protector ]
15435 - * 29 - unused
15436 - * 30 - unused
15437 + * 29 - PCI BIOS CS
15438 + * 30 - PCI BIOS DS
15439 * 31 - TSS for double fault handler
15440 */
15441 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15442 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15443 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15444 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15445 +
15446 #define GDT_ENTRY_TLS_MIN 6
15447 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15448
15449 @@ -79,6 +84,8 @@
15450
15451 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15452
15453 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15454 +
15455 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15456
15457 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15458 @@ -104,6 +111,12 @@
15459 #define __KERNEL_STACK_CANARY 0
15460 #endif
15461
15462 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15463 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15464 +
15465 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15466 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15467 +
15468 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15469
15470 /*
15471 @@ -141,7 +154,7 @@
15472 */
15473
15474 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15475 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15476 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15477
15478
15479 #else
15480 @@ -165,6 +178,8 @@
15481 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15482 #define __USER32_DS __USER_DS
15483
15484 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15485 +
15486 #define GDT_ENTRY_TSS 8 /* needs two entries */
15487 #define GDT_ENTRY_LDT 10 /* needs two entries */
15488 #define GDT_ENTRY_TLS_MIN 12
15489 @@ -185,6 +200,7 @@
15490 #endif
15491
15492 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15493 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15494 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15495 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15496 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15497 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15498 {
15499 unsigned long __limit;
15500 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15501 - return __limit + 1;
15502 + return __limit;
15503 }
15504
15505 #endif /* !__ASSEMBLY__ */
15506 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15507 index b073aae..39f9bdd 100644
15508 --- a/arch/x86/include/asm/smp.h
15509 +++ b/arch/x86/include/asm/smp.h
15510 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15511 /* cpus sharing the last level cache: */
15512 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15513 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15514 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15515 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15516
15517 static inline struct cpumask *cpu_sibling_mask(int cpu)
15518 {
15519 @@ -79,7 +79,7 @@ struct smp_ops {
15520
15521 void (*send_call_func_ipi)(const struct cpumask *mask);
15522 void (*send_call_func_single_ipi)(int cpu);
15523 -};
15524 +} __no_const;
15525
15526 /* Globals due to paravirt */
15527 extern void set_cpu_sibling_map(int cpu);
15528 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15529 extern int safe_smp_processor_id(void);
15530
15531 #elif defined(CONFIG_X86_64_SMP)
15532 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15533 -
15534 -#define stack_smp_processor_id() \
15535 -({ \
15536 - struct thread_info *ti; \
15537 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15538 - ti->cpu; \
15539 -})
15540 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15541 +#define stack_smp_processor_id() raw_smp_processor_id()
15542 #define safe_smp_processor_id() smp_processor_id()
15543
15544 #endif
15545 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15546 index 33692ea..350a534 100644
15547 --- a/arch/x86/include/asm/spinlock.h
15548 +++ b/arch/x86/include/asm/spinlock.h
15549 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15550 static inline void arch_read_lock(arch_rwlock_t *rw)
15551 {
15552 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15553 +
15554 +#ifdef CONFIG_PAX_REFCOUNT
15555 + "jno 0f\n"
15556 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15557 + "int $4\n0:\n"
15558 + _ASM_EXTABLE(0b, 0b)
15559 +#endif
15560 +
15561 "jns 1f\n"
15562 "call __read_lock_failed\n\t"
15563 "1:\n"
15564 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15565 static inline void arch_write_lock(arch_rwlock_t *rw)
15566 {
15567 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15568 +
15569 +#ifdef CONFIG_PAX_REFCOUNT
15570 + "jno 0f\n"
15571 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15572 + "int $4\n0:\n"
15573 + _ASM_EXTABLE(0b, 0b)
15574 +#endif
15575 +
15576 "jz 1f\n"
15577 "call __write_lock_failed\n\t"
15578 "1:\n"
15579 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15580
15581 static inline void arch_read_unlock(arch_rwlock_t *rw)
15582 {
15583 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15584 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15585 +
15586 +#ifdef CONFIG_PAX_REFCOUNT
15587 + "jno 0f\n"
15588 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15589 + "int $4\n0:\n"
15590 + _ASM_EXTABLE(0b, 0b)
15591 +#endif
15592 +
15593 :"+m" (rw->lock) : : "memory");
15594 }
15595
15596 static inline void arch_write_unlock(arch_rwlock_t *rw)
15597 {
15598 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15599 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15600 +
15601 +#ifdef CONFIG_PAX_REFCOUNT
15602 + "jno 0f\n"
15603 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15604 + "int $4\n0:\n"
15605 + _ASM_EXTABLE(0b, 0b)
15606 +#endif
15607 +
15608 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15609 }
15610
15611 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15612 index 6a99859..03cb807 100644
15613 --- a/arch/x86/include/asm/stackprotector.h
15614 +++ b/arch/x86/include/asm/stackprotector.h
15615 @@ -47,7 +47,7 @@
15616 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15617 */
15618 #define GDT_STACK_CANARY_INIT \
15619 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15620 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15621
15622 /*
15623 * Initialize the stackprotector canary value.
15624 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15625
15626 static inline void load_stack_canary_segment(void)
15627 {
15628 -#ifdef CONFIG_X86_32
15629 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15630 asm volatile ("mov %0, %%gs" : : "r" (0));
15631 #endif
15632 }
15633 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15634 index 70bbe39..4ae2bd4 100644
15635 --- a/arch/x86/include/asm/stacktrace.h
15636 +++ b/arch/x86/include/asm/stacktrace.h
15637 @@ -11,28 +11,20 @@
15638
15639 extern int kstack_depth_to_print;
15640
15641 -struct thread_info;
15642 +struct task_struct;
15643 struct stacktrace_ops;
15644
15645 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15646 - unsigned long *stack,
15647 - unsigned long bp,
15648 - const struct stacktrace_ops *ops,
15649 - void *data,
15650 - unsigned long *end,
15651 - int *graph);
15652 +typedef unsigned long walk_stack_t(struct task_struct *task,
15653 + void *stack_start,
15654 + unsigned long *stack,
15655 + unsigned long bp,
15656 + const struct stacktrace_ops *ops,
15657 + void *data,
15658 + unsigned long *end,
15659 + int *graph);
15660
15661 -extern unsigned long
15662 -print_context_stack(struct thread_info *tinfo,
15663 - unsigned long *stack, unsigned long bp,
15664 - const struct stacktrace_ops *ops, void *data,
15665 - unsigned long *end, int *graph);
15666 -
15667 -extern unsigned long
15668 -print_context_stack_bp(struct thread_info *tinfo,
15669 - unsigned long *stack, unsigned long bp,
15670 - const struct stacktrace_ops *ops, void *data,
15671 - unsigned long *end, int *graph);
15672 +extern walk_stack_t print_context_stack;
15673 +extern walk_stack_t print_context_stack_bp;
15674
15675 /* Generic stack tracer with callbacks */
15676
15677 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15678 void (*address)(void *data, unsigned long address, int reliable);
15679 /* On negative return stop dumping */
15680 int (*stack)(void *data, char *name);
15681 - walk_stack_t walk_stack;
15682 + walk_stack_t *walk_stack;
15683 };
15684
15685 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15686 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15687 index 4ec45b3..a4f0a8a 100644
15688 --- a/arch/x86/include/asm/switch_to.h
15689 +++ b/arch/x86/include/asm/switch_to.h
15690 @@ -108,7 +108,7 @@ do { \
15691 "call __switch_to\n\t" \
15692 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15693 __switch_canary \
15694 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15695 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15696 "movq %%rax,%%rdi\n\t" \
15697 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15698 "jnz ret_from_fork\n\t" \
15699 @@ -119,7 +119,7 @@ do { \
15700 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15701 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15702 [_tif_fork] "i" (_TIF_FORK), \
15703 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15704 + [thread_info] "m" (current_tinfo), \
15705 [current_task] "m" (current_task) \
15706 __switch_canary_iparam \
15707 : "memory", "cc" __EXTRA_CLOBBER)
15708 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15709 index 2d946e6..e453ec4 100644
15710 --- a/arch/x86/include/asm/thread_info.h
15711 +++ b/arch/x86/include/asm/thread_info.h
15712 @@ -10,6 +10,7 @@
15713 #include <linux/compiler.h>
15714 #include <asm/page.h>
15715 #include <asm/types.h>
15716 +#include <asm/percpu.h>
15717
15718 /*
15719 * low level task data that entry.S needs immediate access to
15720 @@ -24,7 +25,6 @@ struct exec_domain;
15721 #include <linux/atomic.h>
15722
15723 struct thread_info {
15724 - struct task_struct *task; /* main task structure */
15725 struct exec_domain *exec_domain; /* execution domain */
15726 __u32 flags; /* low level flags */
15727 __u32 status; /* thread synchronous flags */
15728 @@ -34,19 +34,13 @@ struct thread_info {
15729 mm_segment_t addr_limit;
15730 struct restart_block restart_block;
15731 void __user *sysenter_return;
15732 -#ifdef CONFIG_X86_32
15733 - unsigned long previous_esp; /* ESP of the previous stack in
15734 - case of nested (IRQ) stacks
15735 - */
15736 - __u8 supervisor_stack[0];
15737 -#endif
15738 + unsigned long lowest_stack;
15739 unsigned int sig_on_uaccess_error:1;
15740 unsigned int uaccess_err:1; /* uaccess failed */
15741 };
15742
15743 -#define INIT_THREAD_INFO(tsk) \
15744 +#define INIT_THREAD_INFO \
15745 { \
15746 - .task = &tsk, \
15747 .exec_domain = &default_exec_domain, \
15748 .flags = 0, \
15749 .cpu = 0, \
15750 @@ -57,7 +51,7 @@ struct thread_info {
15751 }, \
15752 }
15753
15754 -#define init_thread_info (init_thread_union.thread_info)
15755 +#define init_thread_info (init_thread_union.stack)
15756 #define init_stack (init_thread_union.stack)
15757
15758 #else /* !__ASSEMBLY__ */
15759 @@ -98,6 +92,7 @@ struct thread_info {
15760 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15761 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15762 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15763 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15764
15765 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15766 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15767 @@ -122,17 +117,18 @@ struct thread_info {
15768 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15769 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15770 #define _TIF_X32 (1 << TIF_X32)
15771 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15772
15773 /* work to do in syscall_trace_enter() */
15774 #define _TIF_WORK_SYSCALL_ENTRY \
15775 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15776 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15777 - _TIF_NOHZ)
15778 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15779
15780 /* work to do in syscall_trace_leave() */
15781 #define _TIF_WORK_SYSCALL_EXIT \
15782 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15783 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15784 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15785
15786 /* work to do on interrupt/exception return */
15787 #define _TIF_WORK_MASK \
15788 @@ -143,7 +139,7 @@ struct thread_info {
15789 /* work to do on any return to user space */
15790 #define _TIF_ALLWORK_MASK \
15791 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15792 - _TIF_NOHZ)
15793 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15794
15795 /* Only used for 64 bit */
15796 #define _TIF_DO_NOTIFY_MASK \
15797 @@ -159,45 +155,40 @@ struct thread_info {
15798
15799 #define PREEMPT_ACTIVE 0x10000000
15800
15801 -#ifdef CONFIG_X86_32
15802 -
15803 -#define STACK_WARN (THREAD_SIZE/8)
15804 -/*
15805 - * macros/functions for gaining access to the thread information structure
15806 - *
15807 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15808 - */
15809 -#ifndef __ASSEMBLY__
15810 -
15811 -
15812 -/* how to get the current stack pointer from C */
15813 -register unsigned long current_stack_pointer asm("esp") __used;
15814 -
15815 -/* how to get the thread information struct from C */
15816 -static inline struct thread_info *current_thread_info(void)
15817 -{
15818 - return (struct thread_info *)
15819 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15820 -}
15821 -
15822 -#else /* !__ASSEMBLY__ */
15823 -
15824 +#ifdef __ASSEMBLY__
15825 /* how to get the thread information struct from ASM */
15826 #define GET_THREAD_INFO(reg) \
15827 - movl $-THREAD_SIZE, reg; \
15828 - andl %esp, reg
15829 + mov PER_CPU_VAR(current_tinfo), reg
15830
15831 /* use this one if reg already contains %esp */
15832 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15833 - andl $-THREAD_SIZE, reg
15834 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15835 +#else
15836 +/* how to get the thread information struct from C */
15837 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15838 +
15839 +static __always_inline struct thread_info *current_thread_info(void)
15840 +{
15841 + return this_cpu_read_stable(current_tinfo);
15842 +}
15843 +#endif
15844 +
15845 +#ifdef CONFIG_X86_32
15846 +
15847 +#define STACK_WARN (THREAD_SIZE/8)
15848 +/*
15849 + * macros/functions for gaining access to the thread information structure
15850 + *
15851 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15852 + */
15853 +#ifndef __ASSEMBLY__
15854 +
15855 +/* how to get the current stack pointer from C */
15856 +register unsigned long current_stack_pointer asm("esp") __used;
15857
15858 #endif
15859
15860 #else /* X86_32 */
15861
15862 -#include <asm/percpu.h>
15863 -#define KERNEL_STACK_OFFSET (5*8)
15864 -
15865 /*
15866 * macros/functions for gaining access to the thread information structure
15867 * preempt_count needs to be 1 initially, until the scheduler is functional.
15868 @@ -205,27 +196,8 @@ static inline struct thread_info *current_thread_info(void)
15869 #ifndef __ASSEMBLY__
15870 DECLARE_PER_CPU(unsigned long, kernel_stack);
15871
15872 -static inline struct thread_info *current_thread_info(void)
15873 -{
15874 - struct thread_info *ti;
15875 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15876 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15877 - return ti;
15878 -}
15879 -
15880 -#else /* !__ASSEMBLY__ */
15881 -
15882 -/* how to get the thread information struct from ASM */
15883 -#define GET_THREAD_INFO(reg) \
15884 - movq PER_CPU_VAR(kernel_stack),reg ; \
15885 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15886 -
15887 -/*
15888 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15889 - * a certain register (to be used in assembler memory operands).
15890 - */
15891 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15892 -
15893 +/* how to get the current stack pointer from C */
15894 +register unsigned long current_stack_pointer asm("rsp") __used;
15895 #endif
15896
15897 #endif /* !X86_32 */
15898 @@ -286,5 +258,12 @@ static inline bool is_ia32_task(void)
15899 extern void arch_task_cache_init(void);
15900 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15901 extern void arch_release_task_struct(struct task_struct *tsk);
15902 +
15903 +#define __HAVE_THREAD_FUNCTIONS
15904 +#define task_thread_info(task) (&(task)->tinfo)
15905 +#define task_stack_page(task) ((task)->stack)
15906 +#define setup_thread_stack(p, org) do {} while (0)
15907 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15908 +
15909 #endif
15910 #endif /* _ASM_X86_THREAD_INFO_H */
15911 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15912 index 1709801..0a60f2f 100644
15913 --- a/arch/x86/include/asm/uaccess.h
15914 +++ b/arch/x86/include/asm/uaccess.h
15915 @@ -7,6 +7,7 @@
15916 #include <linux/compiler.h>
15917 #include <linux/thread_info.h>
15918 #include <linux/string.h>
15919 +#include <linux/sched.h>
15920 #include <asm/asm.h>
15921 #include <asm/page.h>
15922 #include <asm/smap.h>
15923 @@ -29,7 +30,12 @@
15924
15925 #define get_ds() (KERNEL_DS)
15926 #define get_fs() (current_thread_info()->addr_limit)
15927 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15928 +void __set_fs(mm_segment_t x);
15929 +void set_fs(mm_segment_t x);
15930 +#else
15931 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15932 +#endif
15933
15934 #define segment_eq(a, b) ((a).seg == (b).seg)
15935
15936 @@ -77,8 +83,33 @@
15937 * checks that the pointer is in the user space range - after calling
15938 * this function, memory access functions may still return -EFAULT.
15939 */
15940 -#define access_ok(type, addr, size) \
15941 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15942 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15943 +#define access_ok(type, addr, size) \
15944 +({ \
15945 + long __size = size; \
15946 + unsigned long __addr = (unsigned long)addr; \
15947 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15948 + unsigned long __end_ao = __addr + __size - 1; \
15949 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15950 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15951 + while(__addr_ao <= __end_ao) { \
15952 + char __c_ao; \
15953 + __addr_ao += PAGE_SIZE; \
15954 + if (__size > PAGE_SIZE) \
15955 + cond_resched(); \
15956 + if (__get_user(__c_ao, (char __user *)__addr)) \
15957 + break; \
15958 + if (type != VERIFY_WRITE) { \
15959 + __addr = __addr_ao; \
15960 + continue; \
15961 + } \
15962 + if (__put_user(__c_ao, (char __user *)__addr)) \
15963 + break; \
15964 + __addr = __addr_ao; \
15965 + } \
15966 + } \
15967 + __ret_ao; \
15968 +})
15969
15970 /*
15971 * The exception table consists of pairs of addresses relative to the
15972 @@ -189,13 +220,21 @@ extern int __get_user_bad(void);
15973 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15974 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15975
15976 -
15977 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15978 +#define __copyuser_seg "gs;"
15979 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15980 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15981 +#else
15982 +#define __copyuser_seg
15983 +#define __COPYUSER_SET_ES
15984 +#define __COPYUSER_RESTORE_ES
15985 +#endif
15986
15987 #ifdef CONFIG_X86_32
15988 #define __put_user_asm_u64(x, addr, err, errret) \
15989 asm volatile(ASM_STAC "\n" \
15990 - "1: movl %%eax,0(%2)\n" \
15991 - "2: movl %%edx,4(%2)\n" \
15992 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15993 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15994 "3: " ASM_CLAC "\n" \
15995 ".section .fixup,\"ax\"\n" \
15996 "4: movl %3,%0\n" \
15997 @@ -208,8 +247,8 @@ extern int __get_user_bad(void);
15998
15999 #define __put_user_asm_ex_u64(x, addr) \
16000 asm volatile(ASM_STAC "\n" \
16001 - "1: movl %%eax,0(%1)\n" \
16002 - "2: movl %%edx,4(%1)\n" \
16003 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
16004 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
16005 "3: " ASM_CLAC "\n" \
16006 _ASM_EXTABLE_EX(1b, 2b) \
16007 _ASM_EXTABLE_EX(2b, 3b) \
16008 @@ -259,7 +298,7 @@ extern void __put_user_8(void);
16009 __typeof__(*(ptr)) __pu_val; \
16010 __chk_user_ptr(ptr); \
16011 might_fault(); \
16012 - __pu_val = x; \
16013 + __pu_val = (x); \
16014 switch (sizeof(*(ptr))) { \
16015 case 1: \
16016 __put_user_x(1, __pu_val, ptr, __ret_pu); \
16017 @@ -358,7 +397,7 @@ do { \
16018
16019 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16020 asm volatile(ASM_STAC "\n" \
16021 - "1: mov"itype" %2,%"rtype"1\n" \
16022 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
16023 "2: " ASM_CLAC "\n" \
16024 ".section .fixup,\"ax\"\n" \
16025 "3: mov %3,%0\n" \
16026 @@ -366,7 +405,7 @@ do { \
16027 " jmp 2b\n" \
16028 ".previous\n" \
16029 _ASM_EXTABLE(1b, 3b) \
16030 - : "=r" (err), ltype(x) \
16031 + : "=r" (err), ltype (x) \
16032 : "m" (__m(addr)), "i" (errret), "0" (err))
16033
16034 #define __get_user_size_ex(x, ptr, size) \
16035 @@ -391,7 +430,7 @@ do { \
16036 } while (0)
16037
16038 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
16039 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
16040 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
16041 "2:\n" \
16042 _ASM_EXTABLE_EX(1b, 2b) \
16043 : ltype(x) : "m" (__m(addr)))
16044 @@ -408,13 +447,24 @@ do { \
16045 int __gu_err; \
16046 unsigned long __gu_val; \
16047 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
16048 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
16049 + (x) = (__typeof__(*(ptr)))__gu_val; \
16050 __gu_err; \
16051 })
16052
16053 /* FIXME: this hack is definitely wrong -AK */
16054 struct __large_struct { unsigned long buf[100]; };
16055 -#define __m(x) (*(struct __large_struct __user *)(x))
16056 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16057 +#define ____m(x) \
16058 +({ \
16059 + unsigned long ____x = (unsigned long)(x); \
16060 + if (____x < PAX_USER_SHADOW_BASE) \
16061 + ____x += PAX_USER_SHADOW_BASE; \
16062 + (void __user *)____x; \
16063 +})
16064 +#else
16065 +#define ____m(x) (x)
16066 +#endif
16067 +#define __m(x) (*(struct __large_struct __user *)____m(x))
16068
16069 /*
16070 * Tell gcc we read from memory instead of writing: this is because
16071 @@ -423,7 +473,7 @@ struct __large_struct { unsigned long buf[100]; };
16072 */
16073 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16074 asm volatile(ASM_STAC "\n" \
16075 - "1: mov"itype" %"rtype"1,%2\n" \
16076 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
16077 "2: " ASM_CLAC "\n" \
16078 ".section .fixup,\"ax\"\n" \
16079 "3: mov %3,%0\n" \
16080 @@ -431,10 +481,10 @@ struct __large_struct { unsigned long buf[100]; };
16081 ".previous\n" \
16082 _ASM_EXTABLE(1b, 3b) \
16083 : "=r"(err) \
16084 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
16085 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
16086
16087 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
16088 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
16089 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
16090 "2:\n" \
16091 _ASM_EXTABLE_EX(1b, 2b) \
16092 : : ltype(x), "m" (__m(addr)))
16093 @@ -473,8 +523,12 @@ struct __large_struct { unsigned long buf[100]; };
16094 * On error, the variable @x is set to zero.
16095 */
16096
16097 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16098 +#define __get_user(x, ptr) get_user((x), (ptr))
16099 +#else
16100 #define __get_user(x, ptr) \
16101 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
16102 +#endif
16103
16104 /**
16105 * __put_user: - Write a simple value into user space, with less checking.
16106 @@ -496,8 +550,12 @@ struct __large_struct { unsigned long buf[100]; };
16107 * Returns zero on success, or -EFAULT on error.
16108 */
16109
16110 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16111 +#define __put_user(x, ptr) put_user((x), (ptr))
16112 +#else
16113 #define __put_user(x, ptr) \
16114 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
16115 +#endif
16116
16117 #define __get_user_unaligned __get_user
16118 #define __put_user_unaligned __put_user
16119 @@ -515,7 +573,7 @@ struct __large_struct { unsigned long buf[100]; };
16120 #define get_user_ex(x, ptr) do { \
16121 unsigned long __gue_val; \
16122 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
16123 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
16124 + (x) = (__typeof__(*(ptr)))__gue_val; \
16125 } while (0)
16126
16127 #define put_user_try uaccess_try
16128 @@ -532,8 +590,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
16129 extern __must_check long strlen_user(const char __user *str);
16130 extern __must_check long strnlen_user(const char __user *str, long n);
16131
16132 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
16133 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
16134 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16135 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16136
16137 /*
16138 * movsl can be slow when source and dest are not both 8-byte aligned
16139 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
16140 index 7f760a9..04b1c65 100644
16141 --- a/arch/x86/include/asm/uaccess_32.h
16142 +++ b/arch/x86/include/asm/uaccess_32.h
16143 @@ -11,15 +11,15 @@
16144 #include <asm/page.h>
16145
16146 unsigned long __must_check __copy_to_user_ll
16147 - (void __user *to, const void *from, unsigned long n);
16148 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
16149 unsigned long __must_check __copy_from_user_ll
16150 - (void *to, const void __user *from, unsigned long n);
16151 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16152 unsigned long __must_check __copy_from_user_ll_nozero
16153 - (void *to, const void __user *from, unsigned long n);
16154 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16155 unsigned long __must_check __copy_from_user_ll_nocache
16156 - (void *to, const void __user *from, unsigned long n);
16157 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16158 unsigned long __must_check __copy_from_user_ll_nocache_nozero
16159 - (void *to, const void __user *from, unsigned long n);
16160 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16161
16162 /**
16163 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
16164 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
16165 static __always_inline unsigned long __must_check
16166 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
16167 {
16168 + if ((long)n < 0)
16169 + return n;
16170 +
16171 + check_object_size(from, n, true);
16172 +
16173 if (__builtin_constant_p(n)) {
16174 unsigned long ret;
16175
16176 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
16177 __copy_to_user(void __user *to, const void *from, unsigned long n)
16178 {
16179 might_fault();
16180 +
16181 return __copy_to_user_inatomic(to, from, n);
16182 }
16183
16184 static __always_inline unsigned long
16185 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
16186 {
16187 + if ((long)n < 0)
16188 + return n;
16189 +
16190 /* Avoid zeroing the tail if the copy fails..
16191 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
16192 * but as the zeroing behaviour is only significant when n is not
16193 @@ -137,6 +146,12 @@ static __always_inline unsigned long
16194 __copy_from_user(void *to, const void __user *from, unsigned long n)
16195 {
16196 might_fault();
16197 +
16198 + if ((long)n < 0)
16199 + return n;
16200 +
16201 + check_object_size(to, n, false);
16202 +
16203 if (__builtin_constant_p(n)) {
16204 unsigned long ret;
16205
16206 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
16207 const void __user *from, unsigned long n)
16208 {
16209 might_fault();
16210 +
16211 + if ((long)n < 0)
16212 + return n;
16213 +
16214 if (__builtin_constant_p(n)) {
16215 unsigned long ret;
16216
16217 @@ -181,15 +200,19 @@ static __always_inline unsigned long
16218 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
16219 unsigned long n)
16220 {
16221 - return __copy_from_user_ll_nocache_nozero(to, from, n);
16222 + if ((long)n < 0)
16223 + return n;
16224 +
16225 + return __copy_from_user_ll_nocache_nozero(to, from, n);
16226 }
16227
16228 -unsigned long __must_check copy_to_user(void __user *to,
16229 - const void *from, unsigned long n);
16230 -unsigned long __must_check _copy_from_user(void *to,
16231 - const void __user *from,
16232 - unsigned long n);
16233 -
16234 +extern void copy_to_user_overflow(void)
16235 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16236 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16237 +#else
16238 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16239 +#endif
16240 +;
16241
16242 extern void copy_from_user_overflow(void)
16243 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16244 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16245 #endif
16246 ;
16247
16248 -static inline unsigned long __must_check copy_from_user(void *to,
16249 - const void __user *from,
16250 - unsigned long n)
16251 +/**
16252 + * copy_to_user: - Copy a block of data into user space.
16253 + * @to: Destination address, in user space.
16254 + * @from: Source address, in kernel space.
16255 + * @n: Number of bytes to copy.
16256 + *
16257 + * Context: User context only. This function may sleep.
16258 + *
16259 + * Copy data from kernel space to user space.
16260 + *
16261 + * Returns number of bytes that could not be copied.
16262 + * On success, this will be zero.
16263 + */
16264 +static inline unsigned long __must_check
16265 +copy_to_user(void __user *to, const void *from, unsigned long n)
16266 {
16267 - int sz = __compiletime_object_size(to);
16268 + size_t sz = __compiletime_object_size(from);
16269
16270 - if (likely(sz == -1 || sz >= n))
16271 - n = _copy_from_user(to, from, n);
16272 - else
16273 + if (unlikely(sz != (size_t)-1 && sz < n))
16274 + copy_to_user_overflow();
16275 + else if (access_ok(VERIFY_WRITE, to, n))
16276 + n = __copy_to_user(to, from, n);
16277 + return n;
16278 +}
16279 +
16280 +/**
16281 + * copy_from_user: - Copy a block of data from user space.
16282 + * @to: Destination address, in kernel space.
16283 + * @from: Source address, in user space.
16284 + * @n: Number of bytes to copy.
16285 + *
16286 + * Context: User context only. This function may sleep.
16287 + *
16288 + * Copy data from user space to kernel space.
16289 + *
16290 + * Returns number of bytes that could not be copied.
16291 + * On success, this will be zero.
16292 + *
16293 + * If some data could not be copied, this function will pad the copied
16294 + * data to the requested size using zero bytes.
16295 + */
16296 +static inline unsigned long __must_check
16297 +copy_from_user(void *to, const void __user *from, unsigned long n)
16298 +{
16299 + size_t sz = __compiletime_object_size(to);
16300 +
16301 + check_object_size(to, n, false);
16302 +
16303 + if (unlikely(sz != (size_t)-1 && sz < n))
16304 copy_from_user_overflow();
16305 -
16306 + else if (access_ok(VERIFY_READ, from, n))
16307 + n = __copy_from_user(to, from, n);
16308 + else if ((long)n > 0)
16309 + memset(to, 0, n);
16310 return n;
16311 }
16312
16313 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16314 index 142810c..1f2a0a7 100644
16315 --- a/arch/x86/include/asm/uaccess_64.h
16316 +++ b/arch/x86/include/asm/uaccess_64.h
16317 @@ -10,6 +10,9 @@
16318 #include <asm/alternative.h>
16319 #include <asm/cpufeature.h>
16320 #include <asm/page.h>
16321 +#include <asm/pgtable.h>
16322 +
16323 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16324
16325 /*
16326 * Copy To/From Userspace
16327 @@ -17,13 +20,13 @@
16328
16329 /* Handles exceptions in both to and from, but doesn't do access_ok */
16330 __must_check unsigned long
16331 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16332 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16333 __must_check unsigned long
16334 -copy_user_generic_string(void *to, const void *from, unsigned len);
16335 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16336 __must_check unsigned long
16337 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16338 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16339
16340 -static __always_inline __must_check unsigned long
16341 +static __always_inline __must_check __size_overflow(3) unsigned long
16342 copy_user_generic(void *to, const void *from, unsigned len)
16343 {
16344 unsigned ret;
16345 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16346 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16347 "=d" (len)),
16348 "1" (to), "2" (from), "3" (len)
16349 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16350 + : "memory", "rcx", "r8", "r9", "r11");
16351 return ret;
16352 }
16353
16354 +static __always_inline __must_check unsigned long
16355 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16356 +static __always_inline __must_check unsigned long
16357 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16358 __must_check unsigned long
16359 -_copy_to_user(void __user *to, const void *from, unsigned len);
16360 -__must_check unsigned long
16361 -_copy_from_user(void *to, const void __user *from, unsigned len);
16362 -__must_check unsigned long
16363 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16364 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16365 +
16366 +extern void copy_to_user_overflow(void)
16367 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16368 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16369 +#else
16370 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16371 +#endif
16372 +;
16373 +
16374 +extern void copy_from_user_overflow(void)
16375 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16376 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16377 +#else
16378 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16379 +#endif
16380 +;
16381
16382 static inline unsigned long __must_check copy_from_user(void *to,
16383 const void __user *from,
16384 unsigned long n)
16385 {
16386 - int sz = __compiletime_object_size(to);
16387 -
16388 might_fault();
16389 - if (likely(sz == -1 || sz >= n))
16390 - n = _copy_from_user(to, from, n);
16391 -#ifdef CONFIG_DEBUG_VM
16392 - else
16393 - WARN(1, "Buffer overflow detected!\n");
16394 -#endif
16395 +
16396 + check_object_size(to, n, false);
16397 +
16398 + if (access_ok(VERIFY_READ, from, n))
16399 + n = __copy_from_user(to, from, n);
16400 + else if (n < INT_MAX)
16401 + memset(to, 0, n);
16402 return n;
16403 }
16404
16405 static __always_inline __must_check
16406 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16407 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16408 {
16409 might_fault();
16410
16411 - return _copy_to_user(dst, src, size);
16412 + if (access_ok(VERIFY_WRITE, dst, size))
16413 + size = __copy_to_user(dst, src, size);
16414 + return size;
16415 }
16416
16417 static __always_inline __must_check
16418 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16419 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16420 {
16421 - int ret = 0;
16422 + size_t sz = __compiletime_object_size(dst);
16423 + unsigned ret = 0;
16424
16425 might_fault();
16426 +
16427 + if (size > INT_MAX)
16428 + return size;
16429 +
16430 + check_object_size(dst, size, false);
16431 +
16432 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16433 + if (!__access_ok(VERIFY_READ, src, size))
16434 + return size;
16435 +#endif
16436 +
16437 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16438 + copy_from_user_overflow();
16439 + return size;
16440 + }
16441 +
16442 if (!__builtin_constant_p(size))
16443 - return copy_user_generic(dst, (__force void *)src, size);
16444 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16445 switch (size) {
16446 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16447 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16448 ret, "b", "b", "=q", 1);
16449 return ret;
16450 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16451 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16452 ret, "w", "w", "=r", 2);
16453 return ret;
16454 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16455 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16456 ret, "l", "k", "=r", 4);
16457 return ret;
16458 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16459 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16460 ret, "q", "", "=r", 8);
16461 return ret;
16462 case 10:
16463 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16464 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16465 ret, "q", "", "=r", 10);
16466 if (unlikely(ret))
16467 return ret;
16468 __get_user_asm(*(u16 *)(8 + (char *)dst),
16469 - (u16 __user *)(8 + (char __user *)src),
16470 + (const u16 __user *)(8 + (const char __user *)src),
16471 ret, "w", "w", "=r", 2);
16472 return ret;
16473 case 16:
16474 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16475 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16476 ret, "q", "", "=r", 16);
16477 if (unlikely(ret))
16478 return ret;
16479 __get_user_asm(*(u64 *)(8 + (char *)dst),
16480 - (u64 __user *)(8 + (char __user *)src),
16481 + (const u64 __user *)(8 + (const char __user *)src),
16482 ret, "q", "", "=r", 8);
16483 return ret;
16484 default:
16485 - return copy_user_generic(dst, (__force void *)src, size);
16486 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16487 }
16488 }
16489
16490 static __always_inline __must_check
16491 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16492 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16493 {
16494 - int ret = 0;
16495 + size_t sz = __compiletime_object_size(src);
16496 + unsigned ret = 0;
16497
16498 might_fault();
16499 +
16500 + if (size > INT_MAX)
16501 + return size;
16502 +
16503 + check_object_size(src, size, true);
16504 +
16505 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16506 + if (!__access_ok(VERIFY_WRITE, dst, size))
16507 + return size;
16508 +#endif
16509 +
16510 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16511 + copy_to_user_overflow();
16512 + return size;
16513 + }
16514 +
16515 if (!__builtin_constant_p(size))
16516 - return copy_user_generic((__force void *)dst, src, size);
16517 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16518 switch (size) {
16519 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16520 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16521 ret, "b", "b", "iq", 1);
16522 return ret;
16523 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16524 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16525 ret, "w", "w", "ir", 2);
16526 return ret;
16527 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16528 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16529 ret, "l", "k", "ir", 4);
16530 return ret;
16531 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16532 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16533 ret, "q", "", "er", 8);
16534 return ret;
16535 case 10:
16536 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16537 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16538 ret, "q", "", "er", 10);
16539 if (unlikely(ret))
16540 return ret;
16541 asm("":::"memory");
16542 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16543 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16544 ret, "w", "w", "ir", 2);
16545 return ret;
16546 case 16:
16547 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16548 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16549 ret, "q", "", "er", 16);
16550 if (unlikely(ret))
16551 return ret;
16552 asm("":::"memory");
16553 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16554 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16555 ret, "q", "", "er", 8);
16556 return ret;
16557 default:
16558 - return copy_user_generic((__force void *)dst, src, size);
16559 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16560 }
16561 }
16562
16563 static __always_inline __must_check
16564 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16565 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16566 {
16567 - int ret = 0;
16568 + unsigned ret = 0;
16569
16570 might_fault();
16571 +
16572 + if (size > INT_MAX)
16573 + return size;
16574 +
16575 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16576 + if (!__access_ok(VERIFY_READ, src, size))
16577 + return size;
16578 + if (!__access_ok(VERIFY_WRITE, dst, size))
16579 + return size;
16580 +#endif
16581 +
16582 if (!__builtin_constant_p(size))
16583 - return copy_user_generic((__force void *)dst,
16584 - (__force void *)src, size);
16585 + return copy_user_generic((__force_kernel void *)____m(dst),
16586 + (__force_kernel const void *)____m(src), size);
16587 switch (size) {
16588 case 1: {
16589 u8 tmp;
16590 - __get_user_asm(tmp, (u8 __user *)src,
16591 + __get_user_asm(tmp, (const u8 __user *)src,
16592 ret, "b", "b", "=q", 1);
16593 if (likely(!ret))
16594 __put_user_asm(tmp, (u8 __user *)dst,
16595 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16596 }
16597 case 2: {
16598 u16 tmp;
16599 - __get_user_asm(tmp, (u16 __user *)src,
16600 + __get_user_asm(tmp, (const u16 __user *)src,
16601 ret, "w", "w", "=r", 2);
16602 if (likely(!ret))
16603 __put_user_asm(tmp, (u16 __user *)dst,
16604 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16605
16606 case 4: {
16607 u32 tmp;
16608 - __get_user_asm(tmp, (u32 __user *)src,
16609 + __get_user_asm(tmp, (const u32 __user *)src,
16610 ret, "l", "k", "=r", 4);
16611 if (likely(!ret))
16612 __put_user_asm(tmp, (u32 __user *)dst,
16613 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16614 }
16615 case 8: {
16616 u64 tmp;
16617 - __get_user_asm(tmp, (u64 __user *)src,
16618 + __get_user_asm(tmp, (const u64 __user *)src,
16619 ret, "q", "", "=r", 8);
16620 if (likely(!ret))
16621 __put_user_asm(tmp, (u64 __user *)dst,
16622 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16623 return ret;
16624 }
16625 default:
16626 - return copy_user_generic((__force void *)dst,
16627 - (__force void *)src, size);
16628 + return copy_user_generic((__force_kernel void *)____m(dst),
16629 + (__force_kernel const void *)____m(src), size);
16630 }
16631 }
16632
16633 static __must_check __always_inline int
16634 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16635 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16636 {
16637 - return copy_user_generic(dst, (__force const void *)src, size);
16638 + if (size > INT_MAX)
16639 + return size;
16640 +
16641 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16642 + if (!__access_ok(VERIFY_READ, src, size))
16643 + return size;
16644 +#endif
16645 +
16646 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16647 }
16648
16649 -static __must_check __always_inline int
16650 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16651 +static __must_check __always_inline unsigned long
16652 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16653 {
16654 - return copy_user_generic((__force void *)dst, src, size);
16655 + if (size > INT_MAX)
16656 + return size;
16657 +
16658 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16659 + if (!__access_ok(VERIFY_WRITE, dst, size))
16660 + return size;
16661 +#endif
16662 +
16663 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16664 }
16665
16666 -extern long __copy_user_nocache(void *dst, const void __user *src,
16667 - unsigned size, int zerorest);
16668 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16669 + unsigned long size, int zerorest) __size_overflow(3);
16670
16671 -static inline int
16672 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16673 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16674 {
16675 might_sleep();
16676 +
16677 + if (size > INT_MAX)
16678 + return size;
16679 +
16680 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16681 + if (!__access_ok(VERIFY_READ, src, size))
16682 + return size;
16683 +#endif
16684 +
16685 return __copy_user_nocache(dst, src, size, 1);
16686 }
16687
16688 -static inline int
16689 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16690 - unsigned size)
16691 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16692 + unsigned long size)
16693 {
16694 + if (size > INT_MAX)
16695 + return size;
16696 +
16697 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16698 + if (!__access_ok(VERIFY_READ, src, size))
16699 + return size;
16700 +#endif
16701 +
16702 return __copy_user_nocache(dst, src, size, 0);
16703 }
16704
16705 -unsigned long
16706 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16707 +extern unsigned long
16708 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16709
16710 #endif /* _ASM_X86_UACCESS_64_H */
16711 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16712 index 5b238981..77fdd78 100644
16713 --- a/arch/x86/include/asm/word-at-a-time.h
16714 +++ b/arch/x86/include/asm/word-at-a-time.h
16715 @@ -11,7 +11,7 @@
16716 * and shift, for example.
16717 */
16718 struct word_at_a_time {
16719 - const unsigned long one_bits, high_bits;
16720 + unsigned long one_bits, high_bits;
16721 };
16722
16723 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16724 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16725 index 5769349..a3d3e2a 100644
16726 --- a/arch/x86/include/asm/x86_init.h
16727 +++ b/arch/x86/include/asm/x86_init.h
16728 @@ -141,7 +141,7 @@ struct x86_init_ops {
16729 struct x86_init_timers timers;
16730 struct x86_init_iommu iommu;
16731 struct x86_init_pci pci;
16732 -};
16733 +} __no_const;
16734
16735 /**
16736 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16737 @@ -152,7 +152,7 @@ struct x86_cpuinit_ops {
16738 void (*setup_percpu_clockev)(void);
16739 void (*early_percpu_clock_init)(void);
16740 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16741 -};
16742 +} __no_const;
16743
16744 /**
16745 * struct x86_platform_ops - platform specific runtime functions
16746 @@ -178,7 +178,7 @@ struct x86_platform_ops {
16747 void (*save_sched_clock_state)(void);
16748 void (*restore_sched_clock_state)(void);
16749 void (*apic_post_init)(void);
16750 -};
16751 +} __no_const;
16752
16753 struct pci_dev;
16754
16755 @@ -187,14 +187,14 @@ struct x86_msi_ops {
16756 void (*teardown_msi_irq)(unsigned int irq);
16757 void (*teardown_msi_irqs)(struct pci_dev *dev);
16758 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16759 -};
16760 +} __no_const;
16761
16762 struct x86_io_apic_ops {
16763 void (*init) (void);
16764 unsigned int (*read) (unsigned int apic, unsigned int reg);
16765 void (*write) (unsigned int apic, unsigned int reg, unsigned int value);
16766 void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
16767 -};
16768 +} __no_const;
16769
16770 extern struct x86_init_ops x86_init;
16771 extern struct x86_cpuinit_ops x86_cpuinit;
16772 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16773 index 0415cda..b43d877 100644
16774 --- a/arch/x86/include/asm/xsave.h
16775 +++ b/arch/x86/include/asm/xsave.h
16776 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16777 return -EFAULT;
16778
16779 __asm__ __volatile__(ASM_STAC "\n"
16780 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16781 + "1:"
16782 + __copyuser_seg
16783 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16784 "2: " ASM_CLAC "\n"
16785 ".section .fixup,\"ax\"\n"
16786 "3: movl $-1,%[err]\n"
16787 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16788 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16789 {
16790 int err;
16791 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16792 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16793 u32 lmask = mask;
16794 u32 hmask = mask >> 32;
16795
16796 __asm__ __volatile__(ASM_STAC "\n"
16797 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16798 + "1:"
16799 + __copyuser_seg
16800 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16801 "2: " ASM_CLAC "\n"
16802 ".section .fixup,\"ax\"\n"
16803 "3: movl $-1,%[err]\n"
16804 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16805 index bbae024..e1528f9 100644
16806 --- a/arch/x86/include/uapi/asm/e820.h
16807 +++ b/arch/x86/include/uapi/asm/e820.h
16808 @@ -63,7 +63,7 @@ struct e820map {
16809 #define ISA_START_ADDRESS 0xa0000
16810 #define ISA_END_ADDRESS 0x100000
16811
16812 -#define BIOS_BEGIN 0x000a0000
16813 +#define BIOS_BEGIN 0x000c0000
16814 #define BIOS_END 0x00100000
16815
16816 #define BIOS_ROM_BASE 0xffe00000
16817 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16818 index 34e923a..0c6bb6e 100644
16819 --- a/arch/x86/kernel/Makefile
16820 +++ b/arch/x86/kernel/Makefile
16821 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16822 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16823 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16824 obj-y += probe_roms.o
16825 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16826 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16827 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16828 obj-y += syscall_$(BITS).o
16829 obj-$(CONFIG_X86_64) += vsyscall_64.o
16830 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16831 index bacf4b0..4ede72e 100644
16832 --- a/arch/x86/kernel/acpi/boot.c
16833 +++ b/arch/x86/kernel/acpi/boot.c
16834 @@ -1358,7 +1358,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16835 * If your system is blacklisted here, but you find that acpi=force
16836 * works for you, please contact linux-acpi@vger.kernel.org
16837 */
16838 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16839 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16840 /*
16841 * Boxes that need ACPI disabled
16842 */
16843 @@ -1433,7 +1433,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16844 };
16845
16846 /* second table for DMI checks that should run after early-quirks */
16847 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16848 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16849 /*
16850 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16851 * which includes some code which overrides all temperature
16852 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16853 index d5e0d71..6533e08 100644
16854 --- a/arch/x86/kernel/acpi/sleep.c
16855 +++ b/arch/x86/kernel/acpi/sleep.c
16856 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16857 #else /* CONFIG_64BIT */
16858 #ifdef CONFIG_SMP
16859 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16860 +
16861 + pax_open_kernel();
16862 early_gdt_descr.address =
16863 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16864 + pax_close_kernel();
16865 +
16866 initial_gs = per_cpu_offset(smp_processor_id());
16867 #endif
16868 initial_code = (unsigned long)wakeup_long64;
16869 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16870 index 13ab720..95d5442 100644
16871 --- a/arch/x86/kernel/acpi/wakeup_32.S
16872 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16873 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16874 # and restore the stack ... but you need gdt for this to work
16875 movl saved_context_esp, %esp
16876
16877 - movl %cs:saved_magic, %eax
16878 - cmpl $0x12345678, %eax
16879 + cmpl $0x12345678, saved_magic
16880 jne bogus_magic
16881
16882 # jump to place where we left off
16883 - movl saved_eip, %eax
16884 - jmp *%eax
16885 + jmp *(saved_eip)
16886
16887 bogus_magic:
16888 jmp bogus_magic
16889 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16890 index ef5ccca..bd83949 100644
16891 --- a/arch/x86/kernel/alternative.c
16892 +++ b/arch/x86/kernel/alternative.c
16893 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16894 */
16895 for (a = start; a < end; a++) {
16896 instr = (u8 *)&a->instr_offset + a->instr_offset;
16897 +
16898 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16899 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16900 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16901 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16902 +#endif
16903 +
16904 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16905 BUG_ON(a->replacementlen > a->instrlen);
16906 BUG_ON(a->instrlen > sizeof(insnbuf));
16907 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16908 for (poff = start; poff < end; poff++) {
16909 u8 *ptr = (u8 *)poff + *poff;
16910
16911 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16912 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16913 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16914 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16915 +#endif
16916 +
16917 if (!*poff || ptr < text || ptr >= text_end)
16918 continue;
16919 /* turn DS segment override prefix into lock prefix */
16920 - if (*ptr == 0x3e)
16921 + if (*ktla_ktva(ptr) == 0x3e)
16922 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16923 }
16924 mutex_unlock(&text_mutex);
16925 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16926 for (poff = start; poff < end; poff++) {
16927 u8 *ptr = (u8 *)poff + *poff;
16928
16929 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16930 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16931 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16932 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16933 +#endif
16934 +
16935 if (!*poff || ptr < text || ptr >= text_end)
16936 continue;
16937 /* turn lock prefix into DS segment override prefix */
16938 - if (*ptr == 0xf0)
16939 + if (*ktla_ktva(ptr) == 0xf0)
16940 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16941 }
16942 mutex_unlock(&text_mutex);
16943 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16944
16945 BUG_ON(p->len > MAX_PATCH_LEN);
16946 /* prep the buffer with the original instructions */
16947 - memcpy(insnbuf, p->instr, p->len);
16948 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16949 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16950 (unsigned long)p->instr, p->len);
16951
16952 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16953 if (!uniproc_patched || num_possible_cpus() == 1)
16954 free_init_pages("SMP alternatives",
16955 (unsigned long)__smp_locks,
16956 - (unsigned long)__smp_locks_end);
16957 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16958 #endif
16959
16960 apply_paravirt(__parainstructions, __parainstructions_end);
16961 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16962 * instructions. And on the local CPU you need to be protected again NMI or MCE
16963 * handlers seeing an inconsistent instruction while you patch.
16964 */
16965 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16966 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16967 size_t len)
16968 {
16969 unsigned long flags;
16970 local_irq_save(flags);
16971 - memcpy(addr, opcode, len);
16972 +
16973 + pax_open_kernel();
16974 + memcpy(ktla_ktva(addr), opcode, len);
16975 sync_core();
16976 + pax_close_kernel();
16977 +
16978 local_irq_restore(flags);
16979 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16980 that causes hangs on some VIA CPUs. */
16981 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16982 */
16983 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16984 {
16985 - unsigned long flags;
16986 - char *vaddr;
16987 + unsigned char *vaddr = ktla_ktva(addr);
16988 struct page *pages[2];
16989 - int i;
16990 + size_t i;
16991
16992 if (!core_kernel_text((unsigned long)addr)) {
16993 - pages[0] = vmalloc_to_page(addr);
16994 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16995 + pages[0] = vmalloc_to_page(vaddr);
16996 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16997 } else {
16998 - pages[0] = virt_to_page(addr);
16999 + pages[0] = virt_to_page(vaddr);
17000 WARN_ON(!PageReserved(pages[0]));
17001 - pages[1] = virt_to_page(addr + PAGE_SIZE);
17002 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
17003 }
17004 BUG_ON(!pages[0]);
17005 - local_irq_save(flags);
17006 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
17007 - if (pages[1])
17008 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
17009 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
17010 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
17011 - clear_fixmap(FIX_TEXT_POKE0);
17012 - if (pages[1])
17013 - clear_fixmap(FIX_TEXT_POKE1);
17014 - local_flush_tlb();
17015 - sync_core();
17016 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
17017 - that causes hangs on some VIA CPUs. */
17018 + text_poke_early(addr, opcode, len);
17019 for (i = 0; i < len; i++)
17020 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
17021 - local_irq_restore(flags);
17022 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
17023 return addr;
17024 }
17025
17026 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
17027 index cbf5121..812b537 100644
17028 --- a/arch/x86/kernel/apic/apic.c
17029 +++ b/arch/x86/kernel/apic/apic.c
17030 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
17031 /*
17032 * Debug level, exported for io_apic.c
17033 */
17034 -unsigned int apic_verbosity;
17035 +int apic_verbosity;
17036
17037 int pic_mode;
17038
17039 @@ -1956,7 +1956,7 @@ void smp_error_interrupt(struct pt_regs *regs)
17040 apic_write(APIC_ESR, 0);
17041 v1 = apic_read(APIC_ESR);
17042 ack_APIC_irq();
17043 - atomic_inc(&irq_err_count);
17044 + atomic_inc_unchecked(&irq_err_count);
17045
17046 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
17047 smp_processor_id(), v0 , v1);
17048 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
17049 index 00c77cf..2dc6a2d 100644
17050 --- a/arch/x86/kernel/apic/apic_flat_64.c
17051 +++ b/arch/x86/kernel/apic/apic_flat_64.c
17052 @@ -157,7 +157,7 @@ static int flat_probe(void)
17053 return 1;
17054 }
17055
17056 -static struct apic apic_flat = {
17057 +static struct apic apic_flat __read_only = {
17058 .name = "flat",
17059 .probe = flat_probe,
17060 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
17061 @@ -271,7 +271,7 @@ static int physflat_probe(void)
17062 return 0;
17063 }
17064
17065 -static struct apic apic_physflat = {
17066 +static struct apic apic_physflat __read_only = {
17067
17068 .name = "physical flat",
17069 .probe = physflat_probe,
17070 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
17071 index e145f28..2752888 100644
17072 --- a/arch/x86/kernel/apic/apic_noop.c
17073 +++ b/arch/x86/kernel/apic/apic_noop.c
17074 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
17075 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
17076 }
17077
17078 -struct apic apic_noop = {
17079 +struct apic apic_noop __read_only = {
17080 .name = "noop",
17081 .probe = noop_probe,
17082 .acpi_madt_oem_check = NULL,
17083 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
17084 index d50e364..543bee3 100644
17085 --- a/arch/x86/kernel/apic/bigsmp_32.c
17086 +++ b/arch/x86/kernel/apic/bigsmp_32.c
17087 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
17088 return dmi_bigsmp;
17089 }
17090
17091 -static struct apic apic_bigsmp = {
17092 +static struct apic apic_bigsmp __read_only = {
17093
17094 .name = "bigsmp",
17095 .probe = probe_bigsmp,
17096 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
17097 index 0874799..a7a7892 100644
17098 --- a/arch/x86/kernel/apic/es7000_32.c
17099 +++ b/arch/x86/kernel/apic/es7000_32.c
17100 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
17101 return ret && es7000_apic_is_cluster();
17102 }
17103
17104 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
17105 -static struct apic __refdata apic_es7000_cluster = {
17106 +static struct apic apic_es7000_cluster __read_only = {
17107
17108 .name = "es7000",
17109 .probe = probe_es7000,
17110 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
17111 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
17112 };
17113
17114 -static struct apic __refdata apic_es7000 = {
17115 +static struct apic apic_es7000 __read_only = {
17116
17117 .name = "es7000",
17118 .probe = probe_es7000,
17119 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
17120 index b739d39..aebc14c 100644
17121 --- a/arch/x86/kernel/apic/io_apic.c
17122 +++ b/arch/x86/kernel/apic/io_apic.c
17123 @@ -1084,7 +1084,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
17124 }
17125 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
17126
17127 -void lock_vector_lock(void)
17128 +void lock_vector_lock(void) __acquires(vector_lock)
17129 {
17130 /* Used to the online set of cpus does not change
17131 * during assign_irq_vector.
17132 @@ -1092,7 +1092,7 @@ void lock_vector_lock(void)
17133 raw_spin_lock(&vector_lock);
17134 }
17135
17136 -void unlock_vector_lock(void)
17137 +void unlock_vector_lock(void) __releases(vector_lock)
17138 {
17139 raw_spin_unlock(&vector_lock);
17140 }
17141 @@ -2399,7 +2399,7 @@ static void ack_apic_edge(struct irq_data *data)
17142 ack_APIC_irq();
17143 }
17144
17145 -atomic_t irq_mis_count;
17146 +atomic_unchecked_t irq_mis_count;
17147
17148 #ifdef CONFIG_GENERIC_PENDING_IRQ
17149 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
17150 @@ -2540,7 +2540,7 @@ static void ack_apic_level(struct irq_data *data)
17151 * at the cpu.
17152 */
17153 if (!(v & (1 << (i & 0x1f)))) {
17154 - atomic_inc(&irq_mis_count);
17155 + atomic_inc_unchecked(&irq_mis_count);
17156
17157 eoi_ioapic_irq(irq, cfg);
17158 }
17159 @@ -2567,11 +2567,13 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
17160
17161 static void irq_remap_modify_chip_defaults(struct irq_chip *chip)
17162 {
17163 - chip->irq_print_chip = ir_print_prefix;
17164 - chip->irq_ack = ir_ack_apic_edge;
17165 - chip->irq_eoi = ir_ack_apic_level;
17166 + pax_open_kernel();
17167 + *(void **)&chip->irq_print_chip = ir_print_prefix;
17168 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
17169 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
17170
17171 - chip->irq_set_affinity = set_remapped_irq_affinity;
17172 + *(void **)&chip->irq_set_affinity = set_remapped_irq_affinity;
17173 + pax_close_kernel();
17174 }
17175 #endif /* CONFIG_IRQ_REMAP */
17176
17177 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
17178 index d661ee9..791fd33 100644
17179 --- a/arch/x86/kernel/apic/numaq_32.c
17180 +++ b/arch/x86/kernel/apic/numaq_32.c
17181 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
17182 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
17183 }
17184
17185 -/* Use __refdata to keep false positive warning calm. */
17186 -static struct apic __refdata apic_numaq = {
17187 +static struct apic apic_numaq __read_only = {
17188
17189 .name = "NUMAQ",
17190 .probe = probe_numaq,
17191 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
17192 index eb35ef9..f184a21 100644
17193 --- a/arch/x86/kernel/apic/probe_32.c
17194 +++ b/arch/x86/kernel/apic/probe_32.c
17195 @@ -72,7 +72,7 @@ static int probe_default(void)
17196 return 1;
17197 }
17198
17199 -static struct apic apic_default = {
17200 +static struct apic apic_default __read_only = {
17201
17202 .name = "default",
17203 .probe = probe_default,
17204 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
17205 index 77c95c0..434f8a4 100644
17206 --- a/arch/x86/kernel/apic/summit_32.c
17207 +++ b/arch/x86/kernel/apic/summit_32.c
17208 @@ -486,7 +486,7 @@ void setup_summit(void)
17209 }
17210 #endif
17211
17212 -static struct apic apic_summit = {
17213 +static struct apic apic_summit __read_only = {
17214
17215 .name = "summit",
17216 .probe = probe_summit,
17217 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
17218 index c88baa4..757aee1 100644
17219 --- a/arch/x86/kernel/apic/x2apic_cluster.c
17220 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
17221 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
17222 return notifier_from_errno(err);
17223 }
17224
17225 -static struct notifier_block __refdata x2apic_cpu_notifier = {
17226 +static struct notifier_block x2apic_cpu_notifier = {
17227 .notifier_call = update_clusterinfo,
17228 };
17229
17230 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
17231 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
17232 }
17233
17234 -static struct apic apic_x2apic_cluster = {
17235 +static struct apic apic_x2apic_cluster __read_only = {
17236
17237 .name = "cluster x2apic",
17238 .probe = x2apic_cluster_probe,
17239 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
17240 index 562a76d..a003c0f 100644
17241 --- a/arch/x86/kernel/apic/x2apic_phys.c
17242 +++ b/arch/x86/kernel/apic/x2apic_phys.c
17243 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
17244 return apic == &apic_x2apic_phys;
17245 }
17246
17247 -static struct apic apic_x2apic_phys = {
17248 +static struct apic apic_x2apic_phys __read_only = {
17249
17250 .name = "physical x2apic",
17251 .probe = x2apic_phys_probe,
17252 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17253 index 8cfade9..b9d04fc 100644
17254 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17255 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17256 @@ -333,7 +333,7 @@ static int uv_probe(void)
17257 return apic == &apic_x2apic_uv_x;
17258 }
17259
17260 -static struct apic __refdata apic_x2apic_uv_x = {
17261 +static struct apic apic_x2apic_uv_x __read_only = {
17262
17263 .name = "UV large system",
17264 .probe = uv_probe,
17265 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17266 index d65464e..1035d31 100644
17267 --- a/arch/x86/kernel/apm_32.c
17268 +++ b/arch/x86/kernel/apm_32.c
17269 @@ -412,7 +412,7 @@ static DEFINE_MUTEX(apm_mutex);
17270 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17271 * even though they are called in protected mode.
17272 */
17273 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17274 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17275 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17276
17277 static const char driver_version[] = "1.16ac"; /* no spaces */
17278 @@ -590,7 +590,10 @@ static long __apm_bios_call(void *_call)
17279 BUG_ON(cpu != 0);
17280 gdt = get_cpu_gdt_table(cpu);
17281 save_desc_40 = gdt[0x40 / 8];
17282 +
17283 + pax_open_kernel();
17284 gdt[0x40 / 8] = bad_bios_desc;
17285 + pax_close_kernel();
17286
17287 apm_irq_save(flags);
17288 APM_DO_SAVE_SEGS;
17289 @@ -599,7 +602,11 @@ static long __apm_bios_call(void *_call)
17290 &call->esi);
17291 APM_DO_RESTORE_SEGS;
17292 apm_irq_restore(flags);
17293 +
17294 + pax_open_kernel();
17295 gdt[0x40 / 8] = save_desc_40;
17296 + pax_close_kernel();
17297 +
17298 put_cpu();
17299
17300 return call->eax & 0xff;
17301 @@ -666,7 +673,10 @@ static long __apm_bios_call_simple(void *_call)
17302 BUG_ON(cpu != 0);
17303 gdt = get_cpu_gdt_table(cpu);
17304 save_desc_40 = gdt[0x40 / 8];
17305 +
17306 + pax_open_kernel();
17307 gdt[0x40 / 8] = bad_bios_desc;
17308 + pax_close_kernel();
17309
17310 apm_irq_save(flags);
17311 APM_DO_SAVE_SEGS;
17312 @@ -674,7 +684,11 @@ static long __apm_bios_call_simple(void *_call)
17313 &call->eax);
17314 APM_DO_RESTORE_SEGS;
17315 apm_irq_restore(flags);
17316 +
17317 + pax_open_kernel();
17318 gdt[0x40 / 8] = save_desc_40;
17319 + pax_close_kernel();
17320 +
17321 put_cpu();
17322 return error;
17323 }
17324 @@ -2345,12 +2359,15 @@ static int __init apm_init(void)
17325 * code to that CPU.
17326 */
17327 gdt = get_cpu_gdt_table(0);
17328 +
17329 + pax_open_kernel();
17330 set_desc_base(&gdt[APM_CS >> 3],
17331 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17332 set_desc_base(&gdt[APM_CS_16 >> 3],
17333 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17334 set_desc_base(&gdt[APM_DS >> 3],
17335 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17336 + pax_close_kernel();
17337
17338 proc_create("apm", 0, NULL, &apm_file_ops);
17339
17340 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17341 index 2861082..6d4718e 100644
17342 --- a/arch/x86/kernel/asm-offsets.c
17343 +++ b/arch/x86/kernel/asm-offsets.c
17344 @@ -33,6 +33,8 @@ void common(void) {
17345 OFFSET(TI_status, thread_info, status);
17346 OFFSET(TI_addr_limit, thread_info, addr_limit);
17347 OFFSET(TI_preempt_count, thread_info, preempt_count);
17348 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17349 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17350
17351 BLANK();
17352 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17353 @@ -53,8 +55,26 @@ void common(void) {
17354 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17355 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17356 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17357 +
17358 +#ifdef CONFIG_PAX_KERNEXEC
17359 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17360 #endif
17361
17362 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17363 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17364 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17365 +#ifdef CONFIG_X86_64
17366 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17367 +#endif
17368 +#endif
17369 +
17370 +#endif
17371 +
17372 + BLANK();
17373 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17374 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17375 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17376 +
17377 #ifdef CONFIG_XEN
17378 BLANK();
17379 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17380 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17381 index 1b4754f..fbb4227 100644
17382 --- a/arch/x86/kernel/asm-offsets_64.c
17383 +++ b/arch/x86/kernel/asm-offsets_64.c
17384 @@ -76,6 +76,7 @@ int main(void)
17385 BLANK();
17386 #undef ENTRY
17387
17388 + DEFINE(TSS_size, sizeof(struct tss_struct));
17389 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17390 BLANK();
17391
17392 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17393 index a0e067d..9c7db16 100644
17394 --- a/arch/x86/kernel/cpu/Makefile
17395 +++ b/arch/x86/kernel/cpu/Makefile
17396 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17397 CFLAGS_REMOVE_perf_event.o = -pg
17398 endif
17399
17400 -# Make sure load_percpu_segment has no stackprotector
17401 -nostackp := $(call cc-option, -fno-stack-protector)
17402 -CFLAGS_common.o := $(nostackp)
17403 -
17404 obj-y := intel_cacheinfo.o scattered.o topology.o
17405 obj-y += proc.o capflags.o powerflags.o common.o
17406 obj-y += vmware.o hypervisor.o mshyperv.o
17407 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17408 index 15239ff..e23e04e 100644
17409 --- a/arch/x86/kernel/cpu/amd.c
17410 +++ b/arch/x86/kernel/cpu/amd.c
17411 @@ -733,7 +733,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17412 unsigned int size)
17413 {
17414 /* AMD errata T13 (order #21922) */
17415 - if ((c->x86 == 6)) {
17416 + if (c->x86 == 6) {
17417 /* Duron Rev A0 */
17418 if (c->x86_model == 3 && c->x86_mask == 0)
17419 size = 64;
17420 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17421 index 9c3ab43..51e6366 100644
17422 --- a/arch/x86/kernel/cpu/common.c
17423 +++ b/arch/x86/kernel/cpu/common.c
17424 @@ -86,60 +86,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17425
17426 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17427
17428 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17429 -#ifdef CONFIG_X86_64
17430 - /*
17431 - * We need valid kernel segments for data and code in long mode too
17432 - * IRET will check the segment types kkeil 2000/10/28
17433 - * Also sysret mandates a special GDT layout
17434 - *
17435 - * TLS descriptors are currently at a different place compared to i386.
17436 - * Hopefully nobody expects them at a fixed place (Wine?)
17437 - */
17438 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17439 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17440 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17441 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17442 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17443 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17444 -#else
17445 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17446 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17447 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17448 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17449 - /*
17450 - * Segments used for calling PnP BIOS have byte granularity.
17451 - * They code segments and data segments have fixed 64k limits,
17452 - * the transfer segment sizes are set at run time.
17453 - */
17454 - /* 32-bit code */
17455 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17456 - /* 16-bit code */
17457 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17458 - /* 16-bit data */
17459 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17460 - /* 16-bit data */
17461 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17462 - /* 16-bit data */
17463 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17464 - /*
17465 - * The APM segments have byte granularity and their bases
17466 - * are set at run time. All have 64k limits.
17467 - */
17468 - /* 32-bit code */
17469 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17470 - /* 16-bit code */
17471 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17472 - /* data */
17473 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17474 -
17475 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17476 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17477 - GDT_STACK_CANARY_INIT
17478 -#endif
17479 -} };
17480 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17481 -
17482 static int __init x86_xsave_setup(char *s)
17483 {
17484 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17485 @@ -389,7 +335,7 @@ void switch_to_new_gdt(int cpu)
17486 {
17487 struct desc_ptr gdt_descr;
17488
17489 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17490 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17491 gdt_descr.size = GDT_SIZE - 1;
17492 load_gdt(&gdt_descr);
17493 /* Reload the per-cpu base */
17494 @@ -885,6 +831,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17495 /* Filter out anything that depends on CPUID levels we don't have */
17496 filter_cpuid_features(c, true);
17497
17498 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17499 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17500 +#endif
17501 +
17502 /* If the model name is still unset, do table lookup. */
17503 if (!c->x86_model_id[0]) {
17504 const char *p;
17505 @@ -1068,10 +1018,12 @@ static __init int setup_disablecpuid(char *arg)
17506 }
17507 __setup("clearcpuid=", setup_disablecpuid);
17508
17509 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17510 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17511 +
17512 #ifdef CONFIG_X86_64
17513 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17514 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17515 - (unsigned long) nmi_idt_table };
17516 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17517
17518 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17519 irq_stack_union) __aligned(PAGE_SIZE);
17520 @@ -1085,7 +1037,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17521 EXPORT_PER_CPU_SYMBOL(current_task);
17522
17523 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17524 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17525 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17526 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17527
17528 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17529 @@ -1224,7 +1176,7 @@ void __cpuinit cpu_init(void)
17530 int i;
17531
17532 cpu = stack_smp_processor_id();
17533 - t = &per_cpu(init_tss, cpu);
17534 + t = init_tss + cpu;
17535 oist = &per_cpu(orig_ist, cpu);
17536
17537 #ifdef CONFIG_NUMA
17538 @@ -1250,7 +1202,7 @@ void __cpuinit cpu_init(void)
17539 switch_to_new_gdt(cpu);
17540 loadsegment(fs, 0);
17541
17542 - load_idt((const struct desc_ptr *)&idt_descr);
17543 + load_idt(&idt_descr);
17544
17545 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17546 syscall_init();
17547 @@ -1259,7 +1211,6 @@ void __cpuinit cpu_init(void)
17548 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17549 barrier();
17550
17551 - x86_configure_nx();
17552 enable_x2apic();
17553
17554 /*
17555 @@ -1311,7 +1262,7 @@ void __cpuinit cpu_init(void)
17556 {
17557 int cpu = smp_processor_id();
17558 struct task_struct *curr = current;
17559 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17560 + struct tss_struct *t = init_tss + cpu;
17561 struct thread_struct *thread = &curr->thread;
17562
17563 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
17564 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17565 index fcaabd0..7b55a26 100644
17566 --- a/arch/x86/kernel/cpu/intel.c
17567 +++ b/arch/x86/kernel/cpu/intel.c
17568 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17569 * Update the IDT descriptor and reload the IDT so that
17570 * it uses the read-only mapped virtual address.
17571 */
17572 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17573 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17574 load_idt(&idt_descr);
17575 }
17576 #endif
17577 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17578 index 84c1309..39b7224 100644
17579 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17580 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17581 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17582 };
17583
17584 #ifdef CONFIG_AMD_NB
17585 +static struct attribute *default_attrs_amd_nb[] = {
17586 + &type.attr,
17587 + &level.attr,
17588 + &coherency_line_size.attr,
17589 + &physical_line_partition.attr,
17590 + &ways_of_associativity.attr,
17591 + &number_of_sets.attr,
17592 + &size.attr,
17593 + &shared_cpu_map.attr,
17594 + &shared_cpu_list.attr,
17595 + NULL,
17596 + NULL,
17597 + NULL,
17598 + NULL
17599 +};
17600 +
17601 static struct attribute ** __cpuinit amd_l3_attrs(void)
17602 {
17603 static struct attribute **attrs;
17604 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17605
17606 n = ARRAY_SIZE(default_attrs);
17607
17608 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17609 - n += 2;
17610 -
17611 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17612 - n += 1;
17613 -
17614 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17615 - if (attrs == NULL)
17616 - return attrs = default_attrs;
17617 -
17618 - for (n = 0; default_attrs[n]; n++)
17619 - attrs[n] = default_attrs[n];
17620 + attrs = default_attrs_amd_nb;
17621
17622 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17623 attrs[n++] = &cache_disable_0.attr;
17624 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17625 .default_attrs = default_attrs,
17626 };
17627
17628 +#ifdef CONFIG_AMD_NB
17629 +static struct kobj_type ktype_cache_amd_nb = {
17630 + .sysfs_ops = &sysfs_ops,
17631 + .default_attrs = default_attrs_amd_nb,
17632 +};
17633 +#endif
17634 +
17635 static struct kobj_type ktype_percpu_entry = {
17636 .sysfs_ops = &sysfs_ops,
17637 };
17638 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17639 return retval;
17640 }
17641
17642 +#ifdef CONFIG_AMD_NB
17643 + amd_l3_attrs();
17644 +#endif
17645 +
17646 for (i = 0; i < num_cache_leaves; i++) {
17647 + struct kobj_type *ktype;
17648 +
17649 this_object = INDEX_KOBJECT_PTR(cpu, i);
17650 this_object->cpu = cpu;
17651 this_object->index = i;
17652
17653 this_leaf = CPUID4_INFO_IDX(cpu, i);
17654
17655 - ktype_cache.default_attrs = default_attrs;
17656 + ktype = &ktype_cache;
17657 #ifdef CONFIG_AMD_NB
17658 if (this_leaf->base.nb)
17659 - ktype_cache.default_attrs = amd_l3_attrs();
17660 + ktype = &ktype_cache_amd_nb;
17661 #endif
17662 retval = kobject_init_and_add(&(this_object->kobj),
17663 - &ktype_cache,
17664 + ktype,
17665 per_cpu(ici_cache_kobject, cpu),
17666 "index%1lu", i);
17667 if (unlikely(retval)) {
17668 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17669 return NOTIFY_OK;
17670 }
17671
17672 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17673 +static struct notifier_block cacheinfo_cpu_notifier = {
17674 .notifier_call = cacheinfo_cpu_callback,
17675 };
17676
17677 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17678 index 80dbda8..be16652 100644
17679 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17680 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17681 @@ -45,6 +45,7 @@
17682 #include <asm/processor.h>
17683 #include <asm/mce.h>
17684 #include <asm/msr.h>
17685 +#include <asm/local.h>
17686
17687 #include "mce-internal.h"
17688
17689 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17690 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17691 m->cs, m->ip);
17692
17693 - if (m->cs == __KERNEL_CS)
17694 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17695 print_symbol("{%s}", m->ip);
17696 pr_cont("\n");
17697 }
17698 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17699
17700 #define PANIC_TIMEOUT 5 /* 5 seconds */
17701
17702 -static atomic_t mce_paniced;
17703 +static atomic_unchecked_t mce_paniced;
17704
17705 static int fake_panic;
17706 -static atomic_t mce_fake_paniced;
17707 +static atomic_unchecked_t mce_fake_paniced;
17708
17709 /* Panic in progress. Enable interrupts and wait for final IPI */
17710 static void wait_for_panic(void)
17711 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17712 /*
17713 * Make sure only one CPU runs in machine check panic
17714 */
17715 - if (atomic_inc_return(&mce_paniced) > 1)
17716 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17717 wait_for_panic();
17718 barrier();
17719
17720 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17721 console_verbose();
17722 } else {
17723 /* Don't log too much for fake panic */
17724 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17725 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17726 return;
17727 }
17728 /* First print corrected ones that are still unlogged */
17729 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
17730 * might have been modified by someone else.
17731 */
17732 rmb();
17733 - if (atomic_read(&mce_paniced))
17734 + if (atomic_read_unchecked(&mce_paniced))
17735 wait_for_panic();
17736 if (!mca_cfg.monarch_timeout)
17737 goto out;
17738 @@ -1662,7 +1663,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17739 }
17740
17741 /* Call the installed machine check handler for this CPU setup. */
17742 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17743 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17744 unexpected_machine_check;
17745
17746 /*
17747 @@ -1685,7 +1686,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17748 return;
17749 }
17750
17751 + pax_open_kernel();
17752 machine_check_vector = do_machine_check;
17753 + pax_close_kernel();
17754
17755 __mcheck_cpu_init_generic();
17756 __mcheck_cpu_init_vendor(c);
17757 @@ -1699,7 +1702,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17758 */
17759
17760 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17761 -static int mce_chrdev_open_count; /* #times opened */
17762 +static local_t mce_chrdev_open_count; /* #times opened */
17763 static int mce_chrdev_open_exclu; /* already open exclusive? */
17764
17765 static int mce_chrdev_open(struct inode *inode, struct file *file)
17766 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17767 spin_lock(&mce_chrdev_state_lock);
17768
17769 if (mce_chrdev_open_exclu ||
17770 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17771 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17772 spin_unlock(&mce_chrdev_state_lock);
17773
17774 return -EBUSY;
17775 @@ -1715,7 +1718,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17776
17777 if (file->f_flags & O_EXCL)
17778 mce_chrdev_open_exclu = 1;
17779 - mce_chrdev_open_count++;
17780 + local_inc(&mce_chrdev_open_count);
17781
17782 spin_unlock(&mce_chrdev_state_lock);
17783
17784 @@ -1726,7 +1729,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17785 {
17786 spin_lock(&mce_chrdev_state_lock);
17787
17788 - mce_chrdev_open_count--;
17789 + local_dec(&mce_chrdev_open_count);
17790 mce_chrdev_open_exclu = 0;
17791
17792 spin_unlock(&mce_chrdev_state_lock);
17793 @@ -2372,7 +2375,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17794 return NOTIFY_OK;
17795 }
17796
17797 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17798 +static struct notifier_block mce_cpu_notifier = {
17799 .notifier_call = mce_cpu_callback,
17800 };
17801
17802 @@ -2382,7 +2385,7 @@ static __init void mce_init_banks(void)
17803
17804 for (i = 0; i < mca_cfg.banks; i++) {
17805 struct mce_bank *b = &mce_banks[i];
17806 - struct device_attribute *a = &b->attr;
17807 + device_attribute_no_const *a = &b->attr;
17808
17809 sysfs_attr_init(&a->attr);
17810 a->attr.name = b->attrname;
17811 @@ -2450,7 +2453,7 @@ struct dentry *mce_get_debugfs_dir(void)
17812 static void mce_reset(void)
17813 {
17814 cpu_missing = 0;
17815 - atomic_set(&mce_fake_paniced, 0);
17816 + atomic_set_unchecked(&mce_fake_paniced, 0);
17817 atomic_set(&mce_executing, 0);
17818 atomic_set(&mce_callin, 0);
17819 atomic_set(&global_nwo, 0);
17820 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17821 index 2d5454c..51987eb 100644
17822 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17823 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17824 @@ -11,6 +11,7 @@
17825 #include <asm/processor.h>
17826 #include <asm/mce.h>
17827 #include <asm/msr.h>
17828 +#include <asm/pgtable.h>
17829
17830 /* By default disabled */
17831 int mce_p5_enabled __read_mostly;
17832 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17833 if (!cpu_has(c, X86_FEATURE_MCE))
17834 return;
17835
17836 + pax_open_kernel();
17837 machine_check_vector = pentium_machine_check;
17838 + pax_close_kernel();
17839 /* Make sure the vector pointer is visible before we enable MCEs: */
17840 wmb();
17841
17842 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17843 index 47a1870..8c019a7 100644
17844 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17845 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17846 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17847 return notifier_from_errno(err);
17848 }
17849
17850 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17851 +static struct notifier_block thermal_throttle_cpu_notifier =
17852 {
17853 .notifier_call = thermal_throttle_cpu_callback,
17854 };
17855 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17856 index 2d7998f..17c9de1 100644
17857 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17858 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17859 @@ -10,6 +10,7 @@
17860 #include <asm/processor.h>
17861 #include <asm/mce.h>
17862 #include <asm/msr.h>
17863 +#include <asm/pgtable.h>
17864
17865 /* Machine check handler for WinChip C6: */
17866 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17867 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17868 {
17869 u32 lo, hi;
17870
17871 + pax_open_kernel();
17872 machine_check_vector = winchip_machine_check;
17873 + pax_close_kernel();
17874 /* Make sure the vector pointer is visible before we enable MCEs: */
17875 wmb();
17876
17877 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17878 index 726bf96..81f0526 100644
17879 --- a/arch/x86/kernel/cpu/mtrr/main.c
17880 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17881 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17882 u64 size_or_mask, size_and_mask;
17883 static bool mtrr_aps_delayed_init;
17884
17885 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17886 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17887
17888 const struct mtrr_ops *mtrr_if;
17889
17890 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17891 index df5e41f..816c719 100644
17892 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17893 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17894 @@ -25,7 +25,7 @@ struct mtrr_ops {
17895 int (*validate_add_page)(unsigned long base, unsigned long size,
17896 unsigned int type);
17897 int (*have_wrcomb)(void);
17898 -};
17899 +} __do_const;
17900
17901 extern int generic_get_free_region(unsigned long base, unsigned long size,
17902 int replace_reg);
17903 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17904 index 6774c17..72c1b22 100644
17905 --- a/arch/x86/kernel/cpu/perf_event.c
17906 +++ b/arch/x86/kernel/cpu/perf_event.c
17907 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17908 pr_info("no hardware sampling interrupt available.\n");
17909 }
17910
17911 -static struct attribute_group x86_pmu_format_group = {
17912 +static attribute_group_no_const x86_pmu_format_group = {
17913 .name = "format",
17914 .attrs = NULL,
17915 };
17916 @@ -1313,7 +1313,7 @@ static struct attribute_group x86_pmu_format_group = {
17917 struct perf_pmu_events_attr {
17918 struct device_attribute attr;
17919 u64 id;
17920 -};
17921 +} __do_const;
17922
17923 /*
17924 * Remove all undefined events (x86_pmu.event_map(id) == 0)
17925 @@ -1381,7 +1381,7 @@ static struct attribute *events_attr[] = {
17926 NULL,
17927 };
17928
17929 -static struct attribute_group x86_pmu_events_group = {
17930 +static attribute_group_no_const x86_pmu_events_group = {
17931 .name = "events",
17932 .attrs = events_attr,
17933 };
17934 @@ -1880,7 +1880,7 @@ static unsigned long get_segment_base(unsigned int segment)
17935 if (idx > GDT_ENTRIES)
17936 return 0;
17937
17938 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17939 + desc = get_cpu_gdt_table(smp_processor_id());
17940 }
17941
17942 return get_desc_base(desc + idx);
17943 @@ -1970,7 +1970,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17944 break;
17945
17946 perf_callchain_store(entry, frame.return_address);
17947 - fp = frame.next_frame;
17948 + fp = (const void __force_user *)frame.next_frame;
17949 }
17950 }
17951
17952 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17953 index 4914e94..60b06e3 100644
17954 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17955 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17956 @@ -1958,10 +1958,10 @@ __init int intel_pmu_init(void)
17957 * v2 and above have a perf capabilities MSR
17958 */
17959 if (version > 1) {
17960 - u64 capabilities;
17961 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17962
17963 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17964 - x86_pmu.intel_cap.capabilities = capabilities;
17965 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17966 + x86_pmu.intel_cap.capabilities = capabilities;
17967 }
17968
17969 intel_ds_init();
17970 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17971 index b43200d..d235b3e 100644
17972 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17973 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17974 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17975 static int __init uncore_type_init(struct intel_uncore_type *type)
17976 {
17977 struct intel_uncore_pmu *pmus;
17978 - struct attribute_group *events_group;
17979 + attribute_group_no_const *attr_group;
17980 struct attribute **attrs;
17981 int i, j;
17982
17983 @@ -2455,19 +2455,19 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
17984 while (type->event_descs[i].attr.attr.name)
17985 i++;
17986
17987 - events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17988 - sizeof(*events_group), GFP_KERNEL);
17989 - if (!events_group)
17990 + attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
17991 + sizeof(*attr_group), GFP_KERNEL);
17992 + if (!attr_group)
17993 goto fail;
17994
17995 - attrs = (struct attribute **)(events_group + 1);
17996 - events_group->name = "events";
17997 - events_group->attrs = attrs;
17998 + attrs = (struct attribute **)(attr_group + 1);
17999 + attr_group->name = "events";
18000 + attr_group->attrs = attrs;
18001
18002 for (j = 0; j < i; j++)
18003 attrs[j] = &type->event_descs[j].attr.attr;
18004
18005 - type->events_group = events_group;
18006 + type->events_group = attr_group;
18007 }
18008
18009 type->pmu_group = &uncore_pmu_attr_group;
18010 @@ -2826,7 +2826,7 @@ static int
18011 return NOTIFY_OK;
18012 }
18013
18014 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
18015 +static struct notifier_block uncore_cpu_nb = {
18016 .notifier_call = uncore_cpu_notifier,
18017 /*
18018 * to migrate uncore events, our notifier should be executed
18019 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18020 index e68a455..975a932 100644
18021 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18022 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18023 @@ -428,7 +428,7 @@ struct intel_uncore_box {
18024 struct uncore_event_desc {
18025 struct kobj_attribute attr;
18026 const char *config;
18027 -};
18028 +} __do_const;
18029
18030 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
18031 { \
18032 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
18033 index 60c7891..9e911d3 100644
18034 --- a/arch/x86/kernel/cpuid.c
18035 +++ b/arch/x86/kernel/cpuid.c
18036 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
18037 return notifier_from_errno(err);
18038 }
18039
18040 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
18041 +static struct notifier_block cpuid_class_cpu_notifier =
18042 {
18043 .notifier_call = cpuid_class_cpu_callback,
18044 };
18045 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
18046 index 74467fe..18793d5 100644
18047 --- a/arch/x86/kernel/crash.c
18048 +++ b/arch/x86/kernel/crash.c
18049 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
18050 {
18051 #ifdef CONFIG_X86_32
18052 struct pt_regs fixed_regs;
18053 -#endif
18054
18055 -#ifdef CONFIG_X86_32
18056 - if (!user_mode_vm(regs)) {
18057 + if (!user_mode(regs)) {
18058 crash_fixup_ss_esp(&fixed_regs, regs);
18059 regs = &fixed_regs;
18060 }
18061 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
18062 index 37250fe..bf2ec74 100644
18063 --- a/arch/x86/kernel/doublefault_32.c
18064 +++ b/arch/x86/kernel/doublefault_32.c
18065 @@ -11,7 +11,7 @@
18066
18067 #define DOUBLEFAULT_STACKSIZE (1024)
18068 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
18069 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
18070 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
18071
18072 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
18073
18074 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
18075 unsigned long gdt, tss;
18076
18077 store_gdt(&gdt_desc);
18078 - gdt = gdt_desc.address;
18079 + gdt = (unsigned long)gdt_desc.address;
18080
18081 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
18082
18083 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
18084 /* 0x2 bit is always set */
18085 .flags = X86_EFLAGS_SF | 0x2,
18086 .sp = STACK_START,
18087 - .es = __USER_DS,
18088 + .es = __KERNEL_DS,
18089 .cs = __KERNEL_CS,
18090 .ss = __KERNEL_DS,
18091 - .ds = __USER_DS,
18092 + .ds = __KERNEL_DS,
18093 .fs = __KERNEL_PERCPU,
18094
18095 .__cr3 = __pa_nodebug(swapper_pg_dir),
18096 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
18097 index ae42418b..787c16b 100644
18098 --- a/arch/x86/kernel/dumpstack.c
18099 +++ b/arch/x86/kernel/dumpstack.c
18100 @@ -2,6 +2,9 @@
18101 * Copyright (C) 1991, 1992 Linus Torvalds
18102 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
18103 */
18104 +#ifdef CONFIG_GRKERNSEC_HIDESYM
18105 +#define __INCLUDED_BY_HIDESYM 1
18106 +#endif
18107 #include <linux/kallsyms.h>
18108 #include <linux/kprobes.h>
18109 #include <linux/uaccess.h>
18110 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
18111 static void
18112 print_ftrace_graph_addr(unsigned long addr, void *data,
18113 const struct stacktrace_ops *ops,
18114 - struct thread_info *tinfo, int *graph)
18115 + struct task_struct *task, int *graph)
18116 {
18117 - struct task_struct *task;
18118 unsigned long ret_addr;
18119 int index;
18120
18121 if (addr != (unsigned long)return_to_handler)
18122 return;
18123
18124 - task = tinfo->task;
18125 index = task->curr_ret_stack;
18126
18127 if (!task->ret_stack || index < *graph)
18128 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18129 static inline void
18130 print_ftrace_graph_addr(unsigned long addr, void *data,
18131 const struct stacktrace_ops *ops,
18132 - struct thread_info *tinfo, int *graph)
18133 + struct task_struct *task, int *graph)
18134 { }
18135 #endif
18136
18137 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18138 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
18139 */
18140
18141 -static inline int valid_stack_ptr(struct thread_info *tinfo,
18142 - void *p, unsigned int size, void *end)
18143 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
18144 {
18145 - void *t = tinfo;
18146 if (end) {
18147 if (p < end && p >= (end-THREAD_SIZE))
18148 return 1;
18149 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
18150 }
18151
18152 unsigned long
18153 -print_context_stack(struct thread_info *tinfo,
18154 +print_context_stack(struct task_struct *task, void *stack_start,
18155 unsigned long *stack, unsigned long bp,
18156 const struct stacktrace_ops *ops, void *data,
18157 unsigned long *end, int *graph)
18158 {
18159 struct stack_frame *frame = (struct stack_frame *)bp;
18160
18161 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
18162 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
18163 unsigned long addr;
18164
18165 addr = *stack;
18166 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
18167 } else {
18168 ops->address(data, addr, 0);
18169 }
18170 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18171 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18172 }
18173 stack++;
18174 }
18175 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
18176 EXPORT_SYMBOL_GPL(print_context_stack);
18177
18178 unsigned long
18179 -print_context_stack_bp(struct thread_info *tinfo,
18180 +print_context_stack_bp(struct task_struct *task, void *stack_start,
18181 unsigned long *stack, unsigned long bp,
18182 const struct stacktrace_ops *ops, void *data,
18183 unsigned long *end, int *graph)
18184 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18185 struct stack_frame *frame = (struct stack_frame *)bp;
18186 unsigned long *ret_addr = &frame->return_address;
18187
18188 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
18189 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
18190 unsigned long addr = *ret_addr;
18191
18192 if (!__kernel_text_address(addr))
18193 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18194 ops->address(data, addr, 1);
18195 frame = frame->next_frame;
18196 ret_addr = &frame->return_address;
18197 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18198 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18199 }
18200
18201 return (unsigned long)frame;
18202 @@ -189,7 +188,7 @@ void dump_stack(void)
18203
18204 bp = stack_frame(current, NULL);
18205 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
18206 - current->pid, current->comm, print_tainted(),
18207 + task_pid_nr(current), current->comm, print_tainted(),
18208 init_utsname()->release,
18209 (int)strcspn(init_utsname()->version, " "),
18210 init_utsname()->version);
18211 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
18212 }
18213 EXPORT_SYMBOL_GPL(oops_begin);
18214
18215 +extern void gr_handle_kernel_exploit(void);
18216 +
18217 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18218 {
18219 if (regs && kexec_should_crash(current))
18220 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18221 panic("Fatal exception in interrupt");
18222 if (panic_on_oops)
18223 panic("Fatal exception");
18224 - do_exit(signr);
18225 +
18226 + gr_handle_kernel_exploit();
18227 +
18228 + do_group_exit(signr);
18229 }
18230
18231 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18232 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18233 print_modules();
18234 show_regs(regs);
18235 #ifdef CONFIG_X86_32
18236 - if (user_mode_vm(regs)) {
18237 + if (user_mode(regs)) {
18238 sp = regs->sp;
18239 ss = regs->ss & 0xffff;
18240 } else {
18241 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
18242 unsigned long flags = oops_begin();
18243 int sig = SIGSEGV;
18244
18245 - if (!user_mode_vm(regs))
18246 + if (!user_mode(regs))
18247 report_bug(regs->ip, regs);
18248
18249 if (__die(str, regs, err))
18250 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
18251 index 1038a41..db2c12b 100644
18252 --- a/arch/x86/kernel/dumpstack_32.c
18253 +++ b/arch/x86/kernel/dumpstack_32.c
18254 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18255 bp = stack_frame(task, regs);
18256
18257 for (;;) {
18258 - struct thread_info *context;
18259 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18260
18261 - context = (struct thread_info *)
18262 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
18263 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
18264 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18265
18266 - stack = (unsigned long *)context->previous_esp;
18267 - if (!stack)
18268 + if (stack_start == task_stack_page(task))
18269 break;
18270 + stack = *(unsigned long **)stack_start;
18271 if (ops->stack(data, "IRQ") < 0)
18272 break;
18273 touch_nmi_watchdog();
18274 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
18275 {
18276 int i;
18277
18278 - __show_regs(regs, !user_mode_vm(regs));
18279 + __show_regs(regs, !user_mode(regs));
18280
18281 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
18282 TASK_COMM_LEN, current->comm, task_pid_nr(current),
18283 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
18284 * When in-kernel, we also print out the stack and code at the
18285 * time of the fault..
18286 */
18287 - if (!user_mode_vm(regs)) {
18288 + if (!user_mode(regs)) {
18289 unsigned int code_prologue = code_bytes * 43 / 64;
18290 unsigned int code_len = code_bytes;
18291 unsigned char c;
18292 u8 *ip;
18293 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18294
18295 pr_emerg("Stack:\n");
18296 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18297
18298 pr_emerg("Code:");
18299
18300 - ip = (u8 *)regs->ip - code_prologue;
18301 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18302 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18303 /* try starting at IP */
18304 - ip = (u8 *)regs->ip;
18305 + ip = (u8 *)regs->ip + cs_base;
18306 code_len = code_len - code_prologue + 1;
18307 }
18308 for (i = 0; i < code_len; i++, ip++) {
18309 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
18310 pr_cont(" Bad EIP value.");
18311 break;
18312 }
18313 - if (ip == (u8 *)regs->ip)
18314 + if (ip == (u8 *)regs->ip + cs_base)
18315 pr_cont(" <%02x>", c);
18316 else
18317 pr_cont(" %02x", c);
18318 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
18319 {
18320 unsigned short ud2;
18321
18322 + ip = ktla_ktva(ip);
18323 if (ip < PAGE_OFFSET)
18324 return 0;
18325 if (probe_kernel_address((unsigned short *)ip, ud2))
18326 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18327
18328 return ud2 == 0x0b0f;
18329 }
18330 +
18331 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18332 +void pax_check_alloca(unsigned long size)
18333 +{
18334 + unsigned long sp = (unsigned long)&sp, stack_left;
18335 +
18336 + /* all kernel stacks are of the same size */
18337 + stack_left = sp & (THREAD_SIZE - 1);
18338 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18339 +}
18340 +EXPORT_SYMBOL(pax_check_alloca);
18341 +#endif
18342 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18343 index b653675..51cc8c0 100644
18344 --- a/arch/x86/kernel/dumpstack_64.c
18345 +++ b/arch/x86/kernel/dumpstack_64.c
18346 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18347 unsigned long *irq_stack_end =
18348 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18349 unsigned used = 0;
18350 - struct thread_info *tinfo;
18351 int graph = 0;
18352 unsigned long dummy;
18353 + void *stack_start;
18354
18355 if (!task)
18356 task = current;
18357 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18358 * current stack address. If the stacks consist of nested
18359 * exceptions
18360 */
18361 - tinfo = task_thread_info(task);
18362 for (;;) {
18363 char *id;
18364 unsigned long *estack_end;
18365 +
18366 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18367 &used, &id);
18368
18369 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18370 if (ops->stack(data, id) < 0)
18371 break;
18372
18373 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18374 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18375 data, estack_end, &graph);
18376 ops->stack(data, "<EOE>");
18377 /*
18378 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18379 * second-to-last pointer (index -2 to end) in the
18380 * exception stack:
18381 */
18382 + if ((u16)estack_end[-1] != __KERNEL_DS)
18383 + goto out;
18384 stack = (unsigned long *) estack_end[-2];
18385 continue;
18386 }
18387 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18388 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18389 if (ops->stack(data, "IRQ") < 0)
18390 break;
18391 - bp = ops->walk_stack(tinfo, stack, bp,
18392 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18393 ops, data, irq_stack_end, &graph);
18394 /*
18395 * We link to the next stack (which would be
18396 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18397 /*
18398 * This handles the process stack:
18399 */
18400 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18401 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18402 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18403 +out:
18404 put_cpu();
18405 }
18406 EXPORT_SYMBOL(dump_trace);
18407 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18408 {
18409 int i;
18410 unsigned long sp;
18411 - const int cpu = smp_processor_id();
18412 + const int cpu = raw_smp_processor_id();
18413 struct task_struct *cur = current;
18414
18415 sp = regs->sp;
18416 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18417
18418 return ud2 == 0x0b0f;
18419 }
18420 +
18421 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18422 +void pax_check_alloca(unsigned long size)
18423 +{
18424 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18425 + unsigned cpu, used;
18426 + char *id;
18427 +
18428 + /* check the process stack first */
18429 + stack_start = (unsigned long)task_stack_page(current);
18430 + stack_end = stack_start + THREAD_SIZE;
18431 + if (likely(stack_start <= sp && sp < stack_end)) {
18432 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18433 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18434 + return;
18435 + }
18436 +
18437 + cpu = get_cpu();
18438 +
18439 + /* check the irq stacks */
18440 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18441 + stack_start = stack_end - IRQ_STACK_SIZE;
18442 + if (stack_start <= sp && sp < stack_end) {
18443 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18444 + put_cpu();
18445 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18446 + return;
18447 + }
18448 +
18449 + /* check the exception stacks */
18450 + used = 0;
18451 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18452 + stack_start = stack_end - EXCEPTION_STKSZ;
18453 + if (stack_end && stack_start <= sp && sp < stack_end) {
18454 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18455 + put_cpu();
18456 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18457 + return;
18458 + }
18459 +
18460 + put_cpu();
18461 +
18462 + /* unknown stack */
18463 + BUG();
18464 +}
18465 +EXPORT_SYMBOL(pax_check_alloca);
18466 +#endif
18467 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18468 index 9b9f18b..9fcaa04 100644
18469 --- a/arch/x86/kernel/early_printk.c
18470 +++ b/arch/x86/kernel/early_printk.c
18471 @@ -7,6 +7,7 @@
18472 #include <linux/pci_regs.h>
18473 #include <linux/pci_ids.h>
18474 #include <linux/errno.h>
18475 +#include <linux/sched.h>
18476 #include <asm/io.h>
18477 #include <asm/processor.h>
18478 #include <asm/fcntl.h>
18479 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18480 index 6ed91d9..6cc365b 100644
18481 --- a/arch/x86/kernel/entry_32.S
18482 +++ b/arch/x86/kernel/entry_32.S
18483 @@ -177,13 +177,153 @@
18484 /*CFI_REL_OFFSET gs, PT_GS*/
18485 .endm
18486 .macro SET_KERNEL_GS reg
18487 +
18488 +#ifdef CONFIG_CC_STACKPROTECTOR
18489 movl $(__KERNEL_STACK_CANARY), \reg
18490 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18491 + movl $(__USER_DS), \reg
18492 +#else
18493 + xorl \reg, \reg
18494 +#endif
18495 +
18496 movl \reg, %gs
18497 .endm
18498
18499 #endif /* CONFIG_X86_32_LAZY_GS */
18500
18501 -.macro SAVE_ALL
18502 +.macro pax_enter_kernel
18503 +#ifdef CONFIG_PAX_KERNEXEC
18504 + call pax_enter_kernel
18505 +#endif
18506 +.endm
18507 +
18508 +.macro pax_exit_kernel
18509 +#ifdef CONFIG_PAX_KERNEXEC
18510 + call pax_exit_kernel
18511 +#endif
18512 +.endm
18513 +
18514 +#ifdef CONFIG_PAX_KERNEXEC
18515 +ENTRY(pax_enter_kernel)
18516 +#ifdef CONFIG_PARAVIRT
18517 + pushl %eax
18518 + pushl %ecx
18519 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18520 + mov %eax, %esi
18521 +#else
18522 + mov %cr0, %esi
18523 +#endif
18524 + bts $16, %esi
18525 + jnc 1f
18526 + mov %cs, %esi
18527 + cmp $__KERNEL_CS, %esi
18528 + jz 3f
18529 + ljmp $__KERNEL_CS, $3f
18530 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18531 +2:
18532 +#ifdef CONFIG_PARAVIRT
18533 + mov %esi, %eax
18534 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18535 +#else
18536 + mov %esi, %cr0
18537 +#endif
18538 +3:
18539 +#ifdef CONFIG_PARAVIRT
18540 + popl %ecx
18541 + popl %eax
18542 +#endif
18543 + ret
18544 +ENDPROC(pax_enter_kernel)
18545 +
18546 +ENTRY(pax_exit_kernel)
18547 +#ifdef CONFIG_PARAVIRT
18548 + pushl %eax
18549 + pushl %ecx
18550 +#endif
18551 + mov %cs, %esi
18552 + cmp $__KERNEXEC_KERNEL_CS, %esi
18553 + jnz 2f
18554 +#ifdef CONFIG_PARAVIRT
18555 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18556 + mov %eax, %esi
18557 +#else
18558 + mov %cr0, %esi
18559 +#endif
18560 + btr $16, %esi
18561 + ljmp $__KERNEL_CS, $1f
18562 +1:
18563 +#ifdef CONFIG_PARAVIRT
18564 + mov %esi, %eax
18565 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18566 +#else
18567 + mov %esi, %cr0
18568 +#endif
18569 +2:
18570 +#ifdef CONFIG_PARAVIRT
18571 + popl %ecx
18572 + popl %eax
18573 +#endif
18574 + ret
18575 +ENDPROC(pax_exit_kernel)
18576 +#endif
18577 +
18578 +.macro pax_erase_kstack
18579 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18580 + call pax_erase_kstack
18581 +#endif
18582 +.endm
18583 +
18584 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18585 +/*
18586 + * ebp: thread_info
18587 + */
18588 +ENTRY(pax_erase_kstack)
18589 + pushl %edi
18590 + pushl %ecx
18591 + pushl %eax
18592 +
18593 + mov TI_lowest_stack(%ebp), %edi
18594 + mov $-0xBEEF, %eax
18595 + std
18596 +
18597 +1: mov %edi, %ecx
18598 + and $THREAD_SIZE_asm - 1, %ecx
18599 + shr $2, %ecx
18600 + repne scasl
18601 + jecxz 2f
18602 +
18603 + cmp $2*16, %ecx
18604 + jc 2f
18605 +
18606 + mov $2*16, %ecx
18607 + repe scasl
18608 + jecxz 2f
18609 + jne 1b
18610 +
18611 +2: cld
18612 + mov %esp, %ecx
18613 + sub %edi, %ecx
18614 +
18615 + cmp $THREAD_SIZE_asm, %ecx
18616 + jb 3f
18617 + ud2
18618 +3:
18619 +
18620 + shr $2, %ecx
18621 + rep stosl
18622 +
18623 + mov TI_task_thread_sp0(%ebp), %edi
18624 + sub $128, %edi
18625 + mov %edi, TI_lowest_stack(%ebp)
18626 +
18627 + popl %eax
18628 + popl %ecx
18629 + popl %edi
18630 + ret
18631 +ENDPROC(pax_erase_kstack)
18632 +#endif
18633 +
18634 +.macro __SAVE_ALL _DS
18635 cld
18636 PUSH_GS
18637 pushl_cfi %fs
18638 @@ -206,7 +346,7 @@
18639 CFI_REL_OFFSET ecx, 0
18640 pushl_cfi %ebx
18641 CFI_REL_OFFSET ebx, 0
18642 - movl $(__USER_DS), %edx
18643 + movl $\_DS, %edx
18644 movl %edx, %ds
18645 movl %edx, %es
18646 movl $(__KERNEL_PERCPU), %edx
18647 @@ -214,6 +354,15 @@
18648 SET_KERNEL_GS %edx
18649 .endm
18650
18651 +.macro SAVE_ALL
18652 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18653 + __SAVE_ALL __KERNEL_DS
18654 + pax_enter_kernel
18655 +#else
18656 + __SAVE_ALL __USER_DS
18657 +#endif
18658 +.endm
18659 +
18660 .macro RESTORE_INT_REGS
18661 popl_cfi %ebx
18662 CFI_RESTORE ebx
18663 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18664 popfl_cfi
18665 jmp syscall_exit
18666 CFI_ENDPROC
18667 -END(ret_from_fork)
18668 +ENDPROC(ret_from_fork)
18669
18670 ENTRY(ret_from_kernel_thread)
18671 CFI_STARTPROC
18672 @@ -344,7 +493,15 @@ ret_from_intr:
18673 andl $SEGMENT_RPL_MASK, %eax
18674 #endif
18675 cmpl $USER_RPL, %eax
18676 +
18677 +#ifdef CONFIG_PAX_KERNEXEC
18678 + jae resume_userspace
18679 +
18680 + pax_exit_kernel
18681 + jmp resume_kernel
18682 +#else
18683 jb resume_kernel # not returning to v8086 or userspace
18684 +#endif
18685
18686 ENTRY(resume_userspace)
18687 LOCKDEP_SYS_EXIT
18688 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18689 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18690 # int/exception return?
18691 jne work_pending
18692 - jmp restore_all
18693 -END(ret_from_exception)
18694 + jmp restore_all_pax
18695 +ENDPROC(ret_from_exception)
18696
18697 #ifdef CONFIG_PREEMPT
18698 ENTRY(resume_kernel)
18699 @@ -372,7 +529,7 @@ need_resched:
18700 jz restore_all
18701 call preempt_schedule_irq
18702 jmp need_resched
18703 -END(resume_kernel)
18704 +ENDPROC(resume_kernel)
18705 #endif
18706 CFI_ENDPROC
18707 /*
18708 @@ -406,30 +563,45 @@ sysenter_past_esp:
18709 /*CFI_REL_OFFSET cs, 0*/
18710 /*
18711 * Push current_thread_info()->sysenter_return to the stack.
18712 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18713 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18714 */
18715 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18716 + pushl_cfi $0
18717 CFI_REL_OFFSET eip, 0
18718
18719 pushl_cfi %eax
18720 SAVE_ALL
18721 + GET_THREAD_INFO(%ebp)
18722 + movl TI_sysenter_return(%ebp),%ebp
18723 + movl %ebp,PT_EIP(%esp)
18724 ENABLE_INTERRUPTS(CLBR_NONE)
18725
18726 /*
18727 * Load the potential sixth argument from user stack.
18728 * Careful about security.
18729 */
18730 + movl PT_OLDESP(%esp),%ebp
18731 +
18732 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18733 + mov PT_OLDSS(%esp),%ds
18734 +1: movl %ds:(%ebp),%ebp
18735 + push %ss
18736 + pop %ds
18737 +#else
18738 cmpl $__PAGE_OFFSET-3,%ebp
18739 jae syscall_fault
18740 ASM_STAC
18741 1: movl (%ebp),%ebp
18742 ASM_CLAC
18743 +#endif
18744 +
18745 movl %ebp,PT_EBP(%esp)
18746 _ASM_EXTABLE(1b,syscall_fault)
18747
18748 GET_THREAD_INFO(%ebp)
18749
18750 +#ifdef CONFIG_PAX_RANDKSTACK
18751 + pax_erase_kstack
18752 +#endif
18753 +
18754 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18755 jnz sysenter_audit
18756 sysenter_do_call:
18757 @@ -444,12 +616,24 @@ sysenter_do_call:
18758 testl $_TIF_ALLWORK_MASK, %ecx
18759 jne sysexit_audit
18760 sysenter_exit:
18761 +
18762 +#ifdef CONFIG_PAX_RANDKSTACK
18763 + pushl_cfi %eax
18764 + movl %esp, %eax
18765 + call pax_randomize_kstack
18766 + popl_cfi %eax
18767 +#endif
18768 +
18769 + pax_erase_kstack
18770 +
18771 /* if something modifies registers it must also disable sysexit */
18772 movl PT_EIP(%esp), %edx
18773 movl PT_OLDESP(%esp), %ecx
18774 xorl %ebp,%ebp
18775 TRACE_IRQS_ON
18776 1: mov PT_FS(%esp), %fs
18777 +2: mov PT_DS(%esp), %ds
18778 +3: mov PT_ES(%esp), %es
18779 PTGS_TO_GS
18780 ENABLE_INTERRUPTS_SYSEXIT
18781
18782 @@ -466,6 +650,9 @@ sysenter_audit:
18783 movl %eax,%edx /* 2nd arg: syscall number */
18784 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18785 call __audit_syscall_entry
18786 +
18787 + pax_erase_kstack
18788 +
18789 pushl_cfi %ebx
18790 movl PT_EAX(%esp),%eax /* reload syscall number */
18791 jmp sysenter_do_call
18792 @@ -491,10 +678,16 @@ sysexit_audit:
18793
18794 CFI_ENDPROC
18795 .pushsection .fixup,"ax"
18796 -2: movl $0,PT_FS(%esp)
18797 +4: movl $0,PT_FS(%esp)
18798 + jmp 1b
18799 +5: movl $0,PT_DS(%esp)
18800 + jmp 1b
18801 +6: movl $0,PT_ES(%esp)
18802 jmp 1b
18803 .popsection
18804 - _ASM_EXTABLE(1b,2b)
18805 + _ASM_EXTABLE(1b,4b)
18806 + _ASM_EXTABLE(2b,5b)
18807 + _ASM_EXTABLE(3b,6b)
18808 PTGS_TO_GS_EX
18809 ENDPROC(ia32_sysenter_target)
18810
18811 @@ -509,6 +702,11 @@ ENTRY(system_call)
18812 pushl_cfi %eax # save orig_eax
18813 SAVE_ALL
18814 GET_THREAD_INFO(%ebp)
18815 +
18816 +#ifdef CONFIG_PAX_RANDKSTACK
18817 + pax_erase_kstack
18818 +#endif
18819 +
18820 # system call tracing in operation / emulation
18821 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18822 jnz syscall_trace_entry
18823 @@ -527,6 +725,15 @@ syscall_exit:
18824 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18825 jne syscall_exit_work
18826
18827 +restore_all_pax:
18828 +
18829 +#ifdef CONFIG_PAX_RANDKSTACK
18830 + movl %esp, %eax
18831 + call pax_randomize_kstack
18832 +#endif
18833 +
18834 + pax_erase_kstack
18835 +
18836 restore_all:
18837 TRACE_IRQS_IRET
18838 restore_all_notrace:
18839 @@ -583,14 +790,34 @@ ldt_ss:
18840 * compensating for the offset by changing to the ESPFIX segment with
18841 * a base address that matches for the difference.
18842 */
18843 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18844 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18845 mov %esp, %edx /* load kernel esp */
18846 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18847 mov %dx, %ax /* eax: new kernel esp */
18848 sub %eax, %edx /* offset (low word is 0) */
18849 +#ifdef CONFIG_SMP
18850 + movl PER_CPU_VAR(cpu_number), %ebx
18851 + shll $PAGE_SHIFT_asm, %ebx
18852 + addl $cpu_gdt_table, %ebx
18853 +#else
18854 + movl $cpu_gdt_table, %ebx
18855 +#endif
18856 shr $16, %edx
18857 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18858 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18859 +
18860 +#ifdef CONFIG_PAX_KERNEXEC
18861 + mov %cr0, %esi
18862 + btr $16, %esi
18863 + mov %esi, %cr0
18864 +#endif
18865 +
18866 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18867 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18868 +
18869 +#ifdef CONFIG_PAX_KERNEXEC
18870 + bts $16, %esi
18871 + mov %esi, %cr0
18872 +#endif
18873 +
18874 pushl_cfi $__ESPFIX_SS
18875 pushl_cfi %eax /* new kernel esp */
18876 /* Disable interrupts, but do not irqtrace this section: we
18877 @@ -619,20 +846,18 @@ work_resched:
18878 movl TI_flags(%ebp), %ecx
18879 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18880 # than syscall tracing?
18881 - jz restore_all
18882 + jz restore_all_pax
18883 testb $_TIF_NEED_RESCHED, %cl
18884 jnz work_resched
18885
18886 work_notifysig: # deal with pending signals and
18887 # notify-resume requests
18888 + movl %esp, %eax
18889 #ifdef CONFIG_VM86
18890 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18891 - movl %esp, %eax
18892 jne work_notifysig_v86 # returning to kernel-space or
18893 # vm86-space
18894 1:
18895 -#else
18896 - movl %esp, %eax
18897 #endif
18898 TRACE_IRQS_ON
18899 ENABLE_INTERRUPTS(CLBR_NONE)
18900 @@ -653,7 +878,7 @@ work_notifysig_v86:
18901 movl %eax, %esp
18902 jmp 1b
18903 #endif
18904 -END(work_pending)
18905 +ENDPROC(work_pending)
18906
18907 # perform syscall exit tracing
18908 ALIGN
18909 @@ -661,11 +886,14 @@ syscall_trace_entry:
18910 movl $-ENOSYS,PT_EAX(%esp)
18911 movl %esp, %eax
18912 call syscall_trace_enter
18913 +
18914 + pax_erase_kstack
18915 +
18916 /* What it returned is what we'll actually use. */
18917 cmpl $(NR_syscalls), %eax
18918 jnae syscall_call
18919 jmp syscall_exit
18920 -END(syscall_trace_entry)
18921 +ENDPROC(syscall_trace_entry)
18922
18923 # perform syscall exit tracing
18924 ALIGN
18925 @@ -678,21 +906,25 @@ syscall_exit_work:
18926 movl %esp, %eax
18927 call syscall_trace_leave
18928 jmp resume_userspace
18929 -END(syscall_exit_work)
18930 +ENDPROC(syscall_exit_work)
18931 CFI_ENDPROC
18932
18933 RING0_INT_FRAME # can't unwind into user space anyway
18934 syscall_fault:
18935 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18936 + push %ss
18937 + pop %ds
18938 +#endif
18939 ASM_CLAC
18940 GET_THREAD_INFO(%ebp)
18941 movl $-EFAULT,PT_EAX(%esp)
18942 jmp resume_userspace
18943 -END(syscall_fault)
18944 +ENDPROC(syscall_fault)
18945
18946 syscall_badsys:
18947 movl $-ENOSYS,PT_EAX(%esp)
18948 jmp resume_userspace
18949 -END(syscall_badsys)
18950 +ENDPROC(syscall_badsys)
18951 CFI_ENDPROC
18952 /*
18953 * End of kprobes section
18954 @@ -753,8 +985,15 @@ PTREGSCALL1(vm86old)
18955 * normal stack and adjusts ESP with the matching offset.
18956 */
18957 /* fixup the stack */
18958 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18959 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18960 +#ifdef CONFIG_SMP
18961 + movl PER_CPU_VAR(cpu_number), %ebx
18962 + shll $PAGE_SHIFT_asm, %ebx
18963 + addl $cpu_gdt_table, %ebx
18964 +#else
18965 + movl $cpu_gdt_table, %ebx
18966 +#endif
18967 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18968 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18969 shl $16, %eax
18970 addl %esp, %eax /* the adjusted stack pointer */
18971 pushl_cfi $__KERNEL_DS
18972 @@ -807,7 +1046,7 @@ vector=vector+1
18973 .endr
18974 2: jmp common_interrupt
18975 .endr
18976 -END(irq_entries_start)
18977 +ENDPROC(irq_entries_start)
18978
18979 .previous
18980 END(interrupt)
18981 @@ -858,7 +1097,7 @@ ENTRY(coprocessor_error)
18982 pushl_cfi $do_coprocessor_error
18983 jmp error_code
18984 CFI_ENDPROC
18985 -END(coprocessor_error)
18986 +ENDPROC(coprocessor_error)
18987
18988 ENTRY(simd_coprocessor_error)
18989 RING0_INT_FRAME
18990 @@ -880,7 +1119,7 @@ ENTRY(simd_coprocessor_error)
18991 #endif
18992 jmp error_code
18993 CFI_ENDPROC
18994 -END(simd_coprocessor_error)
18995 +ENDPROC(simd_coprocessor_error)
18996
18997 ENTRY(device_not_available)
18998 RING0_INT_FRAME
18999 @@ -889,18 +1128,18 @@ ENTRY(device_not_available)
19000 pushl_cfi $do_device_not_available
19001 jmp error_code
19002 CFI_ENDPROC
19003 -END(device_not_available)
19004 +ENDPROC(device_not_available)
19005
19006 #ifdef CONFIG_PARAVIRT
19007 ENTRY(native_iret)
19008 iret
19009 _ASM_EXTABLE(native_iret, iret_exc)
19010 -END(native_iret)
19011 +ENDPROC(native_iret)
19012
19013 ENTRY(native_irq_enable_sysexit)
19014 sti
19015 sysexit
19016 -END(native_irq_enable_sysexit)
19017 +ENDPROC(native_irq_enable_sysexit)
19018 #endif
19019
19020 ENTRY(overflow)
19021 @@ -910,7 +1149,7 @@ ENTRY(overflow)
19022 pushl_cfi $do_overflow
19023 jmp error_code
19024 CFI_ENDPROC
19025 -END(overflow)
19026 +ENDPROC(overflow)
19027
19028 ENTRY(bounds)
19029 RING0_INT_FRAME
19030 @@ -919,7 +1158,7 @@ ENTRY(bounds)
19031 pushl_cfi $do_bounds
19032 jmp error_code
19033 CFI_ENDPROC
19034 -END(bounds)
19035 +ENDPROC(bounds)
19036
19037 ENTRY(invalid_op)
19038 RING0_INT_FRAME
19039 @@ -928,7 +1167,7 @@ ENTRY(invalid_op)
19040 pushl_cfi $do_invalid_op
19041 jmp error_code
19042 CFI_ENDPROC
19043 -END(invalid_op)
19044 +ENDPROC(invalid_op)
19045
19046 ENTRY(coprocessor_segment_overrun)
19047 RING0_INT_FRAME
19048 @@ -937,7 +1176,7 @@ ENTRY(coprocessor_segment_overrun)
19049 pushl_cfi $do_coprocessor_segment_overrun
19050 jmp error_code
19051 CFI_ENDPROC
19052 -END(coprocessor_segment_overrun)
19053 +ENDPROC(coprocessor_segment_overrun)
19054
19055 ENTRY(invalid_TSS)
19056 RING0_EC_FRAME
19057 @@ -945,7 +1184,7 @@ ENTRY(invalid_TSS)
19058 pushl_cfi $do_invalid_TSS
19059 jmp error_code
19060 CFI_ENDPROC
19061 -END(invalid_TSS)
19062 +ENDPROC(invalid_TSS)
19063
19064 ENTRY(segment_not_present)
19065 RING0_EC_FRAME
19066 @@ -953,7 +1192,7 @@ ENTRY(segment_not_present)
19067 pushl_cfi $do_segment_not_present
19068 jmp error_code
19069 CFI_ENDPROC
19070 -END(segment_not_present)
19071 +ENDPROC(segment_not_present)
19072
19073 ENTRY(stack_segment)
19074 RING0_EC_FRAME
19075 @@ -961,7 +1200,7 @@ ENTRY(stack_segment)
19076 pushl_cfi $do_stack_segment
19077 jmp error_code
19078 CFI_ENDPROC
19079 -END(stack_segment)
19080 +ENDPROC(stack_segment)
19081
19082 ENTRY(alignment_check)
19083 RING0_EC_FRAME
19084 @@ -969,7 +1208,7 @@ ENTRY(alignment_check)
19085 pushl_cfi $do_alignment_check
19086 jmp error_code
19087 CFI_ENDPROC
19088 -END(alignment_check)
19089 +ENDPROC(alignment_check)
19090
19091 ENTRY(divide_error)
19092 RING0_INT_FRAME
19093 @@ -978,7 +1217,7 @@ ENTRY(divide_error)
19094 pushl_cfi $do_divide_error
19095 jmp error_code
19096 CFI_ENDPROC
19097 -END(divide_error)
19098 +ENDPROC(divide_error)
19099
19100 #ifdef CONFIG_X86_MCE
19101 ENTRY(machine_check)
19102 @@ -988,7 +1227,7 @@ ENTRY(machine_check)
19103 pushl_cfi machine_check_vector
19104 jmp error_code
19105 CFI_ENDPROC
19106 -END(machine_check)
19107 +ENDPROC(machine_check)
19108 #endif
19109
19110 ENTRY(spurious_interrupt_bug)
19111 @@ -998,7 +1237,7 @@ ENTRY(spurious_interrupt_bug)
19112 pushl_cfi $do_spurious_interrupt_bug
19113 jmp error_code
19114 CFI_ENDPROC
19115 -END(spurious_interrupt_bug)
19116 +ENDPROC(spurious_interrupt_bug)
19117 /*
19118 * End of kprobes section
19119 */
19120 @@ -1101,7 +1340,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
19121
19122 ENTRY(mcount)
19123 ret
19124 -END(mcount)
19125 +ENDPROC(mcount)
19126
19127 ENTRY(ftrace_caller)
19128 cmpl $0, function_trace_stop
19129 @@ -1134,7 +1373,7 @@ ftrace_graph_call:
19130 .globl ftrace_stub
19131 ftrace_stub:
19132 ret
19133 -END(ftrace_caller)
19134 +ENDPROC(ftrace_caller)
19135
19136 ENTRY(ftrace_regs_caller)
19137 pushf /* push flags before compare (in cs location) */
19138 @@ -1235,7 +1474,7 @@ trace:
19139 popl %ecx
19140 popl %eax
19141 jmp ftrace_stub
19142 -END(mcount)
19143 +ENDPROC(mcount)
19144 #endif /* CONFIG_DYNAMIC_FTRACE */
19145 #endif /* CONFIG_FUNCTION_TRACER */
19146
19147 @@ -1253,7 +1492,7 @@ ENTRY(ftrace_graph_caller)
19148 popl %ecx
19149 popl %eax
19150 ret
19151 -END(ftrace_graph_caller)
19152 +ENDPROC(ftrace_graph_caller)
19153
19154 .globl return_to_handler
19155 return_to_handler:
19156 @@ -1309,15 +1548,18 @@ error_code:
19157 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
19158 REG_TO_PTGS %ecx
19159 SET_KERNEL_GS %ecx
19160 - movl $(__USER_DS), %ecx
19161 + movl $(__KERNEL_DS), %ecx
19162 movl %ecx, %ds
19163 movl %ecx, %es
19164 +
19165 + pax_enter_kernel
19166 +
19167 TRACE_IRQS_OFF
19168 movl %esp,%eax # pt_regs pointer
19169 call *%edi
19170 jmp ret_from_exception
19171 CFI_ENDPROC
19172 -END(page_fault)
19173 +ENDPROC(page_fault)
19174
19175 /*
19176 * Debug traps and NMI can happen at the one SYSENTER instruction
19177 @@ -1360,7 +1602,7 @@ debug_stack_correct:
19178 call do_debug
19179 jmp ret_from_exception
19180 CFI_ENDPROC
19181 -END(debug)
19182 +ENDPROC(debug)
19183
19184 /*
19185 * NMI is doubly nasty. It can happen _while_ we're handling
19186 @@ -1398,6 +1640,9 @@ nmi_stack_correct:
19187 xorl %edx,%edx # zero error code
19188 movl %esp,%eax # pt_regs pointer
19189 call do_nmi
19190 +
19191 + pax_exit_kernel
19192 +
19193 jmp restore_all_notrace
19194 CFI_ENDPROC
19195
19196 @@ -1434,12 +1679,15 @@ nmi_espfix_stack:
19197 FIXUP_ESPFIX_STACK # %eax == %esp
19198 xorl %edx,%edx # zero error code
19199 call do_nmi
19200 +
19201 + pax_exit_kernel
19202 +
19203 RESTORE_REGS
19204 lss 12+4(%esp), %esp # back to espfix stack
19205 CFI_ADJUST_CFA_OFFSET -24
19206 jmp irq_return
19207 CFI_ENDPROC
19208 -END(nmi)
19209 +ENDPROC(nmi)
19210
19211 ENTRY(int3)
19212 RING0_INT_FRAME
19213 @@ -1452,14 +1700,14 @@ ENTRY(int3)
19214 call do_int3
19215 jmp ret_from_exception
19216 CFI_ENDPROC
19217 -END(int3)
19218 +ENDPROC(int3)
19219
19220 ENTRY(general_protection)
19221 RING0_EC_FRAME
19222 pushl_cfi $do_general_protection
19223 jmp error_code
19224 CFI_ENDPROC
19225 -END(general_protection)
19226 +ENDPROC(general_protection)
19227
19228 #ifdef CONFIG_KVM_GUEST
19229 ENTRY(async_page_fault)
19230 @@ -1468,7 +1716,7 @@ ENTRY(async_page_fault)
19231 pushl_cfi $do_async_page_fault
19232 jmp error_code
19233 CFI_ENDPROC
19234 -END(async_page_fault)
19235 +ENDPROC(async_page_fault)
19236 #endif
19237
19238 /*
19239 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
19240 index cb3c591..bc63707 100644
19241 --- a/arch/x86/kernel/entry_64.S
19242 +++ b/arch/x86/kernel/entry_64.S
19243 @@ -59,6 +59,8 @@
19244 #include <asm/context_tracking.h>
19245 #include <asm/smap.h>
19246 #include <linux/err.h>
19247 +#include <asm/pgtable.h>
19248 +#include <asm/alternative-asm.h>
19249
19250 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
19251 #include <linux/elf-em.h>
19252 @@ -80,8 +82,9 @@
19253 #ifdef CONFIG_DYNAMIC_FTRACE
19254
19255 ENTRY(function_hook)
19256 + pax_force_retaddr
19257 retq
19258 -END(function_hook)
19259 +ENDPROC(function_hook)
19260
19261 /* skip is set if stack has been adjusted */
19262 .macro ftrace_caller_setup skip=0
19263 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
19264 #endif
19265
19266 GLOBAL(ftrace_stub)
19267 + pax_force_retaddr
19268 retq
19269 -END(ftrace_caller)
19270 +ENDPROC(ftrace_caller)
19271
19272 ENTRY(ftrace_regs_caller)
19273 /* Save the current flags before compare (in SS location)*/
19274 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19275 popfq
19276 jmp ftrace_stub
19277
19278 -END(ftrace_regs_caller)
19279 +ENDPROC(ftrace_regs_caller)
19280
19281
19282 #else /* ! CONFIG_DYNAMIC_FTRACE */
19283 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19284 #endif
19285
19286 GLOBAL(ftrace_stub)
19287 + pax_force_retaddr
19288 retq
19289
19290 trace:
19291 @@ -225,12 +230,13 @@ trace:
19292 #endif
19293 subq $MCOUNT_INSN_SIZE, %rdi
19294
19295 + pax_force_fptr ftrace_trace_function
19296 call *ftrace_trace_function
19297
19298 MCOUNT_RESTORE_FRAME
19299
19300 jmp ftrace_stub
19301 -END(function_hook)
19302 +ENDPROC(function_hook)
19303 #endif /* CONFIG_DYNAMIC_FTRACE */
19304 #endif /* CONFIG_FUNCTION_TRACER */
19305
19306 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19307
19308 MCOUNT_RESTORE_FRAME
19309
19310 + pax_force_retaddr
19311 retq
19312 -END(ftrace_graph_caller)
19313 +ENDPROC(ftrace_graph_caller)
19314
19315 GLOBAL(return_to_handler)
19316 subq $24, %rsp
19317 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19318 movq 8(%rsp), %rdx
19319 movq (%rsp), %rax
19320 addq $24, %rsp
19321 + pax_force_fptr %rdi
19322 jmp *%rdi
19323 +ENDPROC(return_to_handler)
19324 #endif
19325
19326
19327 @@ -284,6 +293,273 @@ ENTRY(native_usergs_sysret64)
19328 ENDPROC(native_usergs_sysret64)
19329 #endif /* CONFIG_PARAVIRT */
19330
19331 + .macro ljmpq sel, off
19332 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19333 + .byte 0x48; ljmp *1234f(%rip)
19334 + .pushsection .rodata
19335 + .align 16
19336 + 1234: .quad \off; .word \sel
19337 + .popsection
19338 +#else
19339 + pushq $\sel
19340 + pushq $\off
19341 + lretq
19342 +#endif
19343 + .endm
19344 +
19345 + .macro pax_enter_kernel
19346 + pax_set_fptr_mask
19347 +#ifdef CONFIG_PAX_KERNEXEC
19348 + call pax_enter_kernel
19349 +#endif
19350 + .endm
19351 +
19352 + .macro pax_exit_kernel
19353 +#ifdef CONFIG_PAX_KERNEXEC
19354 + call pax_exit_kernel
19355 +#endif
19356 + .endm
19357 +
19358 +#ifdef CONFIG_PAX_KERNEXEC
19359 +ENTRY(pax_enter_kernel)
19360 + pushq %rdi
19361 +
19362 +#ifdef CONFIG_PARAVIRT
19363 + PV_SAVE_REGS(CLBR_RDI)
19364 +#endif
19365 +
19366 + GET_CR0_INTO_RDI
19367 + bts $16,%rdi
19368 + jnc 3f
19369 + mov %cs,%edi
19370 + cmp $__KERNEL_CS,%edi
19371 + jnz 2f
19372 +1:
19373 +
19374 +#ifdef CONFIG_PARAVIRT
19375 + PV_RESTORE_REGS(CLBR_RDI)
19376 +#endif
19377 +
19378 + popq %rdi
19379 + pax_force_retaddr
19380 + retq
19381 +
19382 +2: ljmpq __KERNEL_CS,1f
19383 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19384 +4: SET_RDI_INTO_CR0
19385 + jmp 1b
19386 +ENDPROC(pax_enter_kernel)
19387 +
19388 +ENTRY(pax_exit_kernel)
19389 + pushq %rdi
19390 +
19391 +#ifdef CONFIG_PARAVIRT
19392 + PV_SAVE_REGS(CLBR_RDI)
19393 +#endif
19394 +
19395 + mov %cs,%rdi
19396 + cmp $__KERNEXEC_KERNEL_CS,%edi
19397 + jz 2f
19398 +1:
19399 +
19400 +#ifdef CONFIG_PARAVIRT
19401 + PV_RESTORE_REGS(CLBR_RDI);
19402 +#endif
19403 +
19404 + popq %rdi
19405 + pax_force_retaddr
19406 + retq
19407 +
19408 +2: GET_CR0_INTO_RDI
19409 + btr $16,%rdi
19410 + ljmpq __KERNEL_CS,3f
19411 +3: SET_RDI_INTO_CR0
19412 + jmp 1b
19413 +ENDPROC(pax_exit_kernel)
19414 +#endif
19415 +
19416 + .macro pax_enter_kernel_user
19417 + pax_set_fptr_mask
19418 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19419 + call pax_enter_kernel_user
19420 +#endif
19421 + .endm
19422 +
19423 + .macro pax_exit_kernel_user
19424 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19425 + call pax_exit_kernel_user
19426 +#endif
19427 +#ifdef CONFIG_PAX_RANDKSTACK
19428 + pushq %rax
19429 + call pax_randomize_kstack
19430 + popq %rax
19431 +#endif
19432 + .endm
19433 +
19434 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19435 +ENTRY(pax_enter_kernel_user)
19436 + pushq %rdi
19437 + pushq %rbx
19438 +
19439 +#ifdef CONFIG_PARAVIRT
19440 + PV_SAVE_REGS(CLBR_RDI)
19441 +#endif
19442 +
19443 + GET_CR3_INTO_RDI
19444 + mov %rdi,%rbx
19445 + add $__START_KERNEL_map,%rbx
19446 + sub phys_base(%rip),%rbx
19447 +
19448 +#ifdef CONFIG_PARAVIRT
19449 + pushq %rdi
19450 + cmpl $0, pv_info+PARAVIRT_enabled
19451 + jz 1f
19452 + i = 0
19453 + .rept USER_PGD_PTRS
19454 + mov i*8(%rbx),%rsi
19455 + mov $0,%sil
19456 + lea i*8(%rbx),%rdi
19457 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19458 + i = i + 1
19459 + .endr
19460 + jmp 2f
19461 +1:
19462 +#endif
19463 +
19464 + i = 0
19465 + .rept USER_PGD_PTRS
19466 + movb $0,i*8(%rbx)
19467 + i = i + 1
19468 + .endr
19469 +
19470 +#ifdef CONFIG_PARAVIRT
19471 +2: popq %rdi
19472 +#endif
19473 + SET_RDI_INTO_CR3
19474 +
19475 +#ifdef CONFIG_PAX_KERNEXEC
19476 + GET_CR0_INTO_RDI
19477 + bts $16,%rdi
19478 + SET_RDI_INTO_CR0
19479 +#endif
19480 +
19481 +#ifdef CONFIG_PARAVIRT
19482 + PV_RESTORE_REGS(CLBR_RDI)
19483 +#endif
19484 +
19485 + popq %rbx
19486 + popq %rdi
19487 + pax_force_retaddr
19488 + retq
19489 +ENDPROC(pax_enter_kernel_user)
19490 +
19491 +ENTRY(pax_exit_kernel_user)
19492 + push %rdi
19493 +
19494 +#ifdef CONFIG_PARAVIRT
19495 + pushq %rbx
19496 + PV_SAVE_REGS(CLBR_RDI)
19497 +#endif
19498 +
19499 +#ifdef CONFIG_PAX_KERNEXEC
19500 + GET_CR0_INTO_RDI
19501 + btr $16,%rdi
19502 + SET_RDI_INTO_CR0
19503 +#endif
19504 +
19505 + GET_CR3_INTO_RDI
19506 + add $__START_KERNEL_map,%rdi
19507 + sub phys_base(%rip),%rdi
19508 +
19509 +#ifdef CONFIG_PARAVIRT
19510 + cmpl $0, pv_info+PARAVIRT_enabled
19511 + jz 1f
19512 + mov %rdi,%rbx
19513 + i = 0
19514 + .rept USER_PGD_PTRS
19515 + mov i*8(%rbx),%rsi
19516 + mov $0x67,%sil
19517 + lea i*8(%rbx),%rdi
19518 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19519 + i = i + 1
19520 + .endr
19521 + jmp 2f
19522 +1:
19523 +#endif
19524 +
19525 + i = 0
19526 + .rept USER_PGD_PTRS
19527 + movb $0x67,i*8(%rdi)
19528 + i = i + 1
19529 + .endr
19530 +
19531 +#ifdef CONFIG_PARAVIRT
19532 +2: PV_RESTORE_REGS(CLBR_RDI)
19533 + popq %rbx
19534 +#endif
19535 +
19536 + popq %rdi
19537 + pax_force_retaddr
19538 + retq
19539 +ENDPROC(pax_exit_kernel_user)
19540 +#endif
19541 +
19542 +.macro pax_erase_kstack
19543 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19544 + call pax_erase_kstack
19545 +#endif
19546 +.endm
19547 +
19548 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19549 +ENTRY(pax_erase_kstack)
19550 + pushq %rdi
19551 + pushq %rcx
19552 + pushq %rax
19553 + pushq %r11
19554 +
19555 + GET_THREAD_INFO(%r11)
19556 + mov TI_lowest_stack(%r11), %rdi
19557 + mov $-0xBEEF, %rax
19558 + std
19559 +
19560 +1: mov %edi, %ecx
19561 + and $THREAD_SIZE_asm - 1, %ecx
19562 + shr $3, %ecx
19563 + repne scasq
19564 + jecxz 2f
19565 +
19566 + cmp $2*8, %ecx
19567 + jc 2f
19568 +
19569 + mov $2*8, %ecx
19570 + repe scasq
19571 + jecxz 2f
19572 + jne 1b
19573 +
19574 +2: cld
19575 + mov %esp, %ecx
19576 + sub %edi, %ecx
19577 +
19578 + cmp $THREAD_SIZE_asm, %rcx
19579 + jb 3f
19580 + ud2
19581 +3:
19582 +
19583 + shr $3, %ecx
19584 + rep stosq
19585 +
19586 + mov TI_task_thread_sp0(%r11), %rdi
19587 + sub $256, %rdi
19588 + mov %rdi, TI_lowest_stack(%r11)
19589 +
19590 + popq %r11
19591 + popq %rax
19592 + popq %rcx
19593 + popq %rdi
19594 + pax_force_retaddr
19595 + ret
19596 +ENDPROC(pax_erase_kstack)
19597 +#endif
19598
19599 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19600 #ifdef CONFIG_TRACE_IRQFLAGS
19601 @@ -375,8 +651,8 @@ ENDPROC(native_usergs_sysret64)
19602 .endm
19603
19604 .macro UNFAKE_STACK_FRAME
19605 - addq $8*6, %rsp
19606 - CFI_ADJUST_CFA_OFFSET -(6*8)
19607 + addq $8*6 + ARG_SKIP, %rsp
19608 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19609 .endm
19610
19611 /*
19612 @@ -463,7 +739,7 @@ ENDPROC(native_usergs_sysret64)
19613 movq %rsp, %rsi
19614
19615 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19616 - testl $3, CS-RBP(%rsi)
19617 + testb $3, CS-RBP(%rsi)
19618 je 1f
19619 SWAPGS
19620 /*
19621 @@ -498,9 +774,10 @@ ENTRY(save_rest)
19622 movq_cfi r15, R15+16
19623 movq %r11, 8(%rsp) /* return address */
19624 FIXUP_TOP_OF_STACK %r11, 16
19625 + pax_force_retaddr
19626 ret
19627 CFI_ENDPROC
19628 -END(save_rest)
19629 +ENDPROC(save_rest)
19630
19631 /* save complete stack frame */
19632 .pushsection .kprobes.text, "ax"
19633 @@ -529,9 +806,10 @@ ENTRY(save_paranoid)
19634 js 1f /* negative -> in kernel */
19635 SWAPGS
19636 xorl %ebx,%ebx
19637 -1: ret
19638 +1: pax_force_retaddr_bts
19639 + ret
19640 CFI_ENDPROC
19641 -END(save_paranoid)
19642 +ENDPROC(save_paranoid)
19643 .popsection
19644
19645 /*
19646 @@ -553,7 +831,7 @@ ENTRY(ret_from_fork)
19647
19648 RESTORE_REST
19649
19650 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19651 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19652 jz 1f
19653
19654 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19655 @@ -571,7 +849,7 @@ ENTRY(ret_from_fork)
19656 RESTORE_REST
19657 jmp int_ret_from_sys_call
19658 CFI_ENDPROC
19659 -END(ret_from_fork)
19660 +ENDPROC(ret_from_fork)
19661
19662 /*
19663 * System call entry. Up to 6 arguments in registers are supported.
19664 @@ -608,7 +886,7 @@ END(ret_from_fork)
19665 ENTRY(system_call)
19666 CFI_STARTPROC simple
19667 CFI_SIGNAL_FRAME
19668 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19669 + CFI_DEF_CFA rsp,0
19670 CFI_REGISTER rip,rcx
19671 /*CFI_REGISTER rflags,r11*/
19672 SWAPGS_UNSAFE_STACK
19673 @@ -621,16 +899,23 @@ GLOBAL(system_call_after_swapgs)
19674
19675 movq %rsp,PER_CPU_VAR(old_rsp)
19676 movq PER_CPU_VAR(kernel_stack),%rsp
19677 + SAVE_ARGS 8*6,0
19678 + pax_enter_kernel_user
19679 +
19680 +#ifdef CONFIG_PAX_RANDKSTACK
19681 + pax_erase_kstack
19682 +#endif
19683 +
19684 /*
19685 * No need to follow this irqs off/on section - it's straight
19686 * and short:
19687 */
19688 ENABLE_INTERRUPTS(CLBR_NONE)
19689 - SAVE_ARGS 8,0
19690 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19691 movq %rcx,RIP-ARGOFFSET(%rsp)
19692 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19693 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19694 + GET_THREAD_INFO(%rcx)
19695 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19696 jnz tracesys
19697 system_call_fastpath:
19698 #if __SYSCALL_MASK == ~0
19699 @@ -640,7 +925,7 @@ system_call_fastpath:
19700 cmpl $__NR_syscall_max,%eax
19701 #endif
19702 ja badsys
19703 - movq %r10,%rcx
19704 + movq R10-ARGOFFSET(%rsp),%rcx
19705 call *sys_call_table(,%rax,8) # XXX: rip relative
19706 movq %rax,RAX-ARGOFFSET(%rsp)
19707 /*
19708 @@ -654,10 +939,13 @@ sysret_check:
19709 LOCKDEP_SYS_EXIT
19710 DISABLE_INTERRUPTS(CLBR_NONE)
19711 TRACE_IRQS_OFF
19712 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19713 + GET_THREAD_INFO(%rcx)
19714 + movl TI_flags(%rcx),%edx
19715 andl %edi,%edx
19716 jnz sysret_careful
19717 CFI_REMEMBER_STATE
19718 + pax_exit_kernel_user
19719 + pax_erase_kstack
19720 /*
19721 * sysretq will re-enable interrupts:
19722 */
19723 @@ -709,14 +997,18 @@ badsys:
19724 * jump back to the normal fast path.
19725 */
19726 auditsys:
19727 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19728 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19729 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19730 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19731 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19732 movq %rax,%rsi /* 2nd arg: syscall number */
19733 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19734 call __audit_syscall_entry
19735 +
19736 + pax_erase_kstack
19737 +
19738 LOAD_ARGS 0 /* reload call-clobbered registers */
19739 + pax_set_fptr_mask
19740 jmp system_call_fastpath
19741
19742 /*
19743 @@ -737,7 +1029,7 @@ sysret_audit:
19744 /* Do syscall tracing */
19745 tracesys:
19746 #ifdef CONFIG_AUDITSYSCALL
19747 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19748 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19749 jz auditsys
19750 #endif
19751 SAVE_REST
19752 @@ -745,12 +1037,16 @@ tracesys:
19753 FIXUP_TOP_OF_STACK %rdi
19754 movq %rsp,%rdi
19755 call syscall_trace_enter
19756 +
19757 + pax_erase_kstack
19758 +
19759 /*
19760 * Reload arg registers from stack in case ptrace changed them.
19761 * We don't reload %rax because syscall_trace_enter() returned
19762 * the value it wants us to use in the table lookup.
19763 */
19764 LOAD_ARGS ARGOFFSET, 1
19765 + pax_set_fptr_mask
19766 RESTORE_REST
19767 #if __SYSCALL_MASK == ~0
19768 cmpq $__NR_syscall_max,%rax
19769 @@ -759,7 +1055,7 @@ tracesys:
19770 cmpl $__NR_syscall_max,%eax
19771 #endif
19772 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19773 - movq %r10,%rcx /* fixup for C */
19774 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19775 call *sys_call_table(,%rax,8)
19776 movq %rax,RAX-ARGOFFSET(%rsp)
19777 /* Use IRET because user could have changed frame */
19778 @@ -780,7 +1076,9 @@ GLOBAL(int_with_check)
19779 andl %edi,%edx
19780 jnz int_careful
19781 andl $~TS_COMPAT,TI_status(%rcx)
19782 - jmp retint_swapgs
19783 + pax_exit_kernel_user
19784 + pax_erase_kstack
19785 + jmp retint_swapgs_pax
19786
19787 /* Either reschedule or signal or syscall exit tracking needed. */
19788 /* First do a reschedule test. */
19789 @@ -826,7 +1124,7 @@ int_restore_rest:
19790 TRACE_IRQS_OFF
19791 jmp int_with_check
19792 CFI_ENDPROC
19793 -END(system_call)
19794 +ENDPROC(system_call)
19795
19796 /*
19797 * Certain special system calls that need to save a complete full stack frame.
19798 @@ -842,7 +1140,7 @@ ENTRY(\label)
19799 call \func
19800 jmp ptregscall_common
19801 CFI_ENDPROC
19802 -END(\label)
19803 +ENDPROC(\label)
19804 .endm
19805
19806 .macro FORK_LIKE func
19807 @@ -856,9 +1154,10 @@ ENTRY(stub_\func)
19808 DEFAULT_FRAME 0 8 /* offset 8: return address */
19809 call sys_\func
19810 RESTORE_TOP_OF_STACK %r11, 8
19811 + pax_force_retaddr
19812 ret $REST_SKIP /* pop extended registers */
19813 CFI_ENDPROC
19814 -END(stub_\func)
19815 +ENDPROC(stub_\func)
19816 .endm
19817
19818 FORK_LIKE clone
19819 @@ -875,9 +1174,10 @@ ENTRY(ptregscall_common)
19820 movq_cfi_restore R12+8, r12
19821 movq_cfi_restore RBP+8, rbp
19822 movq_cfi_restore RBX+8, rbx
19823 + pax_force_retaddr
19824 ret $REST_SKIP /* pop extended registers */
19825 CFI_ENDPROC
19826 -END(ptregscall_common)
19827 +ENDPROC(ptregscall_common)
19828
19829 ENTRY(stub_execve)
19830 CFI_STARTPROC
19831 @@ -891,7 +1191,7 @@ ENTRY(stub_execve)
19832 RESTORE_REST
19833 jmp int_ret_from_sys_call
19834 CFI_ENDPROC
19835 -END(stub_execve)
19836 +ENDPROC(stub_execve)
19837
19838 /*
19839 * sigreturn is special because it needs to restore all registers on return.
19840 @@ -909,7 +1209,7 @@ ENTRY(stub_rt_sigreturn)
19841 RESTORE_REST
19842 jmp int_ret_from_sys_call
19843 CFI_ENDPROC
19844 -END(stub_rt_sigreturn)
19845 +ENDPROC(stub_rt_sigreturn)
19846
19847 #ifdef CONFIG_X86_X32_ABI
19848 ENTRY(stub_x32_rt_sigreturn)
19849 @@ -975,7 +1275,7 @@ vector=vector+1
19850 2: jmp common_interrupt
19851 .endr
19852 CFI_ENDPROC
19853 -END(irq_entries_start)
19854 +ENDPROC(irq_entries_start)
19855
19856 .previous
19857 END(interrupt)
19858 @@ -995,6 +1295,16 @@ END(interrupt)
19859 subq $ORIG_RAX-RBP, %rsp
19860 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19861 SAVE_ARGS_IRQ
19862 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19863 + testb $3, CS(%rdi)
19864 + jnz 1f
19865 + pax_enter_kernel
19866 + jmp 2f
19867 +1: pax_enter_kernel_user
19868 +2:
19869 +#else
19870 + pax_enter_kernel
19871 +#endif
19872 call \func
19873 .endm
19874
19875 @@ -1027,7 +1337,7 @@ ret_from_intr:
19876
19877 exit_intr:
19878 GET_THREAD_INFO(%rcx)
19879 - testl $3,CS-ARGOFFSET(%rsp)
19880 + testb $3,CS-ARGOFFSET(%rsp)
19881 je retint_kernel
19882
19883 /* Interrupt came from user space */
19884 @@ -1049,12 +1359,16 @@ retint_swapgs: /* return to user-space */
19885 * The iretq could re-enable interrupts:
19886 */
19887 DISABLE_INTERRUPTS(CLBR_ANY)
19888 + pax_exit_kernel_user
19889 +retint_swapgs_pax:
19890 TRACE_IRQS_IRETQ
19891 SWAPGS
19892 jmp restore_args
19893
19894 retint_restore_args: /* return to kernel space */
19895 DISABLE_INTERRUPTS(CLBR_ANY)
19896 + pax_exit_kernel
19897 + pax_force_retaddr (RIP-ARGOFFSET)
19898 /*
19899 * The iretq could re-enable interrupts:
19900 */
19901 @@ -1137,7 +1451,7 @@ ENTRY(retint_kernel)
19902 #endif
19903
19904 CFI_ENDPROC
19905 -END(common_interrupt)
19906 +ENDPROC(common_interrupt)
19907 /*
19908 * End of kprobes section
19909 */
19910 @@ -1155,7 +1469,7 @@ ENTRY(\sym)
19911 interrupt \do_sym
19912 jmp ret_from_intr
19913 CFI_ENDPROC
19914 -END(\sym)
19915 +ENDPROC(\sym)
19916 .endm
19917
19918 #ifdef CONFIG_SMP
19919 @@ -1211,12 +1525,22 @@ ENTRY(\sym)
19920 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19921 call error_entry
19922 DEFAULT_FRAME 0
19923 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19924 + testb $3, CS(%rsp)
19925 + jnz 1f
19926 + pax_enter_kernel
19927 + jmp 2f
19928 +1: pax_enter_kernel_user
19929 +2:
19930 +#else
19931 + pax_enter_kernel
19932 +#endif
19933 movq %rsp,%rdi /* pt_regs pointer */
19934 xorl %esi,%esi /* no error code */
19935 call \do_sym
19936 jmp error_exit /* %ebx: no swapgs flag */
19937 CFI_ENDPROC
19938 -END(\sym)
19939 +ENDPROC(\sym)
19940 .endm
19941
19942 .macro paranoidzeroentry sym do_sym
19943 @@ -1229,15 +1553,25 @@ ENTRY(\sym)
19944 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19945 call save_paranoid
19946 TRACE_IRQS_OFF
19947 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19948 + testb $3, CS(%rsp)
19949 + jnz 1f
19950 + pax_enter_kernel
19951 + jmp 2f
19952 +1: pax_enter_kernel_user
19953 +2:
19954 +#else
19955 + pax_enter_kernel
19956 +#endif
19957 movq %rsp,%rdi /* pt_regs pointer */
19958 xorl %esi,%esi /* no error code */
19959 call \do_sym
19960 jmp paranoid_exit /* %ebx: no swapgs flag */
19961 CFI_ENDPROC
19962 -END(\sym)
19963 +ENDPROC(\sym)
19964 .endm
19965
19966 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19967 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19968 .macro paranoidzeroentry_ist sym do_sym ist
19969 ENTRY(\sym)
19970 INTR_FRAME
19971 @@ -1248,14 +1582,30 @@ ENTRY(\sym)
19972 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19973 call save_paranoid
19974 TRACE_IRQS_OFF_DEBUG
19975 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19976 + testb $3, CS(%rsp)
19977 + jnz 1f
19978 + pax_enter_kernel
19979 + jmp 2f
19980 +1: pax_enter_kernel_user
19981 +2:
19982 +#else
19983 + pax_enter_kernel
19984 +#endif
19985 movq %rsp,%rdi /* pt_regs pointer */
19986 xorl %esi,%esi /* no error code */
19987 +#ifdef CONFIG_SMP
19988 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19989 + lea init_tss(%r12), %r12
19990 +#else
19991 + lea init_tss(%rip), %r12
19992 +#endif
19993 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19994 call \do_sym
19995 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19996 jmp paranoid_exit /* %ebx: no swapgs flag */
19997 CFI_ENDPROC
19998 -END(\sym)
19999 +ENDPROC(\sym)
20000 .endm
20001
20002 .macro errorentry sym do_sym
20003 @@ -1267,13 +1617,23 @@ ENTRY(\sym)
20004 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20005 call error_entry
20006 DEFAULT_FRAME 0
20007 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20008 + testb $3, CS(%rsp)
20009 + jnz 1f
20010 + pax_enter_kernel
20011 + jmp 2f
20012 +1: pax_enter_kernel_user
20013 +2:
20014 +#else
20015 + pax_enter_kernel
20016 +#endif
20017 movq %rsp,%rdi /* pt_regs pointer */
20018 movq ORIG_RAX(%rsp),%rsi /* get error code */
20019 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20020 call \do_sym
20021 jmp error_exit /* %ebx: no swapgs flag */
20022 CFI_ENDPROC
20023 -END(\sym)
20024 +ENDPROC(\sym)
20025 .endm
20026
20027 /* error code is on the stack already */
20028 @@ -1287,13 +1647,23 @@ ENTRY(\sym)
20029 call save_paranoid
20030 DEFAULT_FRAME 0
20031 TRACE_IRQS_OFF
20032 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20033 + testb $3, CS(%rsp)
20034 + jnz 1f
20035 + pax_enter_kernel
20036 + jmp 2f
20037 +1: pax_enter_kernel_user
20038 +2:
20039 +#else
20040 + pax_enter_kernel
20041 +#endif
20042 movq %rsp,%rdi /* pt_regs pointer */
20043 movq ORIG_RAX(%rsp),%rsi /* get error code */
20044 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20045 call \do_sym
20046 jmp paranoid_exit /* %ebx: no swapgs flag */
20047 CFI_ENDPROC
20048 -END(\sym)
20049 +ENDPROC(\sym)
20050 .endm
20051
20052 zeroentry divide_error do_divide_error
20053 @@ -1323,9 +1693,10 @@ gs_change:
20054 2: mfence /* workaround */
20055 SWAPGS
20056 popfq_cfi
20057 + pax_force_retaddr
20058 ret
20059 CFI_ENDPROC
20060 -END(native_load_gs_index)
20061 +ENDPROC(native_load_gs_index)
20062
20063 _ASM_EXTABLE(gs_change,bad_gs)
20064 .section .fixup,"ax"
20065 @@ -1353,9 +1724,10 @@ ENTRY(call_softirq)
20066 CFI_DEF_CFA_REGISTER rsp
20067 CFI_ADJUST_CFA_OFFSET -8
20068 decl PER_CPU_VAR(irq_count)
20069 + pax_force_retaddr
20070 ret
20071 CFI_ENDPROC
20072 -END(call_softirq)
20073 +ENDPROC(call_softirq)
20074
20075 #ifdef CONFIG_XEN
20076 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
20077 @@ -1393,7 +1765,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
20078 decl PER_CPU_VAR(irq_count)
20079 jmp error_exit
20080 CFI_ENDPROC
20081 -END(xen_do_hypervisor_callback)
20082 +ENDPROC(xen_do_hypervisor_callback)
20083
20084 /*
20085 * Hypervisor uses this for application faults while it executes.
20086 @@ -1452,7 +1824,7 @@ ENTRY(xen_failsafe_callback)
20087 SAVE_ALL
20088 jmp error_exit
20089 CFI_ENDPROC
20090 -END(xen_failsafe_callback)
20091 +ENDPROC(xen_failsafe_callback)
20092
20093 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
20094 xen_hvm_callback_vector xen_evtchn_do_upcall
20095 @@ -1501,16 +1873,31 @@ ENTRY(paranoid_exit)
20096 TRACE_IRQS_OFF_DEBUG
20097 testl %ebx,%ebx /* swapgs needed? */
20098 jnz paranoid_restore
20099 - testl $3,CS(%rsp)
20100 + testb $3,CS(%rsp)
20101 jnz paranoid_userspace
20102 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20103 + pax_exit_kernel
20104 + TRACE_IRQS_IRETQ 0
20105 + SWAPGS_UNSAFE_STACK
20106 + RESTORE_ALL 8
20107 + pax_force_retaddr_bts
20108 + jmp irq_return
20109 +#endif
20110 paranoid_swapgs:
20111 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20112 + pax_exit_kernel_user
20113 +#else
20114 + pax_exit_kernel
20115 +#endif
20116 TRACE_IRQS_IRETQ 0
20117 SWAPGS_UNSAFE_STACK
20118 RESTORE_ALL 8
20119 jmp irq_return
20120 paranoid_restore:
20121 + pax_exit_kernel
20122 TRACE_IRQS_IRETQ_DEBUG 0
20123 RESTORE_ALL 8
20124 + pax_force_retaddr_bts
20125 jmp irq_return
20126 paranoid_userspace:
20127 GET_THREAD_INFO(%rcx)
20128 @@ -1539,7 +1926,7 @@ paranoid_schedule:
20129 TRACE_IRQS_OFF
20130 jmp paranoid_userspace
20131 CFI_ENDPROC
20132 -END(paranoid_exit)
20133 +ENDPROC(paranoid_exit)
20134
20135 /*
20136 * Exception entry point. This expects an error code/orig_rax on the stack.
20137 @@ -1566,12 +1953,13 @@ ENTRY(error_entry)
20138 movq_cfi r14, R14+8
20139 movq_cfi r15, R15+8
20140 xorl %ebx,%ebx
20141 - testl $3,CS+8(%rsp)
20142 + testb $3,CS+8(%rsp)
20143 je error_kernelspace
20144 error_swapgs:
20145 SWAPGS
20146 error_sti:
20147 TRACE_IRQS_OFF
20148 + pax_force_retaddr_bts
20149 ret
20150
20151 /*
20152 @@ -1598,7 +1986,7 @@ bstep_iret:
20153 movq %rcx,RIP+8(%rsp)
20154 jmp error_swapgs
20155 CFI_ENDPROC
20156 -END(error_entry)
20157 +ENDPROC(error_entry)
20158
20159
20160 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
20161 @@ -1618,7 +2006,7 @@ ENTRY(error_exit)
20162 jnz retint_careful
20163 jmp retint_swapgs
20164 CFI_ENDPROC
20165 -END(error_exit)
20166 +ENDPROC(error_exit)
20167
20168 /*
20169 * Test if a given stack is an NMI stack or not.
20170 @@ -1676,9 +2064,11 @@ ENTRY(nmi)
20171 * If %cs was not the kernel segment, then the NMI triggered in user
20172 * space, which means it is definitely not nested.
20173 */
20174 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
20175 + je 1f
20176 cmpl $__KERNEL_CS, 16(%rsp)
20177 jne first_nmi
20178 -
20179 +1:
20180 /*
20181 * Check the special variable on the stack to see if NMIs are
20182 * executing.
20183 @@ -1847,6 +2237,17 @@ end_repeat_nmi:
20184 */
20185 movq %cr2, %r12
20186
20187 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20188 + testb $3, CS(%rsp)
20189 + jnz 1f
20190 + pax_enter_kernel
20191 + jmp 2f
20192 +1: pax_enter_kernel_user
20193 +2:
20194 +#else
20195 + pax_enter_kernel
20196 +#endif
20197 +
20198 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20199 movq %rsp,%rdi
20200 movq $-1,%rsi
20201 @@ -1862,23 +2263,34 @@ end_repeat_nmi:
20202 testl %ebx,%ebx /* swapgs needed? */
20203 jnz nmi_restore
20204 nmi_swapgs:
20205 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20206 + pax_exit_kernel_user
20207 +#else
20208 + pax_exit_kernel
20209 +#endif
20210 SWAPGS_UNSAFE_STACK
20211 + RESTORE_ALL 6*8
20212 + /* Clear the NMI executing stack variable */
20213 + movq $0, 5*8(%rsp)
20214 + jmp irq_return
20215 nmi_restore:
20216 + pax_exit_kernel
20217 /* Pop the extra iret frame at once */
20218 RESTORE_ALL 6*8
20219 + pax_force_retaddr_bts
20220
20221 /* Clear the NMI executing stack variable */
20222 movq $0, 5*8(%rsp)
20223 jmp irq_return
20224 CFI_ENDPROC
20225 -END(nmi)
20226 +ENDPROC(nmi)
20227
20228 ENTRY(ignore_sysret)
20229 CFI_STARTPROC
20230 mov $-ENOSYS,%eax
20231 sysret
20232 CFI_ENDPROC
20233 -END(ignore_sysret)
20234 +ENDPROC(ignore_sysret)
20235
20236 /*
20237 * End of kprobes section
20238 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20239 index 1d41402..af9a46a 100644
20240 --- a/arch/x86/kernel/ftrace.c
20241 +++ b/arch/x86/kernel/ftrace.c
20242 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20243 {
20244 unsigned char replaced[MCOUNT_INSN_SIZE];
20245
20246 + ip = ktla_ktva(ip);
20247 +
20248 /*
20249 * Note: Due to modules and __init, code can
20250 * disappear and change, we need to protect against faulting
20251 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20252 unsigned char old[MCOUNT_INSN_SIZE], *new;
20253 int ret;
20254
20255 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20256 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20257 new = ftrace_call_replace(ip, (unsigned long)func);
20258
20259 /* See comment above by declaration of modifying_ftrace_code */
20260 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20261 /* Also update the regs callback function */
20262 if (!ret) {
20263 ip = (unsigned long)(&ftrace_regs_call);
20264 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20265 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20266 new = ftrace_call_replace(ip, (unsigned long)func);
20267 ret = ftrace_modify_code(ip, old, new);
20268 }
20269 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20270 * kernel identity mapping to modify code.
20271 */
20272 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20273 - ip = (unsigned long)__va(__pa(ip));
20274 + ip = (unsigned long)__va(__pa(ktla_ktva(ip)));
20275
20276 return probe_kernel_write((void *)ip, val, size);
20277 }
20278 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20279 unsigned char replaced[MCOUNT_INSN_SIZE];
20280 unsigned char brk = BREAKPOINT_INSTRUCTION;
20281
20282 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20283 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20284 return -EFAULT;
20285
20286 /* Make sure it is what we expect it to be */
20287 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20288 return ret;
20289
20290 fail_update:
20291 - probe_kernel_write((void *)ip, &old_code[0], 1);
20292 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20293 goto out;
20294 }
20295
20296 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20297 {
20298 unsigned char code[MCOUNT_INSN_SIZE];
20299
20300 + ip = ktla_ktva(ip);
20301 +
20302 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20303 return -EFAULT;
20304
20305 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
20306 index c18f59d..9c0c9f6 100644
20307 --- a/arch/x86/kernel/head32.c
20308 +++ b/arch/x86/kernel/head32.c
20309 @@ -18,6 +18,7 @@
20310 #include <asm/io_apic.h>
20311 #include <asm/bios_ebda.h>
20312 #include <asm/tlbflush.h>
20313 +#include <asm/boot.h>
20314
20315 static void __init i386_default_early_setup(void)
20316 {
20317 @@ -30,8 +31,7 @@ static void __init i386_default_early_setup(void)
20318
20319 void __init i386_start_kernel(void)
20320 {
20321 - memblock_reserve(__pa_symbol(&_text),
20322 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
20323 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
20324
20325 #ifdef CONFIG_BLK_DEV_INITRD
20326 /* Reserve INITRD */
20327 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20328 index c8932c7..d56b622 100644
20329 --- a/arch/x86/kernel/head_32.S
20330 +++ b/arch/x86/kernel/head_32.S
20331 @@ -26,6 +26,12 @@
20332 /* Physical address */
20333 #define pa(X) ((X) - __PAGE_OFFSET)
20334
20335 +#ifdef CONFIG_PAX_KERNEXEC
20336 +#define ta(X) (X)
20337 +#else
20338 +#define ta(X) ((X) - __PAGE_OFFSET)
20339 +#endif
20340 +
20341 /*
20342 * References to members of the new_cpu_data structure.
20343 */
20344 @@ -55,11 +61,7 @@
20345 * and small than max_low_pfn, otherwise will waste some page table entries
20346 */
20347
20348 -#if PTRS_PER_PMD > 1
20349 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20350 -#else
20351 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20352 -#endif
20353 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20354
20355 /* Number of possible pages in the lowmem region */
20356 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20357 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20358 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20359
20360 /*
20361 + * Real beginning of normal "text" segment
20362 + */
20363 +ENTRY(stext)
20364 +ENTRY(_stext)
20365 +
20366 +/*
20367 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20368 * %esi points to the real-mode code as a 32-bit pointer.
20369 * CS and DS must be 4 GB flat segments, but we don't depend on
20370 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20371 * can.
20372 */
20373 __HEAD
20374 +
20375 +#ifdef CONFIG_PAX_KERNEXEC
20376 + jmp startup_32
20377 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20378 +.fill PAGE_SIZE-5,1,0xcc
20379 +#endif
20380 +
20381 ENTRY(startup_32)
20382 movl pa(stack_start),%ecx
20383
20384 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20385 2:
20386 leal -__PAGE_OFFSET(%ecx),%esp
20387
20388 +#ifdef CONFIG_SMP
20389 + movl $pa(cpu_gdt_table),%edi
20390 + movl $__per_cpu_load,%eax
20391 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20392 + rorl $16,%eax
20393 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20394 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20395 + movl $__per_cpu_end - 1,%eax
20396 + subl $__per_cpu_start,%eax
20397 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20398 +#endif
20399 +
20400 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20401 + movl $NR_CPUS,%ecx
20402 + movl $pa(cpu_gdt_table),%edi
20403 +1:
20404 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20405 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20406 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20407 + addl $PAGE_SIZE_asm,%edi
20408 + loop 1b
20409 +#endif
20410 +
20411 +#ifdef CONFIG_PAX_KERNEXEC
20412 + movl $pa(boot_gdt),%edi
20413 + movl $__LOAD_PHYSICAL_ADDR,%eax
20414 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20415 + rorl $16,%eax
20416 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20417 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20418 + rorl $16,%eax
20419 +
20420 + ljmp $(__BOOT_CS),$1f
20421 +1:
20422 +
20423 + movl $NR_CPUS,%ecx
20424 + movl $pa(cpu_gdt_table),%edi
20425 + addl $__PAGE_OFFSET,%eax
20426 +1:
20427 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20428 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20429 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20430 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20431 + rorl $16,%eax
20432 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20433 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20434 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20435 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20436 + rorl $16,%eax
20437 + addl $PAGE_SIZE_asm,%edi
20438 + loop 1b
20439 +#endif
20440 +
20441 /*
20442 * Clear BSS first so that there are no surprises...
20443 */
20444 @@ -196,8 +264,11 @@ ENTRY(startup_32)
20445 movl %eax, pa(max_pfn_mapped)
20446
20447 /* Do early initialization of the fixmap area */
20448 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20449 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20450 +#ifdef CONFIG_COMPAT_VDSO
20451 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20452 +#else
20453 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20454 +#endif
20455 #else /* Not PAE */
20456
20457 page_pde_offset = (__PAGE_OFFSET >> 20);
20458 @@ -227,8 +298,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20459 movl %eax, pa(max_pfn_mapped)
20460
20461 /* Do early initialization of the fixmap area */
20462 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20463 - movl %eax,pa(initial_page_table+0xffc)
20464 +#ifdef CONFIG_COMPAT_VDSO
20465 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20466 +#else
20467 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20468 +#endif
20469 #endif
20470
20471 #ifdef CONFIG_PARAVIRT
20472 @@ -242,9 +316,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20473 cmpl $num_subarch_entries, %eax
20474 jae bad_subarch
20475
20476 - movl pa(subarch_entries)(,%eax,4), %eax
20477 - subl $__PAGE_OFFSET, %eax
20478 - jmp *%eax
20479 + jmp *pa(subarch_entries)(,%eax,4)
20480
20481 bad_subarch:
20482 WEAK(lguest_entry)
20483 @@ -256,10 +328,10 @@ WEAK(xen_entry)
20484 __INITDATA
20485
20486 subarch_entries:
20487 - .long default_entry /* normal x86/PC */
20488 - .long lguest_entry /* lguest hypervisor */
20489 - .long xen_entry /* Xen hypervisor */
20490 - .long default_entry /* Moorestown MID */
20491 + .long ta(default_entry) /* normal x86/PC */
20492 + .long ta(lguest_entry) /* lguest hypervisor */
20493 + .long ta(xen_entry) /* Xen hypervisor */
20494 + .long ta(default_entry) /* Moorestown MID */
20495 num_subarch_entries = (. - subarch_entries) / 4
20496 .previous
20497 #else
20498 @@ -335,6 +407,7 @@ default_entry:
20499 movl pa(mmu_cr4_features),%eax
20500 movl %eax,%cr4
20501
20502 +#ifdef CONFIG_X86_PAE
20503 testb $X86_CR4_PAE, %al # check if PAE is enabled
20504 jz 6f
20505
20506 @@ -363,6 +436,9 @@ default_entry:
20507 /* Make changes effective */
20508 wrmsr
20509
20510 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20511 +#endif
20512 +
20513 6:
20514
20515 /*
20516 @@ -460,14 +536,20 @@ is386: movl $2,%ecx # set MP
20517 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20518 movl %eax,%ss # after changing gdt.
20519
20520 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20521 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20522 movl %eax,%ds
20523 movl %eax,%es
20524
20525 movl $(__KERNEL_PERCPU), %eax
20526 movl %eax,%fs # set this cpu's percpu
20527
20528 +#ifdef CONFIG_CC_STACKPROTECTOR
20529 movl $(__KERNEL_STACK_CANARY),%eax
20530 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20531 + movl $(__USER_DS),%eax
20532 +#else
20533 + xorl %eax,%eax
20534 +#endif
20535 movl %eax,%gs
20536
20537 xorl %eax,%eax # Clear LDT
20538 @@ -544,8 +626,11 @@ setup_once:
20539 * relocation. Manually set base address in stack canary
20540 * segment descriptor.
20541 */
20542 - movl $gdt_page,%eax
20543 + movl $cpu_gdt_table,%eax
20544 movl $stack_canary,%ecx
20545 +#ifdef CONFIG_SMP
20546 + addl $__per_cpu_load,%ecx
20547 +#endif
20548 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20549 shrl $16, %ecx
20550 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20551 @@ -576,7 +661,7 @@ ENDPROC(early_idt_handlers)
20552 /* This is global to keep gas from relaxing the jumps */
20553 ENTRY(early_idt_handler)
20554 cld
20555 - cmpl $2,%ss:early_recursion_flag
20556 + cmpl $1,%ss:early_recursion_flag
20557 je hlt_loop
20558 incl %ss:early_recursion_flag
20559
20560 @@ -614,8 +699,8 @@ ENTRY(early_idt_handler)
20561 pushl (20+6*4)(%esp) /* trapno */
20562 pushl $fault_msg
20563 call printk
20564 -#endif
20565 call dump_stack
20566 +#endif
20567 hlt_loop:
20568 hlt
20569 jmp hlt_loop
20570 @@ -634,8 +719,11 @@ ENDPROC(early_idt_handler)
20571 /* This is the default interrupt "handler" :-) */
20572 ALIGN
20573 ignore_int:
20574 - cld
20575 #ifdef CONFIG_PRINTK
20576 + cmpl $2,%ss:early_recursion_flag
20577 + je hlt_loop
20578 + incl %ss:early_recursion_flag
20579 + cld
20580 pushl %eax
20581 pushl %ecx
20582 pushl %edx
20583 @@ -644,9 +732,6 @@ ignore_int:
20584 movl $(__KERNEL_DS),%eax
20585 movl %eax,%ds
20586 movl %eax,%es
20587 - cmpl $2,early_recursion_flag
20588 - je hlt_loop
20589 - incl early_recursion_flag
20590 pushl 16(%esp)
20591 pushl 24(%esp)
20592 pushl 32(%esp)
20593 @@ -680,29 +765,43 @@ ENTRY(setup_once_ref)
20594 /*
20595 * BSS section
20596 */
20597 -__PAGE_ALIGNED_BSS
20598 - .align PAGE_SIZE
20599 #ifdef CONFIG_X86_PAE
20600 +.section .initial_pg_pmd,"a",@progbits
20601 initial_pg_pmd:
20602 .fill 1024*KPMDS,4,0
20603 #else
20604 +.section .initial_page_table,"a",@progbits
20605 ENTRY(initial_page_table)
20606 .fill 1024,4,0
20607 #endif
20608 +.section .initial_pg_fixmap,"a",@progbits
20609 initial_pg_fixmap:
20610 .fill 1024,4,0
20611 +.section .empty_zero_page,"a",@progbits
20612 ENTRY(empty_zero_page)
20613 .fill 4096,1,0
20614 +.section .swapper_pg_dir,"a",@progbits
20615 ENTRY(swapper_pg_dir)
20616 +#ifdef CONFIG_X86_PAE
20617 + .fill 4,8,0
20618 +#else
20619 .fill 1024,4,0
20620 +#endif
20621 +
20622 +/*
20623 + * The IDT has to be page-aligned to simplify the Pentium
20624 + * F0 0F bug workaround.. We have a special link segment
20625 + * for this.
20626 + */
20627 +.section .idt,"a",@progbits
20628 +ENTRY(idt_table)
20629 + .fill 256,8,0
20630
20631 /*
20632 * This starts the data section.
20633 */
20634 #ifdef CONFIG_X86_PAE
20635 -__PAGE_ALIGNED_DATA
20636 - /* Page-aligned for the benefit of paravirt? */
20637 - .align PAGE_SIZE
20638 +.section .initial_page_table,"a",@progbits
20639 ENTRY(initial_page_table)
20640 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20641 # if KPMDS == 3
20642 @@ -721,12 +820,20 @@ ENTRY(initial_page_table)
20643 # error "Kernel PMDs should be 1, 2 or 3"
20644 # endif
20645 .align PAGE_SIZE /* needs to be page-sized too */
20646 +
20647 +#ifdef CONFIG_PAX_PER_CPU_PGD
20648 +ENTRY(cpu_pgd)
20649 + .rept NR_CPUS
20650 + .fill 4,8,0
20651 + .endr
20652 +#endif
20653 +
20654 #endif
20655
20656 .data
20657 .balign 4
20658 ENTRY(stack_start)
20659 - .long init_thread_union+THREAD_SIZE
20660 + .long init_thread_union+THREAD_SIZE-8
20661
20662 __INITRODATA
20663 int_msg:
20664 @@ -754,7 +861,7 @@ fault_msg:
20665 * segment size, and 32-bit linear address value:
20666 */
20667
20668 - .data
20669 +.section .rodata,"a",@progbits
20670 .globl boot_gdt_descr
20671 .globl idt_descr
20672
20673 @@ -763,7 +870,7 @@ fault_msg:
20674 .word 0 # 32 bit align gdt_desc.address
20675 boot_gdt_descr:
20676 .word __BOOT_DS+7
20677 - .long boot_gdt - __PAGE_OFFSET
20678 + .long pa(boot_gdt)
20679
20680 .word 0 # 32-bit align idt_desc.address
20681 idt_descr:
20682 @@ -774,7 +881,7 @@ idt_descr:
20683 .word 0 # 32 bit align gdt_desc.address
20684 ENTRY(early_gdt_descr)
20685 .word GDT_ENTRIES*8-1
20686 - .long gdt_page /* Overwritten for secondary CPUs */
20687 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20688
20689 /*
20690 * The boot_gdt must mirror the equivalent in setup.S and is
20691 @@ -783,5 +890,65 @@ ENTRY(early_gdt_descr)
20692 .align L1_CACHE_BYTES
20693 ENTRY(boot_gdt)
20694 .fill GDT_ENTRY_BOOT_CS,8,0
20695 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20696 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20697 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20698 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20699 +
20700 + .align PAGE_SIZE_asm
20701 +ENTRY(cpu_gdt_table)
20702 + .rept NR_CPUS
20703 + .quad 0x0000000000000000 /* NULL descriptor */
20704 + .quad 0x0000000000000000 /* 0x0b reserved */
20705 + .quad 0x0000000000000000 /* 0x13 reserved */
20706 + .quad 0x0000000000000000 /* 0x1b reserved */
20707 +
20708 +#ifdef CONFIG_PAX_KERNEXEC
20709 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20710 +#else
20711 + .quad 0x0000000000000000 /* 0x20 unused */
20712 +#endif
20713 +
20714 + .quad 0x0000000000000000 /* 0x28 unused */
20715 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20716 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20717 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20718 + .quad 0x0000000000000000 /* 0x4b reserved */
20719 + .quad 0x0000000000000000 /* 0x53 reserved */
20720 + .quad 0x0000000000000000 /* 0x5b reserved */
20721 +
20722 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20723 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20724 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20725 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20726 +
20727 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20728 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20729 +
20730 + /*
20731 + * Segments used for calling PnP BIOS have byte granularity.
20732 + * The code segments and data segments have fixed 64k limits,
20733 + * the transfer segment sizes are set at run time.
20734 + */
20735 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20736 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20737 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20738 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20739 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20740 +
20741 + /*
20742 + * The APM segments have byte granularity and their bases
20743 + * are set at run time. All have 64k limits.
20744 + */
20745 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20746 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20747 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20748 +
20749 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20750 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20751 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20752 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20753 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20754 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20755 +
20756 + /* Be sure this is zeroed to avoid false validations in Xen */
20757 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20758 + .endr
20759 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20760 index 980053c..74d3b44 100644
20761 --- a/arch/x86/kernel/head_64.S
20762 +++ b/arch/x86/kernel/head_64.S
20763 @@ -20,6 +20,8 @@
20764 #include <asm/processor-flags.h>
20765 #include <asm/percpu.h>
20766 #include <asm/nops.h>
20767 +#include <asm/cpufeature.h>
20768 +#include <asm/alternative-asm.h>
20769
20770 #ifdef CONFIG_PARAVIRT
20771 #include <asm/asm-offsets.h>
20772 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20773 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20774 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20775 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20776 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20777 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20778 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20779 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20780 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20781 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20782
20783 .text
20784 __HEAD
20785 @@ -88,35 +96,23 @@ startup_64:
20786 */
20787 addq %rbp, init_level4_pgt + 0(%rip)
20788 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20789 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20790 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20791 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20792 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20793
20794 addq %rbp, level3_ident_pgt + 0(%rip)
20795 +#ifndef CONFIG_XEN
20796 + addq %rbp, level3_ident_pgt + 8(%rip)
20797 +#endif
20798
20799 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20800 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20801 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20802 +
20803 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20804 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
20805
20806 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20807 -
20808 - /* Add an Identity mapping if I am above 1G */
20809 - leaq _text(%rip), %rdi
20810 - andq $PMD_PAGE_MASK, %rdi
20811 -
20812 - movq %rdi, %rax
20813 - shrq $PUD_SHIFT, %rax
20814 - andq $(PTRS_PER_PUD - 1), %rax
20815 - jz ident_complete
20816 -
20817 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
20818 - leaq level3_ident_pgt(%rip), %rbx
20819 - movq %rdx, 0(%rbx, %rax, 8)
20820 -
20821 - movq %rdi, %rax
20822 - shrq $PMD_SHIFT, %rax
20823 - andq $(PTRS_PER_PMD - 1), %rax
20824 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
20825 - leaq level2_spare_pgt(%rip), %rbx
20826 - movq %rdx, 0(%rbx, %rax, 8)
20827 -ident_complete:
20828 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20829
20830 /*
20831 * Fixup the kernel text+data virtual addresses. Note that
20832 @@ -159,8 +155,8 @@ ENTRY(secondary_startup_64)
20833 * after the boot processor executes this code.
20834 */
20835
20836 - /* Enable PAE mode and PGE */
20837 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
20838 + /* Enable PAE mode and PSE/PGE */
20839 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
20840 movq %rax, %cr4
20841
20842 /* Setup early boot stage 4 level pagetables. */
20843 @@ -182,9 +178,17 @@ ENTRY(secondary_startup_64)
20844 movl $MSR_EFER, %ecx
20845 rdmsr
20846 btsl $_EFER_SCE, %eax /* Enable System Call */
20847 - btl $20,%edi /* No Execute supported? */
20848 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20849 jnc 1f
20850 btsl $_EFER_NX, %eax
20851 + leaq init_level4_pgt(%rip), %rdi
20852 +#ifndef CONFIG_EFI
20853 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20854 +#endif
20855 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20856 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20857 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20858 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20859 1: wrmsr /* Make changes effective */
20860
20861 /* Setup cr0 */
20862 @@ -246,6 +250,7 @@ ENTRY(secondary_startup_64)
20863 * jump. In addition we need to ensure %cs is set so we make this
20864 * a far return.
20865 */
20866 + pax_set_fptr_mask
20867 movq initial_code(%rip),%rax
20868 pushq $0 # fake return address to stop unwinder
20869 pushq $__KERNEL_CS # set correct cs
20870 @@ -284,7 +289,7 @@ ENDPROC(start_cpu0)
20871 bad_address:
20872 jmp bad_address
20873
20874 - .section ".init.text","ax"
20875 + __INIT
20876 .globl early_idt_handlers
20877 early_idt_handlers:
20878 # 104(%rsp) %rflags
20879 @@ -343,7 +348,7 @@ ENTRY(early_idt_handler)
20880 call dump_stack
20881 #ifdef CONFIG_KALLSYMS
20882 leaq early_idt_ripmsg(%rip),%rdi
20883 - movq 40(%rsp),%rsi # %rip again
20884 + movq 88(%rsp),%rsi # %rip again
20885 call __print_symbol
20886 #endif
20887 #endif /* EARLY_PRINTK */
20888 @@ -363,11 +368,15 @@ ENTRY(early_idt_handler)
20889 addq $16,%rsp # drop vector number and error code
20890 decl early_recursion_flag(%rip)
20891 INTERRUPT_RETURN
20892 + .previous
20893
20894 + __INITDATA
20895 .balign 4
20896 early_recursion_flag:
20897 .long 0
20898 + .previous
20899
20900 + .section .rodata,"a",@progbits
20901 #ifdef CONFIG_EARLY_PRINTK
20902 early_idt_msg:
20903 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20904 @@ -376,6 +385,7 @@ early_idt_ripmsg:
20905 #endif /* CONFIG_EARLY_PRINTK */
20906 .previous
20907
20908 + .section .rodata,"a",@progbits
20909 #define NEXT_PAGE(name) \
20910 .balign PAGE_SIZE; \
20911 ENTRY(name)
20912 @@ -388,7 +398,6 @@ ENTRY(name)
20913 i = i + 1 ; \
20914 .endr
20915
20916 - .data
20917 /*
20918 * This default setting generates an ident mapping at address 0x100000
20919 * and a mapping for the kernel that precisely maps virtual address
20920 @@ -399,13 +408,41 @@ NEXT_PAGE(init_level4_pgt)
20921 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20922 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20923 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20924 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20925 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20926 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20927 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20928 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20929 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20930 .org init_level4_pgt + L4_START_KERNEL*8, 0
20931 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20932 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20933
20934 +#ifdef CONFIG_PAX_PER_CPU_PGD
20935 +NEXT_PAGE(cpu_pgd)
20936 + .rept NR_CPUS
20937 + .fill 512,8,0
20938 + .endr
20939 +#endif
20940 +
20941 NEXT_PAGE(level3_ident_pgt)
20942 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20943 +#ifdef CONFIG_XEN
20944 .fill 511,8,0
20945 +#else
20946 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20947 + .fill 510,8,0
20948 +#endif
20949 +
20950 +NEXT_PAGE(level3_vmalloc_start_pgt)
20951 + .fill 512,8,0
20952 +
20953 +NEXT_PAGE(level3_vmalloc_end_pgt)
20954 + .fill 512,8,0
20955 +
20956 +NEXT_PAGE(level3_vmemmap_pgt)
20957 + .fill L3_VMEMMAP_START,8,0
20958 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20959
20960 NEXT_PAGE(level3_kernel_pgt)
20961 .fill L3_START_KERNEL,8,0
20962 @@ -413,20 +450,23 @@ NEXT_PAGE(level3_kernel_pgt)
20963 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20964 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20965
20966 +NEXT_PAGE(level2_vmemmap_pgt)
20967 + .fill 512,8,0
20968 +
20969 NEXT_PAGE(level2_fixmap_pgt)
20970 - .fill 506,8,0
20971 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20972 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20973 - .fill 5,8,0
20974 + .fill 507,8,0
20975 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20976 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20977 + .fill 4,8,0
20978
20979 -NEXT_PAGE(level1_fixmap_pgt)
20980 +NEXT_PAGE(level1_vsyscall_pgt)
20981 .fill 512,8,0
20982
20983 -NEXT_PAGE(level2_ident_pgt)
20984 - /* Since I easily can, map the first 1G.
20985 + /* Since I easily can, map the first 2G.
20986 * Don't set NX because code runs from these pages.
20987 */
20988 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20989 +NEXT_PAGE(level2_ident_pgt)
20990 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20991
20992 NEXT_PAGE(level2_kernel_pgt)
20993 /*
20994 @@ -439,37 +479,59 @@ NEXT_PAGE(level2_kernel_pgt)
20995 * If you want to increase this then increase MODULES_VADDR
20996 * too.)
20997 */
20998 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
20999 - KERNEL_IMAGE_SIZE/PMD_SIZE)
21000 -
21001 -NEXT_PAGE(level2_spare_pgt)
21002 - .fill 512, 8, 0
21003 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
21004
21005 #undef PMDS
21006 #undef NEXT_PAGE
21007
21008 - .data
21009 + .align PAGE_SIZE
21010 +ENTRY(cpu_gdt_table)
21011 + .rept NR_CPUS
21012 + .quad 0x0000000000000000 /* NULL descriptor */
21013 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
21014 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
21015 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
21016 + .quad 0x00cffb000000ffff /* __USER32_CS */
21017 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
21018 + .quad 0x00affb000000ffff /* __USER_CS */
21019 +
21020 +#ifdef CONFIG_PAX_KERNEXEC
21021 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
21022 +#else
21023 + .quad 0x0 /* unused */
21024 +#endif
21025 +
21026 + .quad 0,0 /* TSS */
21027 + .quad 0,0 /* LDT */
21028 + .quad 0,0,0 /* three TLS descriptors */
21029 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
21030 + /* asm/segment.h:GDT_ENTRIES must match this */
21031 +
21032 + /* zero the remaining page */
21033 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
21034 + .endr
21035 +
21036 .align 16
21037 .globl early_gdt_descr
21038 early_gdt_descr:
21039 .word GDT_ENTRIES*8-1
21040 early_gdt_descr_base:
21041 - .quad INIT_PER_CPU_VAR(gdt_page)
21042 + .quad cpu_gdt_table
21043
21044 ENTRY(phys_base)
21045 /* This must match the first entry in level2_kernel_pgt */
21046 .quad 0x0000000000000000
21047
21048 #include "../../x86/xen/xen-head.S"
21049 -
21050 - .section .bss, "aw", @nobits
21051 +
21052 + .section .rodata,"a",@progbits
21053 .align L1_CACHE_BYTES
21054 ENTRY(idt_table)
21055 - .skip IDT_ENTRIES * 16
21056 + .fill 512,8,0
21057
21058 .align L1_CACHE_BYTES
21059 ENTRY(nmi_idt_table)
21060 - .skip IDT_ENTRIES * 16
21061 + .fill 512,8,0
21062
21063 __PAGE_ALIGNED_BSS
21064 .align PAGE_SIZE
21065 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
21066 index 9c3bd4a..e1d9b35 100644
21067 --- a/arch/x86/kernel/i386_ksyms_32.c
21068 +++ b/arch/x86/kernel/i386_ksyms_32.c
21069 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
21070 EXPORT_SYMBOL(cmpxchg8b_emu);
21071 #endif
21072
21073 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
21074 +
21075 /* Networking helper routines. */
21076 EXPORT_SYMBOL(csum_partial_copy_generic);
21077 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
21078 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
21079
21080 EXPORT_SYMBOL(__get_user_1);
21081 EXPORT_SYMBOL(__get_user_2);
21082 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
21083
21084 EXPORT_SYMBOL(csum_partial);
21085 EXPORT_SYMBOL(empty_zero_page);
21086 +
21087 +#ifdef CONFIG_PAX_KERNEXEC
21088 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
21089 +#endif
21090 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
21091 index 245a71d..89d9ce4 100644
21092 --- a/arch/x86/kernel/i387.c
21093 +++ b/arch/x86/kernel/i387.c
21094 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
21095 static inline bool interrupted_user_mode(void)
21096 {
21097 struct pt_regs *regs = get_irq_regs();
21098 - return regs && user_mode_vm(regs);
21099 + return regs && user_mode(regs);
21100 }
21101
21102 /*
21103 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
21104 index 9a5c460..b332a4b 100644
21105 --- a/arch/x86/kernel/i8259.c
21106 +++ b/arch/x86/kernel/i8259.c
21107 @@ -209,7 +209,7 @@ spurious_8259A_irq:
21108 "spurious 8259A interrupt: IRQ%d.\n", irq);
21109 spurious_irq_mask |= irqmask;
21110 }
21111 - atomic_inc(&irq_err_count);
21112 + atomic_inc_unchecked(&irq_err_count);
21113 /*
21114 * Theoretically we do not have to handle this IRQ,
21115 * but in Linux this does not cause problems and is
21116 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
21117 /* (slave's support for AEOI in flat mode is to be investigated) */
21118 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
21119
21120 + pax_open_kernel();
21121 if (auto_eoi)
21122 /*
21123 * In AEOI mode we just have to mask the interrupt
21124 * when acking.
21125 */
21126 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
21127 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
21128 else
21129 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21130 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21131 + pax_close_kernel();
21132
21133 udelay(100); /* wait for 8259A to initialize */
21134
21135 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
21136 index a979b5b..1d6db75 100644
21137 --- a/arch/x86/kernel/io_delay.c
21138 +++ b/arch/x86/kernel/io_delay.c
21139 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
21140 * Quirk table for systems that misbehave (lock up, etc.) if port
21141 * 0x80 is used:
21142 */
21143 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
21144 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
21145 {
21146 .callback = dmi_io_delay_0xed_port,
21147 .ident = "Compaq Presario V6000",
21148 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
21149 index 8c96897..be66bfa 100644
21150 --- a/arch/x86/kernel/ioport.c
21151 +++ b/arch/x86/kernel/ioport.c
21152 @@ -6,6 +6,7 @@
21153 #include <linux/sched.h>
21154 #include <linux/kernel.h>
21155 #include <linux/capability.h>
21156 +#include <linux/security.h>
21157 #include <linux/errno.h>
21158 #include <linux/types.h>
21159 #include <linux/ioport.h>
21160 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21161
21162 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
21163 return -EINVAL;
21164 +#ifdef CONFIG_GRKERNSEC_IO
21165 + if (turn_on && grsec_disable_privio) {
21166 + gr_handle_ioperm();
21167 + return -EPERM;
21168 + }
21169 +#endif
21170 if (turn_on && !capable(CAP_SYS_RAWIO))
21171 return -EPERM;
21172
21173 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21174 * because the ->io_bitmap_max value must match the bitmap
21175 * contents:
21176 */
21177 - tss = &per_cpu(init_tss, get_cpu());
21178 + tss = init_tss + get_cpu();
21179
21180 if (turn_on)
21181 bitmap_clear(t->io_bitmap_ptr, from, num);
21182 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
21183 return -EINVAL;
21184 /* Trying to gain more privileges? */
21185 if (level > old) {
21186 +#ifdef CONFIG_GRKERNSEC_IO
21187 + if (grsec_disable_privio) {
21188 + gr_handle_iopl();
21189 + return -EPERM;
21190 + }
21191 +#endif
21192 if (!capable(CAP_SYS_RAWIO))
21193 return -EPERM;
21194 }
21195 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
21196 index e4595f1..ee3bfb8 100644
21197 --- a/arch/x86/kernel/irq.c
21198 +++ b/arch/x86/kernel/irq.c
21199 @@ -18,7 +18,7 @@
21200 #include <asm/mce.h>
21201 #include <asm/hw_irq.h>
21202
21203 -atomic_t irq_err_count;
21204 +atomic_unchecked_t irq_err_count;
21205
21206 /* Function pointer for generic interrupt vector handling */
21207 void (*x86_platform_ipi_callback)(void) = NULL;
21208 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
21209 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
21210 seq_printf(p, " Machine check polls\n");
21211 #endif
21212 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
21213 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
21214 #if defined(CONFIG_X86_IO_APIC)
21215 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
21216 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
21217 #endif
21218 return 0;
21219 }
21220 @@ -164,10 +164,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21221
21222 u64 arch_irq_stat(void)
21223 {
21224 - u64 sum = atomic_read(&irq_err_count);
21225 + u64 sum = atomic_read_unchecked(&irq_err_count);
21226
21227 #ifdef CONFIG_X86_IO_APIC
21228 - sum += atomic_read(&irq_mis_count);
21229 + sum += atomic_read_unchecked(&irq_mis_count);
21230 #endif
21231 return sum;
21232 }
21233 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21234 index 344faf8..355f60d 100644
21235 --- a/arch/x86/kernel/irq_32.c
21236 +++ b/arch/x86/kernel/irq_32.c
21237 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21238 __asm__ __volatile__("andl %%esp,%0" :
21239 "=r" (sp) : "0" (THREAD_SIZE - 1));
21240
21241 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21242 + return sp < STACK_WARN;
21243 }
21244
21245 static void print_stack_overflow(void)
21246 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21247 * per-CPU IRQ handling contexts (thread information and stack)
21248 */
21249 union irq_ctx {
21250 - struct thread_info tinfo;
21251 - u32 stack[THREAD_SIZE/sizeof(u32)];
21252 + unsigned long previous_esp;
21253 + u32 stack[THREAD_SIZE/sizeof(u32)];
21254 } __attribute__((aligned(THREAD_SIZE)));
21255
21256 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21257 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21258 static inline int
21259 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21260 {
21261 - union irq_ctx *curctx, *irqctx;
21262 + union irq_ctx *irqctx;
21263 u32 *isp, arg1, arg2;
21264
21265 - curctx = (union irq_ctx *) current_thread_info();
21266 irqctx = __this_cpu_read(hardirq_ctx);
21267
21268 /*
21269 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21270 * handler) we can't do that and just have to keep using the
21271 * current stack (which is the irq stack already after all)
21272 */
21273 - if (unlikely(curctx == irqctx))
21274 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21275 return 0;
21276
21277 /* build the stack frame on the IRQ stack */
21278 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21279 - irqctx->tinfo.task = curctx->tinfo.task;
21280 - irqctx->tinfo.previous_esp = current_stack_pointer;
21281 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21282 + irqctx->previous_esp = current_stack_pointer;
21283
21284 - /* Copy the preempt_count so that the [soft]irq checks work. */
21285 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21286 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21287 + __set_fs(MAKE_MM_SEG(0));
21288 +#endif
21289
21290 if (unlikely(overflow))
21291 call_on_stack(print_stack_overflow, isp);
21292 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21293 : "0" (irq), "1" (desc), "2" (isp),
21294 "D" (desc->handle_irq)
21295 : "memory", "cc", "ecx");
21296 +
21297 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21298 + __set_fs(current_thread_info()->addr_limit);
21299 +#endif
21300 +
21301 return 1;
21302 }
21303
21304 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21305 */
21306 void __cpuinit irq_ctx_init(int cpu)
21307 {
21308 - union irq_ctx *irqctx;
21309 -
21310 if (per_cpu(hardirq_ctx, cpu))
21311 return;
21312
21313 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21314 - THREADINFO_GFP,
21315 - THREAD_SIZE_ORDER));
21316 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21317 - irqctx->tinfo.cpu = cpu;
21318 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21319 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21320 -
21321 - per_cpu(hardirq_ctx, cpu) = irqctx;
21322 -
21323 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21324 - THREADINFO_GFP,
21325 - THREAD_SIZE_ORDER));
21326 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21327 - irqctx->tinfo.cpu = cpu;
21328 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21329 -
21330 - per_cpu(softirq_ctx, cpu) = irqctx;
21331 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21332 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21333 +
21334 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21335 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21336
21337 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21338 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21339 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21340 asmlinkage void do_softirq(void)
21341 {
21342 unsigned long flags;
21343 - struct thread_info *curctx;
21344 union irq_ctx *irqctx;
21345 u32 *isp;
21346
21347 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21348 local_irq_save(flags);
21349
21350 if (local_softirq_pending()) {
21351 - curctx = current_thread_info();
21352 irqctx = __this_cpu_read(softirq_ctx);
21353 - irqctx->tinfo.task = curctx->task;
21354 - irqctx->tinfo.previous_esp = current_stack_pointer;
21355 + irqctx->previous_esp = current_stack_pointer;
21356
21357 /* build the stack frame on the softirq stack */
21358 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21359 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21360 +
21361 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21362 + __set_fs(MAKE_MM_SEG(0));
21363 +#endif
21364
21365 call_on_stack(__do_softirq, isp);
21366 +
21367 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21368 + __set_fs(current_thread_info()->addr_limit);
21369 +#endif
21370 +
21371 /*
21372 * Shouldn't happen, we returned above if in_interrupt():
21373 */
21374 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21375 if (unlikely(!desc))
21376 return false;
21377
21378 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21379 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21380 if (unlikely(overflow))
21381 print_stack_overflow();
21382 desc->handle_irq(irq, desc);
21383 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21384 index d04d3ec..ea4b374 100644
21385 --- a/arch/x86/kernel/irq_64.c
21386 +++ b/arch/x86/kernel/irq_64.c
21387 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21388 u64 estack_top, estack_bottom;
21389 u64 curbase = (u64)task_stack_page(current);
21390
21391 - if (user_mode_vm(regs))
21392 + if (user_mode(regs))
21393 return;
21394
21395 if (regs->sp >= curbase + sizeof(struct thread_info) +
21396 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21397 index dc1404b..bbc43e7 100644
21398 --- a/arch/x86/kernel/kdebugfs.c
21399 +++ b/arch/x86/kernel/kdebugfs.c
21400 @@ -27,7 +27,7 @@ struct setup_data_node {
21401 u32 len;
21402 };
21403
21404 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21405 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21406 size_t count, loff_t *ppos)
21407 {
21408 struct setup_data_node *node = file->private_data;
21409 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21410 index 836f832..a8bda67 100644
21411 --- a/arch/x86/kernel/kgdb.c
21412 +++ b/arch/x86/kernel/kgdb.c
21413 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21414 #ifdef CONFIG_X86_32
21415 switch (regno) {
21416 case GDB_SS:
21417 - if (!user_mode_vm(regs))
21418 + if (!user_mode(regs))
21419 *(unsigned long *)mem = __KERNEL_DS;
21420 break;
21421 case GDB_SP:
21422 - if (!user_mode_vm(regs))
21423 + if (!user_mode(regs))
21424 *(unsigned long *)mem = kernel_stack_pointer(regs);
21425 break;
21426 case GDB_GS:
21427 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21428 bp->attr.bp_addr = breakinfo[breakno].addr;
21429 bp->attr.bp_len = breakinfo[breakno].len;
21430 bp->attr.bp_type = breakinfo[breakno].type;
21431 - info->address = breakinfo[breakno].addr;
21432 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21433 + info->address = ktla_ktva(breakinfo[breakno].addr);
21434 + else
21435 + info->address = breakinfo[breakno].addr;
21436 info->len = breakinfo[breakno].len;
21437 info->type = breakinfo[breakno].type;
21438 val = arch_install_hw_breakpoint(bp);
21439 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21440 case 'k':
21441 /* clear the trace bit */
21442 linux_regs->flags &= ~X86_EFLAGS_TF;
21443 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21444 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21445
21446 /* set the trace bit if we're stepping */
21447 if (remcomInBuffer[0] == 's') {
21448 linux_regs->flags |= X86_EFLAGS_TF;
21449 - atomic_set(&kgdb_cpu_doing_single_step,
21450 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21451 raw_smp_processor_id());
21452 }
21453
21454 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21455
21456 switch (cmd) {
21457 case DIE_DEBUG:
21458 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21459 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21460 if (user_mode(regs))
21461 return single_step_cont(regs, args);
21462 break;
21463 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21464 #endif /* CONFIG_DEBUG_RODATA */
21465
21466 bpt->type = BP_BREAKPOINT;
21467 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21468 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21469 BREAK_INSTR_SIZE);
21470 if (err)
21471 return err;
21472 - err = probe_kernel_write((char *)bpt->bpt_addr,
21473 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21474 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21475 #ifdef CONFIG_DEBUG_RODATA
21476 if (!err)
21477 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21478 return -EBUSY;
21479 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21480 BREAK_INSTR_SIZE);
21481 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21482 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21483 if (err)
21484 return err;
21485 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21486 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21487 if (mutex_is_locked(&text_mutex))
21488 goto knl_write;
21489 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21490 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21491 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21492 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21493 goto knl_write;
21494 return err;
21495 knl_write:
21496 #endif /* CONFIG_DEBUG_RODATA */
21497 - return probe_kernel_write((char *)bpt->bpt_addr,
21498 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21499 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21500 }
21501
21502 diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
21503 index c5e410e..ed5a7f0 100644
21504 --- a/arch/x86/kernel/kprobes-opt.c
21505 +++ b/arch/x86/kernel/kprobes-opt.c
21506 @@ -338,7 +338,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21507 * Verify if the address gap is in 2GB range, because this uses
21508 * a relative jump.
21509 */
21510 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21511 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21512 if (abs(rel) > 0x7fffffff)
21513 return -ERANGE;
21514
21515 @@ -353,16 +353,16 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21516 op->optinsn.size = ret;
21517
21518 /* Copy arch-dep-instance from template */
21519 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21520 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21521
21522 /* Set probe information */
21523 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21524
21525 /* Set probe function call */
21526 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21527 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21528
21529 /* Set returning jmp instruction at the tail of out-of-line buffer */
21530 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21531 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21532 (u8 *)op->kp.addr + op->optinsn.size);
21533
21534 flush_icache_range((unsigned long) buf,
21535 @@ -385,7 +385,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21536 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21537
21538 /* Backup instructions which will be replaced by jump address */
21539 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21540 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21541 RELATIVE_ADDR_SIZE);
21542
21543 insn_buf[0] = RELATIVEJUMP_OPCODE;
21544 @@ -483,7 +483,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21545 /* This kprobe is really able to run optimized path. */
21546 op = container_of(p, struct optimized_kprobe, kp);
21547 /* Detour through copied instructions */
21548 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21549 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21550 if (!reenter)
21551 reset_current_kprobe();
21552 preempt_enable_no_resched();
21553 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
21554 index 57916c0..9e0b9d0 100644
21555 --- a/arch/x86/kernel/kprobes.c
21556 +++ b/arch/x86/kernel/kprobes.c
21557 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21558 s32 raddr;
21559 } __attribute__((packed)) *insn;
21560
21561 - insn = (struct __arch_relative_insn *)from;
21562 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21563 +
21564 + pax_open_kernel();
21565 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21566 insn->op = op;
21567 + pax_close_kernel();
21568 }
21569
21570 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21571 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21572 kprobe_opcode_t opcode;
21573 kprobe_opcode_t *orig_opcodes = opcodes;
21574
21575 - if (search_exception_tables((unsigned long)opcodes))
21576 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21577 return 0; /* Page fault may occur on this address. */
21578
21579 retry:
21580 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21581 * for the first byte, we can recover the original instruction
21582 * from it and kp->opcode.
21583 */
21584 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21585 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21586 buf[0] = kp->opcode;
21587 - return (unsigned long)buf;
21588 + return ktva_ktla((unsigned long)buf);
21589 }
21590
21591 /*
21592 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21593 /* Another subsystem puts a breakpoint, failed to recover */
21594 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21595 return 0;
21596 + pax_open_kernel();
21597 memcpy(dest, insn.kaddr, insn.length);
21598 + pax_close_kernel();
21599
21600 #ifdef CONFIG_X86_64
21601 if (insn_rip_relative(&insn)) {
21602 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21603 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21604 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21605 disp = (u8 *) dest + insn_offset_displacement(&insn);
21606 + pax_open_kernel();
21607 *(s32 *) disp = (s32) newdisp;
21608 + pax_close_kernel();
21609 }
21610 #endif
21611 return insn.length;
21612 @@ -485,7 +492,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21613 * nor set current_kprobe, because it doesn't use single
21614 * stepping.
21615 */
21616 - regs->ip = (unsigned long)p->ainsn.insn;
21617 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21618 preempt_enable_no_resched();
21619 return;
21620 }
21621 @@ -502,9 +509,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21622 regs->flags &= ~X86_EFLAGS_IF;
21623 /* single step inline if the instruction is an int3 */
21624 if (p->opcode == BREAKPOINT_INSTRUCTION)
21625 - regs->ip = (unsigned long)p->addr;
21626 + regs->ip = ktla_ktva((unsigned long)p->addr);
21627 else
21628 - regs->ip = (unsigned long)p->ainsn.insn;
21629 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21630 }
21631
21632 /*
21633 @@ -600,7 +607,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21634 setup_singlestep(p, regs, kcb, 0);
21635 return 1;
21636 }
21637 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21638 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21639 /*
21640 * The breakpoint instruction was removed right
21641 * after we hit it. Another cpu has removed
21642 @@ -651,6 +658,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21643 " movq %rax, 152(%rsp)\n"
21644 RESTORE_REGS_STRING
21645 " popfq\n"
21646 +#ifdef KERNEXEC_PLUGIN
21647 + " btsq $63,(%rsp)\n"
21648 +#endif
21649 #else
21650 " pushf\n"
21651 SAVE_REGS_STRING
21652 @@ -788,7 +798,7 @@ static void __kprobes
21653 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21654 {
21655 unsigned long *tos = stack_addr(regs);
21656 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21657 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21658 unsigned long orig_ip = (unsigned long)p->addr;
21659 kprobe_opcode_t *insn = p->ainsn.insn;
21660
21661 @@ -970,7 +980,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21662 struct die_args *args = data;
21663 int ret = NOTIFY_DONE;
21664
21665 - if (args->regs && user_mode_vm(args->regs))
21666 + if (args->regs && user_mode(args->regs))
21667 return ret;
21668
21669 switch (val) {
21670 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21671 index 9c2bd8b..bb1131c 100644
21672 --- a/arch/x86/kernel/kvm.c
21673 +++ b/arch/x86/kernel/kvm.c
21674 @@ -452,7 +452,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21675 return NOTIFY_OK;
21676 }
21677
21678 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21679 +static struct notifier_block kvm_cpu_notifier = {
21680 .notifier_call = kvm_cpu_notify,
21681 };
21682 #endif
21683 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21684 index ebc9873..1b9724b 100644
21685 --- a/arch/x86/kernel/ldt.c
21686 +++ b/arch/x86/kernel/ldt.c
21687 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21688 if (reload) {
21689 #ifdef CONFIG_SMP
21690 preempt_disable();
21691 - load_LDT(pc);
21692 + load_LDT_nolock(pc);
21693 if (!cpumask_equal(mm_cpumask(current->mm),
21694 cpumask_of(smp_processor_id())))
21695 smp_call_function(flush_ldt, current->mm, 1);
21696 preempt_enable();
21697 #else
21698 - load_LDT(pc);
21699 + load_LDT_nolock(pc);
21700 #endif
21701 }
21702 if (oldsize) {
21703 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21704 return err;
21705
21706 for (i = 0; i < old->size; i++)
21707 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21708 + write_ldt_entry(new->ldt, i, old->ldt + i);
21709 return 0;
21710 }
21711
21712 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21713 retval = copy_ldt(&mm->context, &old_mm->context);
21714 mutex_unlock(&old_mm->context.lock);
21715 }
21716 +
21717 + if (tsk == current) {
21718 + mm->context.vdso = 0;
21719 +
21720 +#ifdef CONFIG_X86_32
21721 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21722 + mm->context.user_cs_base = 0UL;
21723 + mm->context.user_cs_limit = ~0UL;
21724 +
21725 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21726 + cpus_clear(mm->context.cpu_user_cs_mask);
21727 +#endif
21728 +
21729 +#endif
21730 +#endif
21731 +
21732 + }
21733 +
21734 return retval;
21735 }
21736
21737 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21738 }
21739 }
21740
21741 +#ifdef CONFIG_PAX_SEGMEXEC
21742 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21743 + error = -EINVAL;
21744 + goto out_unlock;
21745 + }
21746 +#endif
21747 +
21748 fill_ldt(&ldt, &ldt_info);
21749 if (oldmode)
21750 ldt.avl = 0;
21751 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21752 index 5b19e4d..6476a76 100644
21753 --- a/arch/x86/kernel/machine_kexec_32.c
21754 +++ b/arch/x86/kernel/machine_kexec_32.c
21755 @@ -26,7 +26,7 @@
21756 #include <asm/cacheflush.h>
21757 #include <asm/debugreg.h>
21758
21759 -static void set_idt(void *newidt, __u16 limit)
21760 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21761 {
21762 struct desc_ptr curidt;
21763
21764 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21765 }
21766
21767
21768 -static void set_gdt(void *newgdt, __u16 limit)
21769 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21770 {
21771 struct desc_ptr curgdt;
21772
21773 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21774 }
21775
21776 control_page = page_address(image->control_code_page);
21777 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21778 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21779
21780 relocate_kernel_ptr = control_page;
21781 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21782 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21783 index 3a04b22..1d2eb09 100644
21784 --- a/arch/x86/kernel/microcode_core.c
21785 +++ b/arch/x86/kernel/microcode_core.c
21786 @@ -512,7 +512,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21787 return NOTIFY_OK;
21788 }
21789
21790 -static struct notifier_block __refdata mc_cpu_notifier = {
21791 +static struct notifier_block mc_cpu_notifier = {
21792 .notifier_call = mc_cpu_callback,
21793 };
21794
21795 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21796 index 3544aed..01ddc1c 100644
21797 --- a/arch/x86/kernel/microcode_intel.c
21798 +++ b/arch/x86/kernel/microcode_intel.c
21799 @@ -431,13 +431,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21800
21801 static int get_ucode_user(void *to, const void *from, size_t n)
21802 {
21803 - return copy_from_user(to, from, n);
21804 + return copy_from_user(to, (const void __force_user *)from, n);
21805 }
21806
21807 static enum ucode_state
21808 request_microcode_user(int cpu, const void __user *buf, size_t size)
21809 {
21810 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21811 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21812 }
21813
21814 static void microcode_fini_cpu(int cpu)
21815 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21816 index 216a4d7..228255a 100644
21817 --- a/arch/x86/kernel/module.c
21818 +++ b/arch/x86/kernel/module.c
21819 @@ -43,15 +43,60 @@ do { \
21820 } while (0)
21821 #endif
21822
21823 -void *module_alloc(unsigned long size)
21824 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21825 {
21826 - if (PAGE_ALIGN(size) > MODULES_LEN)
21827 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21828 return NULL;
21829 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21830 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21831 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21832 -1, __builtin_return_address(0));
21833 }
21834
21835 +void *module_alloc(unsigned long size)
21836 +{
21837 +
21838 +#ifdef CONFIG_PAX_KERNEXEC
21839 + return __module_alloc(size, PAGE_KERNEL);
21840 +#else
21841 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21842 +#endif
21843 +
21844 +}
21845 +
21846 +#ifdef CONFIG_PAX_KERNEXEC
21847 +#ifdef CONFIG_X86_32
21848 +void *module_alloc_exec(unsigned long size)
21849 +{
21850 + struct vm_struct *area;
21851 +
21852 + if (size == 0)
21853 + return NULL;
21854 +
21855 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21856 + return area ? area->addr : NULL;
21857 +}
21858 +EXPORT_SYMBOL(module_alloc_exec);
21859 +
21860 +void module_free_exec(struct module *mod, void *module_region)
21861 +{
21862 + vunmap(module_region);
21863 +}
21864 +EXPORT_SYMBOL(module_free_exec);
21865 +#else
21866 +void module_free_exec(struct module *mod, void *module_region)
21867 +{
21868 + module_free(mod, module_region);
21869 +}
21870 +EXPORT_SYMBOL(module_free_exec);
21871 +
21872 +void *module_alloc_exec(unsigned long size)
21873 +{
21874 + return __module_alloc(size, PAGE_KERNEL_RX);
21875 +}
21876 +EXPORT_SYMBOL(module_alloc_exec);
21877 +#endif
21878 +#endif
21879 +
21880 #ifdef CONFIG_X86_32
21881 int apply_relocate(Elf32_Shdr *sechdrs,
21882 const char *strtab,
21883 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21884 unsigned int i;
21885 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21886 Elf32_Sym *sym;
21887 - uint32_t *location;
21888 + uint32_t *plocation, location;
21889
21890 DEBUGP("Applying relocate section %u to %u\n",
21891 relsec, sechdrs[relsec].sh_info);
21892 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21893 /* This is where to make the change */
21894 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21895 - + rel[i].r_offset;
21896 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21897 + location = (uint32_t)plocation;
21898 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21899 + plocation = ktla_ktva((void *)plocation);
21900 /* This is the symbol it is referring to. Note that all
21901 undefined symbols have been resolved. */
21902 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21903 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21904 switch (ELF32_R_TYPE(rel[i].r_info)) {
21905 case R_386_32:
21906 /* We add the value into the location given */
21907 - *location += sym->st_value;
21908 + pax_open_kernel();
21909 + *plocation += sym->st_value;
21910 + pax_close_kernel();
21911 break;
21912 case R_386_PC32:
21913 /* Add the value, subtract its position */
21914 - *location += sym->st_value - (uint32_t)location;
21915 + pax_open_kernel();
21916 + *plocation += sym->st_value - location;
21917 + pax_close_kernel();
21918 break;
21919 default:
21920 pr_err("%s: Unknown relocation: %u\n",
21921 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21922 case R_X86_64_NONE:
21923 break;
21924 case R_X86_64_64:
21925 + pax_open_kernel();
21926 *(u64 *)loc = val;
21927 + pax_close_kernel();
21928 break;
21929 case R_X86_64_32:
21930 + pax_open_kernel();
21931 *(u32 *)loc = val;
21932 + pax_close_kernel();
21933 if (val != *(u32 *)loc)
21934 goto overflow;
21935 break;
21936 case R_X86_64_32S:
21937 + pax_open_kernel();
21938 *(s32 *)loc = val;
21939 + pax_close_kernel();
21940 if ((s64)val != *(s32 *)loc)
21941 goto overflow;
21942 break;
21943 case R_X86_64_PC32:
21944 val -= (u64)loc;
21945 + pax_open_kernel();
21946 *(u32 *)loc = val;
21947 + pax_close_kernel();
21948 +
21949 #if 0
21950 if ((s64)val != *(s32 *)loc)
21951 goto overflow;
21952 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21953 index 4929502..686c291 100644
21954 --- a/arch/x86/kernel/msr.c
21955 +++ b/arch/x86/kernel/msr.c
21956 @@ -234,7 +234,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21957 return notifier_from_errno(err);
21958 }
21959
21960 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21961 +static struct notifier_block msr_class_cpu_notifier = {
21962 .notifier_call = msr_class_cpu_callback,
21963 };
21964
21965 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21966 index f84f5c5..f404e81 100644
21967 --- a/arch/x86/kernel/nmi.c
21968 +++ b/arch/x86/kernel/nmi.c
21969 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21970 return handled;
21971 }
21972
21973 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21974 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21975 {
21976 struct nmi_desc *desc = nmi_to_desc(type);
21977 unsigned long flags;
21978 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21979 * event confuses some handlers (kdump uses this flag)
21980 */
21981 if (action->flags & NMI_FLAG_FIRST)
21982 - list_add_rcu(&action->list, &desc->head);
21983 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21984 else
21985 - list_add_tail_rcu(&action->list, &desc->head);
21986 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21987
21988 spin_unlock_irqrestore(&desc->lock, flags);
21989 return 0;
21990 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21991 if (!strcmp(n->name, name)) {
21992 WARN(in_nmi(),
21993 "Trying to free NMI (%s) from NMI context!\n", n->name);
21994 - list_del_rcu(&n->list);
21995 + pax_list_del_rcu((struct list_head *)&n->list);
21996 break;
21997 }
21998 }
21999 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
22000 dotraplinkage notrace __kprobes void
22001 do_nmi(struct pt_regs *regs, long error_code)
22002 {
22003 +
22004 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
22005 + if (!user_mode(regs)) {
22006 + unsigned long cs = regs->cs & 0xFFFF;
22007 + unsigned long ip = ktva_ktla(regs->ip);
22008 +
22009 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
22010 + regs->ip = ip;
22011 + }
22012 +#endif
22013 +
22014 nmi_nesting_preprocess(regs);
22015
22016 nmi_enter();
22017 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
22018 index 6d9582e..f746287 100644
22019 --- a/arch/x86/kernel/nmi_selftest.c
22020 +++ b/arch/x86/kernel/nmi_selftest.c
22021 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
22022 {
22023 /* trap all the unknown NMIs we may generate */
22024 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
22025 - __initdata);
22026 + __initconst);
22027 }
22028
22029 static void __init cleanup_nmi_testsuite(void)
22030 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
22031 unsigned long timeout;
22032
22033 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
22034 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
22035 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
22036 nmi_fail = FAILURE;
22037 return;
22038 }
22039 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
22040 index 676b8c7..870ba04 100644
22041 --- a/arch/x86/kernel/paravirt-spinlocks.c
22042 +++ b/arch/x86/kernel/paravirt-spinlocks.c
22043 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
22044 arch_spin_lock(lock);
22045 }
22046
22047 -struct pv_lock_ops pv_lock_ops = {
22048 +struct pv_lock_ops pv_lock_ops __read_only = {
22049 #ifdef CONFIG_SMP
22050 .spin_is_locked = __ticket_spin_is_locked,
22051 .spin_is_contended = __ticket_spin_is_contended,
22052 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
22053 index 17fff18..5cfa0f4 100644
22054 --- a/arch/x86/kernel/paravirt.c
22055 +++ b/arch/x86/kernel/paravirt.c
22056 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
22057 {
22058 return x;
22059 }
22060 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22061 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
22062 +#endif
22063
22064 void __init default_banner(void)
22065 {
22066 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
22067 if (opfunc == NULL)
22068 /* If there's no function, patch it with a ud2a (BUG) */
22069 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
22070 - else if (opfunc == _paravirt_nop)
22071 + else if (opfunc == (void *)_paravirt_nop)
22072 /* If the operation is a nop, then nop the callsite */
22073 ret = paravirt_patch_nop();
22074
22075 /* identity functions just return their single argument */
22076 - else if (opfunc == _paravirt_ident_32)
22077 + else if (opfunc == (void *)_paravirt_ident_32)
22078 ret = paravirt_patch_ident_32(insnbuf, len);
22079 - else if (opfunc == _paravirt_ident_64)
22080 + else if (opfunc == (void *)_paravirt_ident_64)
22081 ret = paravirt_patch_ident_64(insnbuf, len);
22082 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22083 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
22084 + ret = paravirt_patch_ident_64(insnbuf, len);
22085 +#endif
22086
22087 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
22088 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
22089 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
22090 if (insn_len > len || start == NULL)
22091 insn_len = len;
22092 else
22093 - memcpy(insnbuf, start, insn_len);
22094 + memcpy(insnbuf, ktla_ktva(start), insn_len);
22095
22096 return insn_len;
22097 }
22098 @@ -304,7 +311,7 @@ void arch_flush_lazy_mmu_mode(void)
22099 preempt_enable();
22100 }
22101
22102 -struct pv_info pv_info = {
22103 +struct pv_info pv_info __read_only = {
22104 .name = "bare hardware",
22105 .paravirt_enabled = 0,
22106 .kernel_rpl = 0,
22107 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
22108 #endif
22109 };
22110
22111 -struct pv_init_ops pv_init_ops = {
22112 +struct pv_init_ops pv_init_ops __read_only = {
22113 .patch = native_patch,
22114 };
22115
22116 -struct pv_time_ops pv_time_ops = {
22117 +struct pv_time_ops pv_time_ops __read_only = {
22118 .sched_clock = native_sched_clock,
22119 .steal_clock = native_steal_clock,
22120 };
22121
22122 -struct pv_irq_ops pv_irq_ops = {
22123 +struct pv_irq_ops pv_irq_ops __read_only = {
22124 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
22125 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
22126 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
22127 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
22128 #endif
22129 };
22130
22131 -struct pv_cpu_ops pv_cpu_ops = {
22132 +struct pv_cpu_ops pv_cpu_ops __read_only = {
22133 .cpuid = native_cpuid,
22134 .get_debugreg = native_get_debugreg,
22135 .set_debugreg = native_set_debugreg,
22136 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
22137 .end_context_switch = paravirt_nop,
22138 };
22139
22140 -struct pv_apic_ops pv_apic_ops = {
22141 +struct pv_apic_ops pv_apic_ops __read_only= {
22142 #ifdef CONFIG_X86_LOCAL_APIC
22143 .startup_ipi_hook = paravirt_nop,
22144 #endif
22145 };
22146
22147 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
22148 +#ifdef CONFIG_X86_32
22149 +#ifdef CONFIG_X86_PAE
22150 +/* 64-bit pagetable entries */
22151 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
22152 +#else
22153 /* 32-bit pagetable entries */
22154 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
22155 +#endif
22156 #else
22157 /* 64-bit pagetable entries */
22158 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
22159 #endif
22160
22161 -struct pv_mmu_ops pv_mmu_ops = {
22162 +struct pv_mmu_ops pv_mmu_ops __read_only = {
22163
22164 .read_cr2 = native_read_cr2,
22165 .write_cr2 = native_write_cr2,
22166 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
22167 .make_pud = PTE_IDENT,
22168
22169 .set_pgd = native_set_pgd,
22170 + .set_pgd_batched = native_set_pgd_batched,
22171 #endif
22172 #endif /* PAGETABLE_LEVELS >= 3 */
22173
22174 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
22175 },
22176
22177 .set_fixmap = native_set_fixmap,
22178 +
22179 +#ifdef CONFIG_PAX_KERNEXEC
22180 + .pax_open_kernel = native_pax_open_kernel,
22181 + .pax_close_kernel = native_pax_close_kernel,
22182 +#endif
22183 +
22184 };
22185
22186 EXPORT_SYMBOL_GPL(pv_time_ops);
22187 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
22188 index 35ccf75..7a15747 100644
22189 --- a/arch/x86/kernel/pci-iommu_table.c
22190 +++ b/arch/x86/kernel/pci-iommu_table.c
22191 @@ -2,7 +2,7 @@
22192 #include <asm/iommu_table.h>
22193 #include <linux/string.h>
22194 #include <linux/kallsyms.h>
22195 -
22196 +#include <linux/sched.h>
22197
22198 #define DEBUG 1
22199
22200 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22201 index 6c483ba..d10ce2f 100644
22202 --- a/arch/x86/kernel/pci-swiotlb.c
22203 +++ b/arch/x86/kernel/pci-swiotlb.c
22204 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22205 void *vaddr, dma_addr_t dma_addr,
22206 struct dma_attrs *attrs)
22207 {
22208 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22209 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22210 }
22211
22212 static struct dma_map_ops swiotlb_dma_ops = {
22213 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22214 index 2ed787f..f70c9f6 100644
22215 --- a/arch/x86/kernel/process.c
22216 +++ b/arch/x86/kernel/process.c
22217 @@ -36,7 +36,8 @@
22218 * section. Since TSS's are completely CPU-local, we want them
22219 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22220 */
22221 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22222 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22223 +EXPORT_SYMBOL(init_tss);
22224
22225 #ifdef CONFIG_X86_64
22226 static DEFINE_PER_CPU(unsigned char, is_idle);
22227 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22228 task_xstate_cachep =
22229 kmem_cache_create("task_xstate", xstate_size,
22230 __alignof__(union thread_xstate),
22231 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22232 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22233 }
22234
22235 /*
22236 @@ -105,7 +106,7 @@ void exit_thread(void)
22237 unsigned long *bp = t->io_bitmap_ptr;
22238
22239 if (bp) {
22240 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22241 + struct tss_struct *tss = init_tss + get_cpu();
22242
22243 t->io_bitmap_ptr = NULL;
22244 clear_thread_flag(TIF_IO_BITMAP);
22245 @@ -136,7 +137,7 @@ void show_regs_common(void)
22246 board = dmi_get_system_info(DMI_BOARD_NAME);
22247
22248 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
22249 - current->pid, current->comm, print_tainted(),
22250 + task_pid_nr(current), current->comm, print_tainted(),
22251 init_utsname()->release,
22252 (int)strcspn(init_utsname()->version, " "),
22253 init_utsname()->version,
22254 @@ -149,6 +150,9 @@ void flush_thread(void)
22255 {
22256 struct task_struct *tsk = current;
22257
22258 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22259 + loadsegment(gs, 0);
22260 +#endif
22261 flush_ptrace_hw_breakpoint(tsk);
22262 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22263 drop_init_fpu(tsk);
22264 @@ -301,7 +305,7 @@ static void __exit_idle(void)
22265 void exit_idle(void)
22266 {
22267 /* idle loop has pid 0 */
22268 - if (current->pid)
22269 + if (task_pid_nr(current))
22270 return;
22271 __exit_idle();
22272 }
22273 @@ -404,7 +408,7 @@ bool set_pm_idle_to_default(void)
22274
22275 return ret;
22276 }
22277 -void stop_this_cpu(void *dummy)
22278 +__noreturn void stop_this_cpu(void *dummy)
22279 {
22280 local_irq_disable();
22281 /*
22282 @@ -632,16 +636,37 @@ static int __init idle_setup(char *str)
22283 }
22284 early_param("idle", idle_setup);
22285
22286 -unsigned long arch_align_stack(unsigned long sp)
22287 +#ifdef CONFIG_PAX_RANDKSTACK
22288 +void pax_randomize_kstack(struct pt_regs *regs)
22289 {
22290 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22291 - sp -= get_random_int() % 8192;
22292 - return sp & ~0xf;
22293 -}
22294 + struct thread_struct *thread = &current->thread;
22295 + unsigned long time;
22296
22297 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22298 -{
22299 - unsigned long range_end = mm->brk + 0x02000000;
22300 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22301 -}
22302 + if (!randomize_va_space)
22303 + return;
22304 +
22305 + if (v8086_mode(regs))
22306 + return;
22307
22308 + rdtscl(time);
22309 +
22310 + /* P4 seems to return a 0 LSB, ignore it */
22311 +#ifdef CONFIG_MPENTIUM4
22312 + time &= 0x3EUL;
22313 + time <<= 2;
22314 +#elif defined(CONFIG_X86_64)
22315 + time &= 0xFUL;
22316 + time <<= 4;
22317 +#else
22318 + time &= 0x1FUL;
22319 + time <<= 3;
22320 +#endif
22321 +
22322 + thread->sp0 ^= time;
22323 + load_sp0(init_tss + smp_processor_id(), thread);
22324 +
22325 +#ifdef CONFIG_X86_64
22326 + this_cpu_write(kernel_stack, thread->sp0);
22327 +#endif
22328 +}
22329 +#endif
22330 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22331 index b5a8905..d9cacac 100644
22332 --- a/arch/x86/kernel/process_32.c
22333 +++ b/arch/x86/kernel/process_32.c
22334 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22335 unsigned long thread_saved_pc(struct task_struct *tsk)
22336 {
22337 return ((unsigned long *)tsk->thread.sp)[3];
22338 +//XXX return tsk->thread.eip;
22339 }
22340
22341 void __show_regs(struct pt_regs *regs, int all)
22342 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22343 unsigned long sp;
22344 unsigned short ss, gs;
22345
22346 - if (user_mode_vm(regs)) {
22347 + if (user_mode(regs)) {
22348 sp = regs->sp;
22349 ss = regs->ss & 0xffff;
22350 - gs = get_user_gs(regs);
22351 } else {
22352 sp = kernel_stack_pointer(regs);
22353 savesegment(ss, ss);
22354 - savesegment(gs, gs);
22355 }
22356 + gs = get_user_gs(regs);
22357
22358 show_regs_common();
22359
22360 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22361 (u16)regs->cs, regs->ip, regs->flags,
22362 - smp_processor_id());
22363 + raw_smp_processor_id());
22364 print_symbol("EIP is at %s\n", regs->ip);
22365
22366 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22367 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22368 int copy_thread(unsigned long clone_flags, unsigned long sp,
22369 unsigned long arg, struct task_struct *p)
22370 {
22371 - struct pt_regs *childregs = task_pt_regs(p);
22372 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22373 struct task_struct *tsk;
22374 int err;
22375
22376 p->thread.sp = (unsigned long) childregs;
22377 p->thread.sp0 = (unsigned long) (childregs+1);
22378 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22379
22380 if (unlikely(p->flags & PF_KTHREAD)) {
22381 /* kernel thread */
22382 memset(childregs, 0, sizeof(struct pt_regs));
22383 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22384 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22385 - childregs->ds = __USER_DS;
22386 - childregs->es = __USER_DS;
22387 + savesegment(gs, childregs->gs);
22388 + childregs->ds = __KERNEL_DS;
22389 + childregs->es = __KERNEL_DS;
22390 childregs->fs = __KERNEL_PERCPU;
22391 childregs->bx = sp; /* function */
22392 childregs->bp = arg;
22393 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22394 struct thread_struct *prev = &prev_p->thread,
22395 *next = &next_p->thread;
22396 int cpu = smp_processor_id();
22397 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22398 + struct tss_struct *tss = init_tss + cpu;
22399 fpu_switch_t fpu;
22400
22401 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22402 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22403 */
22404 lazy_save_gs(prev->gs);
22405
22406 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22407 + __set_fs(task_thread_info(next_p)->addr_limit);
22408 +#endif
22409 +
22410 /*
22411 * Load the per-thread Thread-Local Storage descriptor.
22412 */
22413 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22414 */
22415 arch_end_context_switch(next_p);
22416
22417 + this_cpu_write(current_task, next_p);
22418 + this_cpu_write(current_tinfo, &next_p->tinfo);
22419 +
22420 /*
22421 * Restore %gs if needed (which is common)
22422 */
22423 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22424
22425 switch_fpu_finish(next_p, fpu);
22426
22427 - this_cpu_write(current_task, next_p);
22428 -
22429 return prev_p;
22430 }
22431
22432 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22433 } while (count++ < 16);
22434 return 0;
22435 }
22436 -
22437 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22438 index 6e68a61..955a9a5 100644
22439 --- a/arch/x86/kernel/process_64.c
22440 +++ b/arch/x86/kernel/process_64.c
22441 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22442 struct pt_regs *childregs;
22443 struct task_struct *me = current;
22444
22445 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22446 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22447 childregs = task_pt_regs(p);
22448 p->thread.sp = (unsigned long) childregs;
22449 p->thread.usersp = me->thread.usersp;
22450 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22451 set_tsk_thread_flag(p, TIF_FORK);
22452 p->fpu_counter = 0;
22453 p->thread.io_bitmap_ptr = NULL;
22454 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22455 struct thread_struct *prev = &prev_p->thread;
22456 struct thread_struct *next = &next_p->thread;
22457 int cpu = smp_processor_id();
22458 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22459 + struct tss_struct *tss = init_tss + cpu;
22460 unsigned fsindex, gsindex;
22461 fpu_switch_t fpu;
22462
22463 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22464 prev->usersp = this_cpu_read(old_rsp);
22465 this_cpu_write(old_rsp, next->usersp);
22466 this_cpu_write(current_task, next_p);
22467 + this_cpu_write(current_tinfo, &next_p->tinfo);
22468
22469 - this_cpu_write(kernel_stack,
22470 - (unsigned long)task_stack_page(next_p) +
22471 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22472 + this_cpu_write(kernel_stack, next->sp0);
22473
22474 /*
22475 * Now maybe reload the debug registers and handle I/O bitmaps
22476 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22477 if (!p || p == current || p->state == TASK_RUNNING)
22478 return 0;
22479 stack = (unsigned long)task_stack_page(p);
22480 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22481 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22482 return 0;
22483 fp = *(u64 *)(p->thread.sp);
22484 do {
22485 - if (fp < (unsigned long)stack ||
22486 - fp >= (unsigned long)stack+THREAD_SIZE)
22487 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22488 return 0;
22489 ip = *(u64 *)(fp+8);
22490 if (!in_sched_functions(ip))
22491 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22492 index b629bbe..0fa615a 100644
22493 --- a/arch/x86/kernel/ptrace.c
22494 +++ b/arch/x86/kernel/ptrace.c
22495 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22496 {
22497 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22498 unsigned long sp = (unsigned long)&regs->sp;
22499 - struct thread_info *tinfo;
22500
22501 - if (context == (sp & ~(THREAD_SIZE - 1)))
22502 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22503 return sp;
22504
22505 - tinfo = (struct thread_info *)context;
22506 - if (tinfo->previous_esp)
22507 - return tinfo->previous_esp;
22508 + sp = *(unsigned long *)context;
22509 + if (sp)
22510 + return sp;
22511
22512 return (unsigned long)regs;
22513 }
22514 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22515 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22516 {
22517 int i;
22518 - int dr7 = 0;
22519 + unsigned long dr7 = 0;
22520 struct arch_hw_breakpoint *info;
22521
22522 for (i = 0; i < HBP_NUM; i++) {
22523 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22524 unsigned long addr, unsigned long data)
22525 {
22526 int ret;
22527 - unsigned long __user *datap = (unsigned long __user *)data;
22528 + unsigned long __user *datap = (__force unsigned long __user *)data;
22529
22530 switch (request) {
22531 /* read the word at location addr in the USER area. */
22532 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22533 if ((int) addr < 0)
22534 return -EIO;
22535 ret = do_get_thread_area(child, addr,
22536 - (struct user_desc __user *)data);
22537 + (__force struct user_desc __user *) data);
22538 break;
22539
22540 case PTRACE_SET_THREAD_AREA:
22541 if ((int) addr < 0)
22542 return -EIO;
22543 ret = do_set_thread_area(child, addr,
22544 - (struct user_desc __user *)data, 0);
22545 + (__force struct user_desc __user *) data, 0);
22546 break;
22547 #endif
22548
22549 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22550
22551 #ifdef CONFIG_X86_64
22552
22553 -static struct user_regset x86_64_regsets[] __read_mostly = {
22554 +static user_regset_no_const x86_64_regsets[] __read_only = {
22555 [REGSET_GENERAL] = {
22556 .core_note_type = NT_PRSTATUS,
22557 .n = sizeof(struct user_regs_struct) / sizeof(long),
22558 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22559 #endif /* CONFIG_X86_64 */
22560
22561 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22562 -static struct user_regset x86_32_regsets[] __read_mostly = {
22563 +static user_regset_no_const x86_32_regsets[] __read_only = {
22564 [REGSET_GENERAL] = {
22565 .core_note_type = NT_PRSTATUS,
22566 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22567 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22568 */
22569 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22570
22571 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22572 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22573 {
22574 #ifdef CONFIG_X86_64
22575 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22576 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22577 memset(info, 0, sizeof(*info));
22578 info->si_signo = SIGTRAP;
22579 info->si_code = si_code;
22580 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22581 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22582 }
22583
22584 void user_single_step_siginfo(struct task_struct *tsk,
22585 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22586 # define IS_IA32 0
22587 #endif
22588
22589 +#ifdef CONFIG_GRKERNSEC_SETXID
22590 +extern void gr_delayed_cred_worker(void);
22591 +#endif
22592 +
22593 /*
22594 * We must return the syscall number to actually look up in the table.
22595 * This can be -1L to skip running any syscall at all.
22596 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22597
22598 user_exit();
22599
22600 +#ifdef CONFIG_GRKERNSEC_SETXID
22601 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22602 + gr_delayed_cred_worker();
22603 +#endif
22604 +
22605 /*
22606 * If we stepped into a sysenter/syscall insn, it trapped in
22607 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22608 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22609 */
22610 user_exit();
22611
22612 +#ifdef CONFIG_GRKERNSEC_SETXID
22613 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22614 + gr_delayed_cred_worker();
22615 +#endif
22616 +
22617 audit_syscall_exit(regs);
22618
22619 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22620 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22621 index 2cb9470..ff1fd80 100644
22622 --- a/arch/x86/kernel/pvclock.c
22623 +++ b/arch/x86/kernel/pvclock.c
22624 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22625 return pv_tsc_khz;
22626 }
22627
22628 -static atomic64_t last_value = ATOMIC64_INIT(0);
22629 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22630
22631 void pvclock_resume(void)
22632 {
22633 - atomic64_set(&last_value, 0);
22634 + atomic64_set_unchecked(&last_value, 0);
22635 }
22636
22637 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22638 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22639 * updating at the same time, and one of them could be slightly behind,
22640 * making the assumption that last_value always go forward fail to hold.
22641 */
22642 - last = atomic64_read(&last_value);
22643 + last = atomic64_read_unchecked(&last_value);
22644 do {
22645 if (ret < last)
22646 return last;
22647 - last = atomic64_cmpxchg(&last_value, last, ret);
22648 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22649 } while (unlikely(last != ret));
22650
22651 return ret;
22652 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22653 index 76fa1e9..abf09ea 100644
22654 --- a/arch/x86/kernel/reboot.c
22655 +++ b/arch/x86/kernel/reboot.c
22656 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22657 EXPORT_SYMBOL(pm_power_off);
22658
22659 static const struct desc_ptr no_idt = {};
22660 -static int reboot_mode;
22661 +static unsigned short reboot_mode;
22662 enum reboot_type reboot_type = BOOT_ACPI;
22663 int reboot_force;
22664
22665 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22666
22667 void __noreturn machine_real_restart(unsigned int type)
22668 {
22669 +
22670 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22671 + struct desc_struct *gdt;
22672 +#endif
22673 +
22674 local_irq_disable();
22675
22676 /*
22677 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22678
22679 /* Jump to the identity-mapped low memory code */
22680 #ifdef CONFIG_X86_32
22681 - asm volatile("jmpl *%0" : :
22682 +
22683 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22684 + gdt = get_cpu_gdt_table(smp_processor_id());
22685 + pax_open_kernel();
22686 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22687 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22688 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22689 + loadsegment(ds, __KERNEL_DS);
22690 + loadsegment(es, __KERNEL_DS);
22691 + loadsegment(ss, __KERNEL_DS);
22692 +#endif
22693 +#ifdef CONFIG_PAX_KERNEXEC
22694 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22695 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22696 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22697 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22698 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22699 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22700 +#endif
22701 + pax_close_kernel();
22702 +#endif
22703 +
22704 + asm volatile("ljmpl *%0" : :
22705 "rm" (real_mode_header->machine_real_restart_asm),
22706 "a" (type));
22707 #else
22708 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22709 * try to force a triple fault and then cycle between hitting the keyboard
22710 * controller and doing that
22711 */
22712 -static void native_machine_emergency_restart(void)
22713 +static void __noreturn native_machine_emergency_restart(void)
22714 {
22715 int i;
22716 int attempt = 0;
22717 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22718 #endif
22719 }
22720
22721 -static void __machine_emergency_restart(int emergency)
22722 +static void __noreturn __machine_emergency_restart(int emergency)
22723 {
22724 reboot_emergency = emergency;
22725 machine_ops.emergency_restart();
22726 }
22727
22728 -static void native_machine_restart(char *__unused)
22729 +static void __noreturn native_machine_restart(char *__unused)
22730 {
22731 pr_notice("machine restart\n");
22732
22733 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22734 __machine_emergency_restart(0);
22735 }
22736
22737 -static void native_machine_halt(void)
22738 +static void __noreturn native_machine_halt(void)
22739 {
22740 /* Stop other cpus and apics */
22741 machine_shutdown();
22742 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22743 stop_this_cpu(NULL);
22744 }
22745
22746 -static void native_machine_power_off(void)
22747 +static void __noreturn native_machine_power_off(void)
22748 {
22749 if (pm_power_off) {
22750 if (!reboot_force)
22751 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22752 }
22753 /* A fallback in case there is no PM info available */
22754 tboot_shutdown(TB_SHUTDOWN_HALT);
22755 + unreachable();
22756 }
22757
22758 -struct machine_ops machine_ops = {
22759 +struct machine_ops machine_ops __read_only = {
22760 .power_off = native_machine_power_off,
22761 .shutdown = native_machine_shutdown,
22762 .emergency_restart = native_machine_emergency_restart,
22763 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22764 index 7a6f3b3..bed145d7 100644
22765 --- a/arch/x86/kernel/relocate_kernel_64.S
22766 +++ b/arch/x86/kernel/relocate_kernel_64.S
22767 @@ -11,6 +11,7 @@
22768 #include <asm/kexec.h>
22769 #include <asm/processor-flags.h>
22770 #include <asm/pgtable_types.h>
22771 +#include <asm/alternative-asm.h>
22772
22773 /*
22774 * Must be relocatable PIC code callable as a C function
22775 @@ -160,13 +161,14 @@ identity_mapped:
22776 xorq %rbp, %rbp
22777 xorq %r8, %r8
22778 xorq %r9, %r9
22779 - xorq %r10, %r9
22780 + xorq %r10, %r10
22781 xorq %r11, %r11
22782 xorq %r12, %r12
22783 xorq %r13, %r13
22784 xorq %r14, %r14
22785 xorq %r15, %r15
22786
22787 + pax_force_retaddr 0, 1
22788 ret
22789
22790 1:
22791 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22792 index 8b24289..d37b58b 100644
22793 --- a/arch/x86/kernel/setup.c
22794 +++ b/arch/x86/kernel/setup.c
22795 @@ -437,7 +437,7 @@ static void __init parse_setup_data(void)
22796
22797 switch (data->type) {
22798 case SETUP_E820_EXT:
22799 - parse_e820_ext(data);
22800 + parse_e820_ext((struct setup_data __force_kernel *)data);
22801 break;
22802 case SETUP_DTB:
22803 add_dtb(pa_data);
22804 @@ -706,7 +706,7 @@ static void __init trim_bios_range(void)
22805 * area (640->1Mb) as ram even though it is not.
22806 * take them out.
22807 */
22808 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22809 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22810
22811 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22812 }
22813 @@ -830,14 +830,14 @@ void __init setup_arch(char **cmdline_p)
22814
22815 if (!boot_params.hdr.root_flags)
22816 root_mountflags &= ~MS_RDONLY;
22817 - init_mm.start_code = (unsigned long) _text;
22818 - init_mm.end_code = (unsigned long) _etext;
22819 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22820 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22821 init_mm.end_data = (unsigned long) _edata;
22822 init_mm.brk = _brk_end;
22823
22824 - code_resource.start = virt_to_phys(_text);
22825 - code_resource.end = virt_to_phys(_etext)-1;
22826 - data_resource.start = virt_to_phys(_etext);
22827 + code_resource.start = virt_to_phys(ktla_ktva(_text));
22828 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
22829 + data_resource.start = virt_to_phys(_sdata);
22830 data_resource.end = virt_to_phys(_edata)-1;
22831 bss_resource.start = virt_to_phys(&__bss_start);
22832 bss_resource.end = virt_to_phys(&__bss_stop)-1;
22833 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22834 index 5cdff03..80fa283 100644
22835 --- a/arch/x86/kernel/setup_percpu.c
22836 +++ b/arch/x86/kernel/setup_percpu.c
22837 @@ -21,19 +21,17 @@
22838 #include <asm/cpu.h>
22839 #include <asm/stackprotector.h>
22840
22841 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22842 +#ifdef CONFIG_SMP
22843 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22844 EXPORT_PER_CPU_SYMBOL(cpu_number);
22845 +#endif
22846
22847 -#ifdef CONFIG_X86_64
22848 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22849 -#else
22850 -#define BOOT_PERCPU_OFFSET 0
22851 -#endif
22852
22853 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22854 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22855
22856 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22857 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22858 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22859 };
22860 EXPORT_SYMBOL(__per_cpu_offset);
22861 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22862 {
22863 #ifdef CONFIG_NEED_MULTIPLE_NODES
22864 pg_data_t *last = NULL;
22865 - unsigned int cpu;
22866 + int cpu;
22867
22868 for_each_possible_cpu(cpu) {
22869 int node = early_cpu_to_node(cpu);
22870 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22871 {
22872 #ifdef CONFIG_X86_32
22873 struct desc_struct gdt;
22874 + unsigned long base = per_cpu_offset(cpu);
22875
22876 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22877 - 0x2 | DESCTYPE_S, 0x8);
22878 - gdt.s = 1;
22879 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22880 + 0x83 | DESCTYPE_S, 0xC);
22881 write_gdt_entry(get_cpu_gdt_table(cpu),
22882 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22883 #endif
22884 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22885 /* alrighty, percpu areas up and running */
22886 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22887 for_each_possible_cpu(cpu) {
22888 +#ifdef CONFIG_CC_STACKPROTECTOR
22889 +#ifdef CONFIG_X86_32
22890 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22891 +#endif
22892 +#endif
22893 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22894 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22895 per_cpu(cpu_number, cpu) = cpu;
22896 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22897 */
22898 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22899 #endif
22900 +#ifdef CONFIG_CC_STACKPROTECTOR
22901 +#ifdef CONFIG_X86_32
22902 + if (!cpu)
22903 + per_cpu(stack_canary.canary, cpu) = canary;
22904 +#endif
22905 +#endif
22906 /*
22907 * Up to this point, the boot CPU has been using .init.data
22908 * area. Reload any changed state for the boot CPU.
22909 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22910 index d6bf1f3..3ffce5a 100644
22911 --- a/arch/x86/kernel/signal.c
22912 +++ b/arch/x86/kernel/signal.c
22913 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22914 * Align the stack pointer according to the i386 ABI,
22915 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22916 */
22917 - sp = ((sp + 4) & -16ul) - 4;
22918 + sp = ((sp - 12) & -16ul) - 4;
22919 #else /* !CONFIG_X86_32 */
22920 sp = round_down(sp, 16) - 8;
22921 #endif
22922 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22923 }
22924
22925 if (current->mm->context.vdso)
22926 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22927 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22928 else
22929 - restorer = &frame->retcode;
22930 + restorer = (void __user *)&frame->retcode;
22931 if (ka->sa.sa_flags & SA_RESTORER)
22932 restorer = ka->sa.sa_restorer;
22933
22934 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22935 * reasons and because gdb uses it as a signature to notice
22936 * signal handler stack frames.
22937 */
22938 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22939 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22940
22941 if (err)
22942 return -EFAULT;
22943 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22944 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22945
22946 /* Set up to return from userspace. */
22947 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22948 + if (current->mm->context.vdso)
22949 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22950 + else
22951 + restorer = (void __user *)&frame->retcode;
22952 if (ka->sa.sa_flags & SA_RESTORER)
22953 restorer = ka->sa.sa_restorer;
22954 put_user_ex(restorer, &frame->pretcode);
22955 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22956 * reasons and because gdb uses it as a signature to notice
22957 * signal handler stack frames.
22958 */
22959 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22960 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22961 } put_user_catch(err);
22962
22963 err |= copy_siginfo_to_user(&frame->info, info);
22964 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22965 index 48d2b7d..90d328a 100644
22966 --- a/arch/x86/kernel/smp.c
22967 +++ b/arch/x86/kernel/smp.c
22968 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22969
22970 __setup("nonmi_ipi", nonmi_ipi_setup);
22971
22972 -struct smp_ops smp_ops = {
22973 +struct smp_ops smp_ops __read_only = {
22974 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22975 .smp_prepare_cpus = native_smp_prepare_cpus,
22976 .smp_cpus_done = native_smp_cpus_done,
22977 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22978 index ed0fe38..87fc692 100644
22979 --- a/arch/x86/kernel/smpboot.c
22980 +++ b/arch/x86/kernel/smpboot.c
22981 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22982 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22983 (THREAD_SIZE + task_stack_page(idle))) - 1);
22984 per_cpu(current_task, cpu) = idle;
22985 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22986
22987 #ifdef CONFIG_X86_32
22988 /* Stack for startup_32 can be just as for start_secondary onwards */
22989 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22990 #else
22991 clear_tsk_thread_flag(idle, TIF_FORK);
22992 initial_gs = per_cpu_offset(cpu);
22993 - per_cpu(kernel_stack, cpu) =
22994 - (unsigned long)task_stack_page(idle) -
22995 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22996 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22997 #endif
22998 +
22999 + pax_open_kernel();
23000 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
23001 + pax_close_kernel();
23002 +
23003 initial_code = (unsigned long)start_secondary;
23004 stack_start = idle->thread.sp;
23005
23006 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
23007 /* the FPU context is blank, nobody can own it */
23008 __cpu_disable_lazy_restore(cpu);
23009
23010 +#ifdef CONFIG_PAX_PER_CPU_PGD
23011 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
23012 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
23013 + KERNEL_PGD_PTRS);
23014 +#endif
23015 +
23016 + /* the FPU context is blank, nobody can own it */
23017 + __cpu_disable_lazy_restore(cpu);
23018 +
23019 err = do_boot_cpu(apicid, cpu, tidle);
23020 if (err) {
23021 pr_debug("do_boot_cpu failed %d\n", err);
23022 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
23023 index 9b4d51d..5d28b58 100644
23024 --- a/arch/x86/kernel/step.c
23025 +++ b/arch/x86/kernel/step.c
23026 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23027 struct desc_struct *desc;
23028 unsigned long base;
23029
23030 - seg &= ~7UL;
23031 + seg >>= 3;
23032
23033 mutex_lock(&child->mm->context.lock);
23034 - if (unlikely((seg >> 3) >= child->mm->context.size))
23035 + if (unlikely(seg >= child->mm->context.size))
23036 addr = -1L; /* bogus selector, access would fault */
23037 else {
23038 desc = child->mm->context.ldt + seg;
23039 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23040 addr += base;
23041 }
23042 mutex_unlock(&child->mm->context.lock);
23043 - }
23044 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
23045 + addr = ktla_ktva(addr);
23046
23047 return addr;
23048 }
23049 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
23050 unsigned char opcode[15];
23051 unsigned long addr = convert_ip_to_linear(child, regs);
23052
23053 + if (addr == -EINVAL)
23054 + return 0;
23055 +
23056 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
23057 for (i = 0; i < copied; i++) {
23058 switch (opcode[i]) {
23059 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
23060 new file mode 100644
23061 index 0000000..207bec6
23062 --- /dev/null
23063 +++ b/arch/x86/kernel/sys_i386_32.c
23064 @@ -0,0 +1,250 @@
23065 +/*
23066 + * This file contains various random system calls that
23067 + * have a non-standard calling sequence on the Linux/i386
23068 + * platform.
23069 + */
23070 +
23071 +#include <linux/errno.h>
23072 +#include <linux/sched.h>
23073 +#include <linux/mm.h>
23074 +#include <linux/fs.h>
23075 +#include <linux/smp.h>
23076 +#include <linux/sem.h>
23077 +#include <linux/msg.h>
23078 +#include <linux/shm.h>
23079 +#include <linux/stat.h>
23080 +#include <linux/syscalls.h>
23081 +#include <linux/mman.h>
23082 +#include <linux/file.h>
23083 +#include <linux/utsname.h>
23084 +#include <linux/ipc.h>
23085 +
23086 +#include <linux/uaccess.h>
23087 +#include <linux/unistd.h>
23088 +
23089 +#include <asm/syscalls.h>
23090 +
23091 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
23092 +{
23093 + unsigned long pax_task_size = TASK_SIZE;
23094 +
23095 +#ifdef CONFIG_PAX_SEGMEXEC
23096 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
23097 + pax_task_size = SEGMEXEC_TASK_SIZE;
23098 +#endif
23099 +
23100 + if (flags & MAP_FIXED)
23101 + if (len > pax_task_size || addr > pax_task_size - len)
23102 + return -EINVAL;
23103 +
23104 + return 0;
23105 +}
23106 +
23107 +unsigned long
23108 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
23109 + unsigned long len, unsigned long pgoff, unsigned long flags)
23110 +{
23111 + struct mm_struct *mm = current->mm;
23112 + struct vm_area_struct *vma;
23113 + unsigned long start_addr, pax_task_size = TASK_SIZE;
23114 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23115 +
23116 +#ifdef CONFIG_PAX_SEGMEXEC
23117 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23118 + pax_task_size = SEGMEXEC_TASK_SIZE;
23119 +#endif
23120 +
23121 + pax_task_size -= PAGE_SIZE;
23122 +
23123 + if (len > pax_task_size)
23124 + return -ENOMEM;
23125 +
23126 + if (flags & MAP_FIXED)
23127 + return addr;
23128 +
23129 +#ifdef CONFIG_PAX_RANDMMAP
23130 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23131 +#endif
23132 +
23133 + if (addr) {
23134 + addr = PAGE_ALIGN(addr);
23135 + if (pax_task_size - len >= addr) {
23136 + vma = find_vma(mm, addr);
23137 + if (check_heap_stack_gap(vma, addr, len, offset))
23138 + return addr;
23139 + }
23140 + }
23141 + if (len > mm->cached_hole_size) {
23142 + start_addr = addr = mm->free_area_cache;
23143 + } else {
23144 + start_addr = addr = mm->mmap_base;
23145 + mm->cached_hole_size = 0;
23146 + }
23147 +
23148 +#ifdef CONFIG_PAX_PAGEEXEC
23149 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
23150 + start_addr = 0x00110000UL;
23151 +
23152 +#ifdef CONFIG_PAX_RANDMMAP
23153 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23154 + start_addr += mm->delta_mmap & 0x03FFF000UL;
23155 +#endif
23156 +
23157 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
23158 + start_addr = addr = mm->mmap_base;
23159 + else
23160 + addr = start_addr;
23161 + }
23162 +#endif
23163 +
23164 +full_search:
23165 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
23166 + /* At this point: (!vma || addr < vma->vm_end). */
23167 + if (pax_task_size - len < addr) {
23168 + /*
23169 + * Start a new search - just in case we missed
23170 + * some holes.
23171 + */
23172 + if (start_addr != mm->mmap_base) {
23173 + start_addr = addr = mm->mmap_base;
23174 + mm->cached_hole_size = 0;
23175 + goto full_search;
23176 + }
23177 + return -ENOMEM;
23178 + }
23179 + if (check_heap_stack_gap(vma, addr, len, offset))
23180 + break;
23181 + if (addr + mm->cached_hole_size < vma->vm_start)
23182 + mm->cached_hole_size = vma->vm_start - addr;
23183 + addr = vma->vm_end;
23184 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
23185 + start_addr = addr = mm->mmap_base;
23186 + mm->cached_hole_size = 0;
23187 + goto full_search;
23188 + }
23189 + }
23190 +
23191 + /*
23192 + * Remember the place where we stopped the search:
23193 + */
23194 + mm->free_area_cache = addr + len;
23195 + return addr;
23196 +}
23197 +
23198 +unsigned long
23199 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23200 + const unsigned long len, const unsigned long pgoff,
23201 + const unsigned long flags)
23202 +{
23203 + struct vm_area_struct *vma;
23204 + struct mm_struct *mm = current->mm;
23205 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
23206 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23207 +
23208 +#ifdef CONFIG_PAX_SEGMEXEC
23209 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23210 + pax_task_size = SEGMEXEC_TASK_SIZE;
23211 +#endif
23212 +
23213 + pax_task_size -= PAGE_SIZE;
23214 +
23215 + /* requested length too big for entire address space */
23216 + if (len > pax_task_size)
23217 + return -ENOMEM;
23218 +
23219 + if (flags & MAP_FIXED)
23220 + return addr;
23221 +
23222 +#ifdef CONFIG_PAX_PAGEEXEC
23223 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23224 + goto bottomup;
23225 +#endif
23226 +
23227 +#ifdef CONFIG_PAX_RANDMMAP
23228 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23229 +#endif
23230 +
23231 + /* requesting a specific address */
23232 + if (addr) {
23233 + addr = PAGE_ALIGN(addr);
23234 + if (pax_task_size - len >= addr) {
23235 + vma = find_vma(mm, addr);
23236 + if (check_heap_stack_gap(vma, addr, len, offset))
23237 + return addr;
23238 + }
23239 + }
23240 +
23241 + /* check if free_area_cache is useful for us */
23242 + if (len <= mm->cached_hole_size) {
23243 + mm->cached_hole_size = 0;
23244 + mm->free_area_cache = mm->mmap_base;
23245 + }
23246 +
23247 + /* either no address requested or can't fit in requested address hole */
23248 + addr = mm->free_area_cache;
23249 +
23250 + /* make sure it can fit in the remaining address space */
23251 + if (addr > len) {
23252 + vma = find_vma(mm, addr-len);
23253 + if (check_heap_stack_gap(vma, addr - len, len, offset))
23254 + /* remember the address as a hint for next time */
23255 + return (mm->free_area_cache = addr-len);
23256 + }
23257 +
23258 + if (mm->mmap_base < len)
23259 + goto bottomup;
23260 +
23261 + addr = mm->mmap_base-len;
23262 +
23263 + do {
23264 + /*
23265 + * Lookup failure means no vma is above this address,
23266 + * else if new region fits below vma->vm_start,
23267 + * return with success:
23268 + */
23269 + vma = find_vma(mm, addr);
23270 + if (check_heap_stack_gap(vma, addr, len, offset))
23271 + /* remember the address as a hint for next time */
23272 + return (mm->free_area_cache = addr);
23273 +
23274 + /* remember the largest hole we saw so far */
23275 + if (addr + mm->cached_hole_size < vma->vm_start)
23276 + mm->cached_hole_size = vma->vm_start - addr;
23277 +
23278 + /* try just below the current vma->vm_start */
23279 + addr = skip_heap_stack_gap(vma, len, offset);
23280 + } while (!IS_ERR_VALUE(addr));
23281 +
23282 +bottomup:
23283 + /*
23284 + * A failed mmap() very likely causes application failure,
23285 + * so fall back to the bottom-up function here. This scenario
23286 + * can happen with large stack limits and large mmap()
23287 + * allocations.
23288 + */
23289 +
23290 +#ifdef CONFIG_PAX_SEGMEXEC
23291 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23292 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23293 + else
23294 +#endif
23295 +
23296 + mm->mmap_base = TASK_UNMAPPED_BASE;
23297 +
23298 +#ifdef CONFIG_PAX_RANDMMAP
23299 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23300 + mm->mmap_base += mm->delta_mmap;
23301 +#endif
23302 +
23303 + mm->free_area_cache = mm->mmap_base;
23304 + mm->cached_hole_size = ~0UL;
23305 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23306 + /*
23307 + * Restore the topdown base:
23308 + */
23309 + mm->mmap_base = base;
23310 + mm->free_area_cache = base;
23311 + mm->cached_hole_size = ~0UL;
23312 +
23313 + return addr;
23314 +}
23315 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23316 index 97ef74b..57a1882 100644
23317 --- a/arch/x86/kernel/sys_x86_64.c
23318 +++ b/arch/x86/kernel/sys_x86_64.c
23319 @@ -81,8 +81,8 @@ out:
23320 return error;
23321 }
23322
23323 -static void find_start_end(unsigned long flags, unsigned long *begin,
23324 - unsigned long *end)
23325 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23326 + unsigned long *begin, unsigned long *end)
23327 {
23328 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23329 unsigned long new_begin;
23330 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23331 *begin = new_begin;
23332 }
23333 } else {
23334 - *begin = TASK_UNMAPPED_BASE;
23335 + *begin = mm->mmap_base;
23336 *end = TASK_SIZE;
23337 }
23338 }
23339 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23340 struct vm_area_struct *vma;
23341 struct vm_unmapped_area_info info;
23342 unsigned long begin, end;
23343 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23344
23345 if (flags & MAP_FIXED)
23346 return addr;
23347
23348 - find_start_end(flags, &begin, &end);
23349 + find_start_end(mm, flags, &begin, &end);
23350
23351 if (len > end)
23352 return -ENOMEM;
23353
23354 +#ifdef CONFIG_PAX_RANDMMAP
23355 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23356 +#endif
23357 +
23358 if (addr) {
23359 addr = PAGE_ALIGN(addr);
23360 vma = find_vma(mm, addr);
23361 - if (end - len >= addr &&
23362 - (!vma || addr + len <= vma->vm_start))
23363 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23364 return addr;
23365 }
23366
23367 @@ -161,6 +165,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23368 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23369 goto bottomup;
23370
23371 +#ifdef CONFIG_PAX_RANDMMAP
23372 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23373 +#endif
23374 +
23375 /* requesting a specific address */
23376 if (addr) {
23377 addr = PAGE_ALIGN(addr);
23378 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23379 index f84fe00..f41d9f1 100644
23380 --- a/arch/x86/kernel/tboot.c
23381 +++ b/arch/x86/kernel/tboot.c
23382 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23383
23384 void tboot_shutdown(u32 shutdown_type)
23385 {
23386 - void (*shutdown)(void);
23387 + void (* __noreturn shutdown)(void);
23388
23389 if (!tboot_enabled())
23390 return;
23391 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23392
23393 switch_to_tboot_pt();
23394
23395 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23396 + shutdown = (void *)tboot->shutdown_entry;
23397 shutdown();
23398
23399 /* should not reach here */
23400 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23401 return 0;
23402 }
23403
23404 -static atomic_t ap_wfs_count;
23405 +static atomic_unchecked_t ap_wfs_count;
23406
23407 static int tboot_wait_for_aps(int num_aps)
23408 {
23409 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23410 {
23411 switch (action) {
23412 case CPU_DYING:
23413 - atomic_inc(&ap_wfs_count);
23414 + atomic_inc_unchecked(&ap_wfs_count);
23415 if (num_online_cpus() == 1)
23416 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23417 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23418 return NOTIFY_BAD;
23419 break;
23420 }
23421 return NOTIFY_OK;
23422 }
23423
23424 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23425 +static struct notifier_block tboot_cpu_notifier =
23426 {
23427 .notifier_call = tboot_cpu_callback,
23428 };
23429 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23430
23431 tboot_create_trampoline();
23432
23433 - atomic_set(&ap_wfs_count, 0);
23434 + atomic_set_unchecked(&ap_wfs_count, 0);
23435 register_hotcpu_notifier(&tboot_cpu_notifier);
23436
23437 acpi_os_set_prepare_sleep(&tboot_sleep);
23438 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23439 index 24d3c91..d06b473 100644
23440 --- a/arch/x86/kernel/time.c
23441 +++ b/arch/x86/kernel/time.c
23442 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23443 {
23444 unsigned long pc = instruction_pointer(regs);
23445
23446 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23447 + if (!user_mode(regs) && in_lock_functions(pc)) {
23448 #ifdef CONFIG_FRAME_POINTER
23449 - return *(unsigned long *)(regs->bp + sizeof(long));
23450 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23451 #else
23452 unsigned long *sp =
23453 (unsigned long *)kernel_stack_pointer(regs);
23454 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23455 * or above a saved flags. Eflags has bits 22-31 zero,
23456 * kernel addresses don't.
23457 */
23458 +
23459 +#ifdef CONFIG_PAX_KERNEXEC
23460 + return ktla_ktva(sp[0]);
23461 +#else
23462 if (sp[0] >> 22)
23463 return sp[0];
23464 if (sp[1] >> 22)
23465 return sp[1];
23466 #endif
23467 +
23468 +#endif
23469 }
23470 return pc;
23471 }
23472 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23473 index 9d9d2f9..cad418a 100644
23474 --- a/arch/x86/kernel/tls.c
23475 +++ b/arch/x86/kernel/tls.c
23476 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23477 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23478 return -EINVAL;
23479
23480 +#ifdef CONFIG_PAX_SEGMEXEC
23481 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23482 + return -EINVAL;
23483 +#endif
23484 +
23485 set_tls_desc(p, idx, &info, 1);
23486
23487 return 0;
23488 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23489
23490 if (kbuf)
23491 info = kbuf;
23492 - else if (__copy_from_user(infobuf, ubuf, count))
23493 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23494 return -EFAULT;
23495 else
23496 info = infobuf;
23497 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23498 index ecffca1..95c4d13 100644
23499 --- a/arch/x86/kernel/traps.c
23500 +++ b/arch/x86/kernel/traps.c
23501 @@ -68,12 +68,6 @@
23502 #include <asm/setup.h>
23503
23504 asmlinkage int system_call(void);
23505 -
23506 -/*
23507 - * The IDT has to be page-aligned to simplify the Pentium
23508 - * F0 0F bug workaround.
23509 - */
23510 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23511 #endif
23512
23513 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23514 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23515 }
23516
23517 static int __kprobes
23518 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23519 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23520 struct pt_regs *regs, long error_code)
23521 {
23522 #ifdef CONFIG_X86_32
23523 - if (regs->flags & X86_VM_MASK) {
23524 + if (v8086_mode(regs)) {
23525 /*
23526 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23527 * On nmi (interrupt 2), do_trap should not be called.
23528 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23529 return -1;
23530 }
23531 #endif
23532 - if (!user_mode(regs)) {
23533 + if (!user_mode_novm(regs)) {
23534 if (!fixup_exception(regs)) {
23535 tsk->thread.error_code = error_code;
23536 tsk->thread.trap_nr = trapnr;
23537 +
23538 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23539 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23540 + str = "PAX: suspicious stack segment fault";
23541 +#endif
23542 +
23543 die(str, regs, error_code);
23544 }
23545 +
23546 +#ifdef CONFIG_PAX_REFCOUNT
23547 + if (trapnr == 4)
23548 + pax_report_refcount_overflow(regs);
23549 +#endif
23550 +
23551 return 0;
23552 }
23553
23554 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23555 }
23556
23557 static void __kprobes
23558 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23559 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23560 long error_code, siginfo_t *info)
23561 {
23562 struct task_struct *tsk = current;
23563 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23564 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23565 printk_ratelimit()) {
23566 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23567 - tsk->comm, tsk->pid, str,
23568 + tsk->comm, task_pid_nr(tsk), str,
23569 regs->ip, regs->sp, error_code);
23570 print_vma_addr(" in ", regs->ip);
23571 pr_cont("\n");
23572 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23573 conditional_sti(regs);
23574
23575 #ifdef CONFIG_X86_32
23576 - if (regs->flags & X86_VM_MASK) {
23577 + if (v8086_mode(regs)) {
23578 local_irq_enable();
23579 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23580 goto exit;
23581 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23582 #endif
23583
23584 tsk = current;
23585 - if (!user_mode(regs)) {
23586 + if (!user_mode_novm(regs)) {
23587 if (fixup_exception(regs))
23588 goto exit;
23589
23590 tsk->thread.error_code = error_code;
23591 tsk->thread.trap_nr = X86_TRAP_GP;
23592 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23593 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23594 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23595 +
23596 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23597 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23598 + die("PAX: suspicious general protection fault", regs, error_code);
23599 + else
23600 +#endif
23601 +
23602 die("general protection fault", regs, error_code);
23603 + }
23604 goto exit;
23605 }
23606
23607 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23608 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23609 + struct mm_struct *mm = tsk->mm;
23610 + unsigned long limit;
23611 +
23612 + down_write(&mm->mmap_sem);
23613 + limit = mm->context.user_cs_limit;
23614 + if (limit < TASK_SIZE) {
23615 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23616 + up_write(&mm->mmap_sem);
23617 + return;
23618 + }
23619 + up_write(&mm->mmap_sem);
23620 + }
23621 +#endif
23622 +
23623 tsk->thread.error_code = error_code;
23624 tsk->thread.trap_nr = X86_TRAP_GP;
23625
23626 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23627 /* It's safe to allow irq's after DR6 has been saved */
23628 preempt_conditional_sti(regs);
23629
23630 - if (regs->flags & X86_VM_MASK) {
23631 + if (v8086_mode(regs)) {
23632 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23633 X86_TRAP_DB);
23634 preempt_conditional_cli(regs);
23635 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23636 * We already checked v86 mode above, so we can check for kernel mode
23637 * by just checking the CPL of CS.
23638 */
23639 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23640 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23641 tsk->thread.debugreg6 &= ~DR_STEP;
23642 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23643 regs->flags &= ~X86_EFLAGS_TF;
23644 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23645 return;
23646 conditional_sti(regs);
23647
23648 - if (!user_mode_vm(regs))
23649 + if (!user_mode(regs))
23650 {
23651 if (!fixup_exception(regs)) {
23652 task->thread.error_code = error_code;
23653 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23654 index c71025b..b117501 100644
23655 --- a/arch/x86/kernel/uprobes.c
23656 +++ b/arch/x86/kernel/uprobes.c
23657 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23658 int ret = NOTIFY_DONE;
23659
23660 /* We are only interested in userspace traps */
23661 - if (regs && !user_mode_vm(regs))
23662 + if (regs && !user_mode(regs))
23663 return NOTIFY_DONE;
23664
23665 switch (val) {
23666 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23667 index b9242ba..50c5edd 100644
23668 --- a/arch/x86/kernel/verify_cpu.S
23669 +++ b/arch/x86/kernel/verify_cpu.S
23670 @@ -20,6 +20,7 @@
23671 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23672 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23673 * arch/x86/kernel/head_32.S: processor startup
23674 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23675 *
23676 * verify_cpu, returns the status of longmode and SSE in register %eax.
23677 * 0: Success 1: Failure
23678 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23679 index 1dfe69c..a3df6f6 100644
23680 --- a/arch/x86/kernel/vm86_32.c
23681 +++ b/arch/x86/kernel/vm86_32.c
23682 @@ -43,6 +43,7 @@
23683 #include <linux/ptrace.h>
23684 #include <linux/audit.h>
23685 #include <linux/stddef.h>
23686 +#include <linux/grsecurity.h>
23687
23688 #include <asm/uaccess.h>
23689 #include <asm/io.h>
23690 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23691 do_exit(SIGSEGV);
23692 }
23693
23694 - tss = &per_cpu(init_tss, get_cpu());
23695 + tss = init_tss + get_cpu();
23696 current->thread.sp0 = current->thread.saved_sp0;
23697 current->thread.sysenter_cs = __KERNEL_CS;
23698 load_sp0(tss, &current->thread);
23699 @@ -212,6 +213,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
23700 struct task_struct *tsk;
23701 int tmp, ret = -EPERM;
23702
23703 +#ifdef CONFIG_GRKERNSEC_VM86
23704 + if (!capable(CAP_SYS_RAWIO)) {
23705 + gr_handle_vm86();
23706 + goto out;
23707 + }
23708 +#endif
23709 +
23710 tsk = current;
23711 if (tsk->thread.saved_sp0)
23712 goto out;
23713 @@ -242,6 +250,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
23714 int tmp, ret;
23715 struct vm86plus_struct __user *v86;
23716
23717 +#ifdef CONFIG_GRKERNSEC_VM86
23718 + if (!capable(CAP_SYS_RAWIO)) {
23719 + gr_handle_vm86();
23720 + ret = -EPERM;
23721 + goto out;
23722 + }
23723 +#endif
23724 +
23725 tsk = current;
23726 switch (cmd) {
23727 case VM86_REQUEST_IRQ:
23728 @@ -328,7 +344,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23729 tsk->thread.saved_fs = info->regs32->fs;
23730 tsk->thread.saved_gs = get_user_gs(info->regs32);
23731
23732 - tss = &per_cpu(init_tss, get_cpu());
23733 + tss = init_tss + get_cpu();
23734 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23735 if (cpu_has_sep)
23736 tsk->thread.sysenter_cs = 0;
23737 @@ -535,7 +551,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23738 goto cannot_handle;
23739 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23740 goto cannot_handle;
23741 - intr_ptr = (unsigned long __user *) (i << 2);
23742 + intr_ptr = (__force unsigned long __user *) (i << 2);
23743 if (get_user(segoffs, intr_ptr))
23744 goto cannot_handle;
23745 if ((segoffs >> 16) == BIOSSEG)
23746 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23747 index 22a1530..8fbaaad 100644
23748 --- a/arch/x86/kernel/vmlinux.lds.S
23749 +++ b/arch/x86/kernel/vmlinux.lds.S
23750 @@ -26,6 +26,13 @@
23751 #include <asm/page_types.h>
23752 #include <asm/cache.h>
23753 #include <asm/boot.h>
23754 +#include <asm/segment.h>
23755 +
23756 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23757 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23758 +#else
23759 +#define __KERNEL_TEXT_OFFSET 0
23760 +#endif
23761
23762 #undef i386 /* in case the preprocessor is a 32bit one */
23763
23764 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23765
23766 PHDRS {
23767 text PT_LOAD FLAGS(5); /* R_E */
23768 +#ifdef CONFIG_X86_32
23769 + module PT_LOAD FLAGS(5); /* R_E */
23770 +#endif
23771 +#ifdef CONFIG_XEN
23772 + rodata PT_LOAD FLAGS(5); /* R_E */
23773 +#else
23774 + rodata PT_LOAD FLAGS(4); /* R__ */
23775 +#endif
23776 data PT_LOAD FLAGS(6); /* RW_ */
23777 -#ifdef CONFIG_X86_64
23778 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23779 #ifdef CONFIG_SMP
23780 percpu PT_LOAD FLAGS(6); /* RW_ */
23781 #endif
23782 + text.init PT_LOAD FLAGS(5); /* R_E */
23783 + text.exit PT_LOAD FLAGS(5); /* R_E */
23784 init PT_LOAD FLAGS(7); /* RWE */
23785 -#endif
23786 note PT_NOTE FLAGS(0); /* ___ */
23787 }
23788
23789 SECTIONS
23790 {
23791 #ifdef CONFIG_X86_32
23792 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23793 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23794 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23795 #else
23796 - . = __START_KERNEL;
23797 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23798 + . = __START_KERNEL;
23799 #endif
23800
23801 /* Text and read-only data */
23802 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23803 - _text = .;
23804 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23805 /* bootstrapping code */
23806 +#ifdef CONFIG_X86_32
23807 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23808 +#else
23809 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23810 +#endif
23811 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23812 + _text = .;
23813 HEAD_TEXT
23814 #ifdef CONFIG_X86_32
23815 . = ALIGN(PAGE_SIZE);
23816 @@ -108,13 +128,48 @@ SECTIONS
23817 IRQENTRY_TEXT
23818 *(.fixup)
23819 *(.gnu.warning)
23820 - /* End of text section */
23821 - _etext = .;
23822 } :text = 0x9090
23823
23824 - NOTES :text :note
23825 + . += __KERNEL_TEXT_OFFSET;
23826
23827 - EXCEPTION_TABLE(16) :text = 0x9090
23828 +#ifdef CONFIG_X86_32
23829 + . = ALIGN(PAGE_SIZE);
23830 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23831 +
23832 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23833 + MODULES_EXEC_VADDR = .;
23834 + BYTE(0)
23835 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23836 + . = ALIGN(HPAGE_SIZE) - 1;
23837 + MODULES_EXEC_END = .;
23838 +#endif
23839 +
23840 + } :module
23841 +#endif
23842 +
23843 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23844 + /* End of text section */
23845 + BYTE(0)
23846 + _etext = . - __KERNEL_TEXT_OFFSET;
23847 + }
23848 +
23849 +#ifdef CONFIG_X86_32
23850 + . = ALIGN(PAGE_SIZE);
23851 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23852 + *(.idt)
23853 + . = ALIGN(PAGE_SIZE);
23854 + *(.empty_zero_page)
23855 + *(.initial_pg_fixmap)
23856 + *(.initial_pg_pmd)
23857 + *(.initial_page_table)
23858 + *(.swapper_pg_dir)
23859 + } :rodata
23860 +#endif
23861 +
23862 + . = ALIGN(PAGE_SIZE);
23863 + NOTES :rodata :note
23864 +
23865 + EXCEPTION_TABLE(16) :rodata
23866
23867 #if defined(CONFIG_DEBUG_RODATA)
23868 /* .text should occupy whole number of pages */
23869 @@ -126,16 +181,20 @@ SECTIONS
23870
23871 /* Data */
23872 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23873 +
23874 +#ifdef CONFIG_PAX_KERNEXEC
23875 + . = ALIGN(HPAGE_SIZE);
23876 +#else
23877 + . = ALIGN(PAGE_SIZE);
23878 +#endif
23879 +
23880 /* Start of data section */
23881 _sdata = .;
23882
23883 /* init_task */
23884 INIT_TASK_DATA(THREAD_SIZE)
23885
23886 -#ifdef CONFIG_X86_32
23887 - /* 32 bit has nosave before _edata */
23888 NOSAVE_DATA
23889 -#endif
23890
23891 PAGE_ALIGNED_DATA(PAGE_SIZE)
23892
23893 @@ -176,12 +235,19 @@ SECTIONS
23894 #endif /* CONFIG_X86_64 */
23895
23896 /* Init code and data - will be freed after init */
23897 - . = ALIGN(PAGE_SIZE);
23898 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23899 + BYTE(0)
23900 +
23901 +#ifdef CONFIG_PAX_KERNEXEC
23902 + . = ALIGN(HPAGE_SIZE);
23903 +#else
23904 + . = ALIGN(PAGE_SIZE);
23905 +#endif
23906 +
23907 __init_begin = .; /* paired with __init_end */
23908 - }
23909 + } :init.begin
23910
23911 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23912 +#ifdef CONFIG_SMP
23913 /*
23914 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23915 * output PHDR, so the next output section - .init.text - should
23916 @@ -190,12 +256,27 @@ SECTIONS
23917 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23918 #endif
23919
23920 - INIT_TEXT_SECTION(PAGE_SIZE)
23921 -#ifdef CONFIG_X86_64
23922 - :init
23923 -#endif
23924 + . = ALIGN(PAGE_SIZE);
23925 + init_begin = .;
23926 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23927 + VMLINUX_SYMBOL(_sinittext) = .;
23928 + INIT_TEXT
23929 + VMLINUX_SYMBOL(_einittext) = .;
23930 + . = ALIGN(PAGE_SIZE);
23931 + } :text.init
23932
23933 - INIT_DATA_SECTION(16)
23934 + /*
23935 + * .exit.text is discard at runtime, not link time, to deal with
23936 + * references from .altinstructions and .eh_frame
23937 + */
23938 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23939 + EXIT_TEXT
23940 + . = ALIGN(16);
23941 + } :text.exit
23942 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23943 +
23944 + . = ALIGN(PAGE_SIZE);
23945 + INIT_DATA_SECTION(16) :init
23946
23947 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23948 __x86_cpu_dev_start = .;
23949 @@ -257,19 +338,12 @@ SECTIONS
23950 }
23951
23952 . = ALIGN(8);
23953 - /*
23954 - * .exit.text is discard at runtime, not link time, to deal with
23955 - * references from .altinstructions and .eh_frame
23956 - */
23957 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23958 - EXIT_TEXT
23959 - }
23960
23961 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23962 EXIT_DATA
23963 }
23964
23965 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23966 +#ifndef CONFIG_SMP
23967 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23968 #endif
23969
23970 @@ -288,16 +362,10 @@ SECTIONS
23971 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23972 __smp_locks = .;
23973 *(.smp_locks)
23974 - . = ALIGN(PAGE_SIZE);
23975 __smp_locks_end = .;
23976 + . = ALIGN(PAGE_SIZE);
23977 }
23978
23979 -#ifdef CONFIG_X86_64
23980 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23981 - NOSAVE_DATA
23982 - }
23983 -#endif
23984 -
23985 /* BSS */
23986 . = ALIGN(PAGE_SIZE);
23987 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23988 @@ -313,6 +381,7 @@ SECTIONS
23989 __brk_base = .;
23990 . += 64 * 1024; /* 64k alignment slop space */
23991 *(.brk_reservation) /* areas brk users have reserved */
23992 + . = ALIGN(HPAGE_SIZE);
23993 __brk_limit = .;
23994 }
23995
23996 @@ -339,13 +408,12 @@ SECTIONS
23997 * for the boot processor.
23998 */
23999 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
24000 -INIT_PER_CPU(gdt_page);
24001 INIT_PER_CPU(irq_stack_union);
24002
24003 /*
24004 * Build-time check on the image size:
24005 */
24006 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
24007 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
24008 "kernel image bigger than KERNEL_IMAGE_SIZE");
24009
24010 #ifdef CONFIG_SMP
24011 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
24012 index 9a907a6..f83f921 100644
24013 --- a/arch/x86/kernel/vsyscall_64.c
24014 +++ b/arch/x86/kernel/vsyscall_64.c
24015 @@ -56,15 +56,13 @@
24016 DEFINE_VVAR(int, vgetcpu_mode);
24017 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
24018
24019 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
24020 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
24021
24022 static int __init vsyscall_setup(char *str)
24023 {
24024 if (str) {
24025 if (!strcmp("emulate", str))
24026 vsyscall_mode = EMULATE;
24027 - else if (!strcmp("native", str))
24028 - vsyscall_mode = NATIVE;
24029 else if (!strcmp("none", str))
24030 vsyscall_mode = NONE;
24031 else
24032 @@ -323,8 +321,7 @@ do_ret:
24033 return true;
24034
24035 sigsegv:
24036 - force_sig(SIGSEGV, current);
24037 - return true;
24038 + do_group_exit(SIGKILL);
24039 }
24040
24041 /*
24042 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
24043 extern char __vvar_page;
24044 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
24045
24046 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
24047 - vsyscall_mode == NATIVE
24048 - ? PAGE_KERNEL_VSYSCALL
24049 - : PAGE_KERNEL_VVAR);
24050 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
24051 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
24052 (unsigned long)VSYSCALL_START);
24053
24054 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
24055 index 1330dd1..d220b99 100644
24056 --- a/arch/x86/kernel/x8664_ksyms_64.c
24057 +++ b/arch/x86/kernel/x8664_ksyms_64.c
24058 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
24059 EXPORT_SYMBOL(copy_user_generic_unrolled);
24060 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
24061 EXPORT_SYMBOL(__copy_user_nocache);
24062 -EXPORT_SYMBOL(_copy_from_user);
24063 -EXPORT_SYMBOL(_copy_to_user);
24064
24065 EXPORT_SYMBOL(copy_page);
24066 EXPORT_SYMBOL(clear_page);
24067 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
24068 index 7a3d075..6cb373d 100644
24069 --- a/arch/x86/kernel/x86_init.c
24070 +++ b/arch/x86/kernel/x86_init.c
24071 @@ -88,7 +88,7 @@ struct x86_init_ops x86_init __initdata = {
24072 },
24073 };
24074
24075 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24076 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
24077 .early_percpu_clock_init = x86_init_noop,
24078 .setup_percpu_clockev = setup_secondary_APIC_clock,
24079 };
24080 @@ -96,7 +96,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24081 static void default_nmi_init(void) { };
24082 static int default_i8042_detect(void) { return 1; };
24083
24084 -struct x86_platform_ops x86_platform = {
24085 +struct x86_platform_ops x86_platform __read_only = {
24086 .calibrate_tsc = native_calibrate_tsc,
24087 .get_wallclock = mach_get_cmos_time,
24088 .set_wallclock = mach_set_rtc_mmss,
24089 @@ -110,14 +110,14 @@ struct x86_platform_ops x86_platform = {
24090 };
24091
24092 EXPORT_SYMBOL_GPL(x86_platform);
24093 -struct x86_msi_ops x86_msi = {
24094 +struct x86_msi_ops x86_msi __read_only = {
24095 .setup_msi_irqs = native_setup_msi_irqs,
24096 .teardown_msi_irq = native_teardown_msi_irq,
24097 .teardown_msi_irqs = default_teardown_msi_irqs,
24098 .restore_msi_irqs = default_restore_msi_irqs,
24099 };
24100
24101 -struct x86_io_apic_ops x86_io_apic_ops = {
24102 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
24103 .init = native_io_apic_init_mappings,
24104 .read = native_io_apic_read,
24105 .write = native_io_apic_write,
24106 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
24107 index ada87a3..afea76d 100644
24108 --- a/arch/x86/kernel/xsave.c
24109 +++ b/arch/x86/kernel/xsave.c
24110 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
24111 {
24112 int err;
24113
24114 + buf = (struct xsave_struct __user *)____m(buf);
24115 if (use_xsave())
24116 err = xsave_user(buf);
24117 else if (use_fxsr())
24118 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
24119 */
24120 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
24121 {
24122 + buf = (void __user *)____m(buf);
24123 if (use_xsave()) {
24124 if ((unsigned long)buf % 64 || fx_only) {
24125 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
24126 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
24127 index a20ecb5..d0e2194 100644
24128 --- a/arch/x86/kvm/cpuid.c
24129 +++ b/arch/x86/kvm/cpuid.c
24130 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
24131 struct kvm_cpuid2 *cpuid,
24132 struct kvm_cpuid_entry2 __user *entries)
24133 {
24134 - int r;
24135 + int r, i;
24136
24137 r = -E2BIG;
24138 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
24139 goto out;
24140 r = -EFAULT;
24141 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
24142 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24143 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24144 goto out;
24145 + for (i = 0; i < cpuid->nent; ++i) {
24146 + struct kvm_cpuid_entry2 cpuid_entry;
24147 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
24148 + goto out;
24149 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
24150 + }
24151 vcpu->arch.cpuid_nent = cpuid->nent;
24152 kvm_apic_set_version(vcpu);
24153 kvm_x86_ops->cpuid_update(vcpu);
24154 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
24155 struct kvm_cpuid2 *cpuid,
24156 struct kvm_cpuid_entry2 __user *entries)
24157 {
24158 - int r;
24159 + int r, i;
24160
24161 r = -E2BIG;
24162 if (cpuid->nent < vcpu->arch.cpuid_nent)
24163 goto out;
24164 r = -EFAULT;
24165 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
24166 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24167 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24168 goto out;
24169 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
24170 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
24171 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
24172 + goto out;
24173 + }
24174 return 0;
24175
24176 out:
24177 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24178 index a27e763..54bfe43 100644
24179 --- a/arch/x86/kvm/emulate.c
24180 +++ b/arch/x86/kvm/emulate.c
24181 @@ -292,6 +292,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24182
24183 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24184 do { \
24185 + unsigned long _tmp; \
24186 __asm__ __volatile__ ( \
24187 _PRE_EFLAGS("0", "4", "2") \
24188 _op _suffix " %"_x"3,%1; " \
24189 @@ -306,8 +307,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24190 /* Raw emulation: instruction has two explicit operands. */
24191 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24192 do { \
24193 - unsigned long _tmp; \
24194 - \
24195 switch ((ctxt)->dst.bytes) { \
24196 case 2: \
24197 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24198 @@ -323,7 +322,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24199
24200 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24201 do { \
24202 - unsigned long _tmp; \
24203 switch ((ctxt)->dst.bytes) { \
24204 case 1: \
24205 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24206 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24207 index 9392f52..0e56d77 100644
24208 --- a/arch/x86/kvm/lapic.c
24209 +++ b/arch/x86/kvm/lapic.c
24210 @@ -55,7 +55,7 @@
24211 #define APIC_BUS_CYCLE_NS 1
24212
24213 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24214 -#define apic_debug(fmt, arg...)
24215 +#define apic_debug(fmt, arg...) do {} while (0)
24216
24217 #define APIC_LVT_NUM 6
24218 /* 14 is the version for Xeon and Pentium 8.4.8*/
24219 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24220 index 891eb6d..e027900 100644
24221 --- a/arch/x86/kvm/paging_tmpl.h
24222 +++ b/arch/x86/kvm/paging_tmpl.h
24223 @@ -208,7 +208,7 @@ retry_walk:
24224 if (unlikely(kvm_is_error_hva(host_addr)))
24225 goto error;
24226
24227 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24228 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24229 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24230 goto error;
24231 walker->ptep_user[walker->level - 1] = ptep_user;
24232 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24233 index d29d3cd..ec9d522 100644
24234 --- a/arch/x86/kvm/svm.c
24235 +++ b/arch/x86/kvm/svm.c
24236 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24237 int cpu = raw_smp_processor_id();
24238
24239 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24240 +
24241 + pax_open_kernel();
24242 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24243 + pax_close_kernel();
24244 +
24245 load_TR_desc();
24246 }
24247
24248 @@ -3881,6 +3885,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24249 #endif
24250 #endif
24251
24252 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24253 + __set_fs(current_thread_info()->addr_limit);
24254 +#endif
24255 +
24256 reload_tss(vcpu);
24257
24258 local_irq_disable();
24259 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24260 index 9120ae1..238abc0 100644
24261 --- a/arch/x86/kvm/vmx.c
24262 +++ b/arch/x86/kvm/vmx.c
24263 @@ -1370,7 +1370,11 @@ static void reload_tss(void)
24264 struct desc_struct *descs;
24265
24266 descs = (void *)gdt->address;
24267 +
24268 + pax_open_kernel();
24269 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24270 + pax_close_kernel();
24271 +
24272 load_TR_desc();
24273 }
24274
24275 @@ -1594,6 +1598,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24276 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24277 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24278
24279 +#ifdef CONFIG_PAX_PER_CPU_PGD
24280 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24281 +#endif
24282 +
24283 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24284 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24285 vmx->loaded_vmcs->cpu = cpu;
24286 @@ -2738,8 +2746,11 @@ static __init int hardware_setup(void)
24287 if (!cpu_has_vmx_flexpriority())
24288 flexpriority_enabled = 0;
24289
24290 - if (!cpu_has_vmx_tpr_shadow())
24291 - kvm_x86_ops->update_cr8_intercept = NULL;
24292 + if (!cpu_has_vmx_tpr_shadow()) {
24293 + pax_open_kernel();
24294 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24295 + pax_close_kernel();
24296 + }
24297
24298 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24299 kvm_disable_largepages();
24300 @@ -3782,7 +3793,10 @@ static void vmx_set_constant_host_state(void)
24301
24302 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24303 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24304 +
24305 +#ifndef CONFIG_PAX_PER_CPU_PGD
24306 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24307 +#endif
24308
24309 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24310 #ifdef CONFIG_X86_64
24311 @@ -3803,7 +3817,7 @@ static void vmx_set_constant_host_state(void)
24312 native_store_idt(&dt);
24313 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24314
24315 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24316 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24317
24318 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24319 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24320 @@ -6355,6 +6369,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24321 "jmp 2f \n\t"
24322 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24323 "2: "
24324 +
24325 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24326 + "ljmp %[cs],$3f\n\t"
24327 + "3: "
24328 +#endif
24329 +
24330 /* Save guest registers, load host registers, keep flags */
24331 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24332 "pop %0 \n\t"
24333 @@ -6407,6 +6427,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24334 #endif
24335 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24336 [wordsize]"i"(sizeof(ulong))
24337 +
24338 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24339 + ,[cs]"i"(__KERNEL_CS)
24340 +#endif
24341 +
24342 : "cc", "memory"
24343 #ifdef CONFIG_X86_64
24344 , "rax", "rbx", "rdi", "rsi"
24345 @@ -6420,7 +6445,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24346 if (debugctlmsr)
24347 update_debugctlmsr(debugctlmsr);
24348
24349 -#ifndef CONFIG_X86_64
24350 +#ifdef CONFIG_X86_32
24351 /*
24352 * The sysexit path does not restore ds/es, so we must set them to
24353 * a reasonable value ourselves.
24354 @@ -6429,8 +6454,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24355 * may be executed in interrupt context, which saves and restore segments
24356 * around it, nullifying its effect.
24357 */
24358 - loadsegment(ds, __USER_DS);
24359 - loadsegment(es, __USER_DS);
24360 + loadsegment(ds, __KERNEL_DS);
24361 + loadsegment(es, __KERNEL_DS);
24362 + loadsegment(ss, __KERNEL_DS);
24363 +
24364 +#ifdef CONFIG_PAX_KERNEXEC
24365 + loadsegment(fs, __KERNEL_PERCPU);
24366 +#endif
24367 +
24368 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24369 + __set_fs(current_thread_info()->addr_limit);
24370 +#endif
24371 +
24372 #endif
24373
24374 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24375 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24376 index c243b81..b692af3 100644
24377 --- a/arch/x86/kvm/x86.c
24378 +++ b/arch/x86/kvm/x86.c
24379 @@ -1408,10 +1408,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24380 unsigned long flags, this_tsc_khz;
24381 struct kvm_vcpu_arch *vcpu = &v->arch;
24382 struct kvm_arch *ka = &v->kvm->arch;
24383 - void *shared_kaddr;
24384 s64 kernel_ns, max_kernel_ns;
24385 u64 tsc_timestamp, host_tsc;
24386 - struct pvclock_vcpu_time_info *guest_hv_clock;
24387 + struct pvclock_vcpu_time_info guest_hv_clock;
24388 u8 pvclock_flags;
24389 bool use_master_clock;
24390
24391 @@ -1465,7 +1464,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24392
24393 local_irq_restore(flags);
24394
24395 - if (!vcpu->time_page)
24396 + if (!vcpu->pv_time_enabled)
24397 return 0;
24398
24399 /*
24400 @@ -1527,12 +1526,12 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24401 */
24402 vcpu->hv_clock.version += 2;
24403
24404 - shared_kaddr = kmap_atomic(vcpu->time_page);
24405 -
24406 - guest_hv_clock = shared_kaddr + vcpu->time_offset;
24407 + if (unlikely(kvm_read_guest_cached(v->kvm, &vcpu->pv_time,
24408 + &guest_hv_clock, sizeof(guest_hv_clock))))
24409 + return 0;
24410
24411 /* retain PVCLOCK_GUEST_STOPPED if set in guest copy */
24412 - pvclock_flags = (guest_hv_clock->flags & PVCLOCK_GUEST_STOPPED);
24413 + pvclock_flags = (guest_hv_clock.flags & PVCLOCK_GUEST_STOPPED);
24414
24415 if (vcpu->pvclock_set_guest_stopped_request) {
24416 pvclock_flags |= PVCLOCK_GUEST_STOPPED;
24417 @@ -1545,12 +1544,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24418
24419 vcpu->hv_clock.flags = pvclock_flags;
24420
24421 - memcpy(shared_kaddr + vcpu->time_offset, &vcpu->hv_clock,
24422 - sizeof(vcpu->hv_clock));
24423 -
24424 - kunmap_atomic(shared_kaddr);
24425 -
24426 - mark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT);
24427 + kvm_write_guest_cached(v->kvm, &vcpu->pv_time,
24428 + &vcpu->hv_clock,
24429 + sizeof(vcpu->hv_clock));
24430 return 0;
24431 }
24432
24433 @@ -1692,8 +1688,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24434 {
24435 struct kvm *kvm = vcpu->kvm;
24436 int lm = is_long_mode(vcpu);
24437 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24438 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24439 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24440 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24441 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24442 : kvm->arch.xen_hvm_config.blob_size_32;
24443 u32 page_num = data & ~PAGE_MASK;
24444 @@ -1839,10 +1835,7 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)
24445
24446 static void kvmclock_reset(struct kvm_vcpu *vcpu)
24447 {
24448 - if (vcpu->arch.time_page) {
24449 - kvm_release_page_dirty(vcpu->arch.time_page);
24450 - vcpu->arch.time_page = NULL;
24451 - }
24452 + vcpu->arch.pv_time_enabled = false;
24453 }
24454
24455 static void accumulate_steal_time(struct kvm_vcpu *vcpu)
24456 @@ -1948,6 +1941,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24457 break;
24458 case MSR_KVM_SYSTEM_TIME_NEW:
24459 case MSR_KVM_SYSTEM_TIME: {
24460 + u64 gpa_offset;
24461 kvmclock_reset(vcpu);
24462
24463 vcpu->arch.time = data;
24464 @@ -1957,14 +1951,17 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24465 if (!(data & 1))
24466 break;
24467
24468 - /* ...but clean it before doing the actual write */
24469 - vcpu->arch.time_offset = data & ~(PAGE_MASK | 1);
24470 + gpa_offset = data & ~(PAGE_MASK | 1);
24471
24472 - vcpu->arch.time_page =
24473 - gfn_to_page(vcpu->kvm, data >> PAGE_SHIFT);
24474 + /* Check that the address is 32-byte aligned. */
24475 + if (gpa_offset & (sizeof(struct pvclock_vcpu_time_info) - 1))
24476 + break;
24477
24478 - if (is_error_page(vcpu->arch.time_page))
24479 - vcpu->arch.time_page = NULL;
24480 + if (kvm_gfn_to_hva_cache_init(vcpu->kvm,
24481 + &vcpu->arch.pv_time, data & ~1ULL))
24482 + vcpu->arch.pv_time_enabled = false;
24483 + else
24484 + vcpu->arch.pv_time_enabled = true;
24485
24486 break;
24487 }
24488 @@ -2571,6 +2568,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24489 if (n < msr_list.nmsrs)
24490 goto out;
24491 r = -EFAULT;
24492 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24493 + goto out;
24494 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24495 num_msrs_to_save * sizeof(u32)))
24496 goto out;
24497 @@ -2700,7 +2699,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24498 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24499 struct kvm_interrupt *irq)
24500 {
24501 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24502 + if (irq->irq >= KVM_NR_INTERRUPTS)
24503 return -EINVAL;
24504 if (irqchip_in_kernel(vcpu->kvm))
24505 return -ENXIO;
24506 @@ -2967,7 +2966,7 @@ static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu,
24507 */
24508 static int kvm_set_guest_paused(struct kvm_vcpu *vcpu)
24509 {
24510 - if (!vcpu->arch.time_page)
24511 + if (!vcpu->arch.pv_time_enabled)
24512 return -EINVAL;
24513 vcpu->arch.pvclock_set_guest_stopped_request = true;
24514 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
24515 @@ -5213,7 +5212,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24516 };
24517 #endif
24518
24519 -int kvm_arch_init(void *opaque)
24520 +int kvm_arch_init(const void *opaque)
24521 {
24522 int r;
24523 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24524 @@ -6661,6 +6660,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
24525 goto fail_free_wbinvd_dirty_mask;
24526
24527 vcpu->arch.ia32_tsc_adjust_msr = 0x0;
24528 + vcpu->arch.pv_time_enabled = false;
24529 kvm_async_pf_hash_reset(vcpu);
24530 kvm_pmu_init(vcpu);
24531
24532 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24533 index df4176c..23ce092 100644
24534 --- a/arch/x86/lguest/boot.c
24535 +++ b/arch/x86/lguest/boot.c
24536 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24537 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24538 * Launcher to reboot us.
24539 */
24540 -static void lguest_restart(char *reason)
24541 +static __noreturn void lguest_restart(char *reason)
24542 {
24543 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24544 + BUG();
24545 }
24546
24547 /*G:050
24548 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24549 index 00933d5..3a64af9 100644
24550 --- a/arch/x86/lib/atomic64_386_32.S
24551 +++ b/arch/x86/lib/atomic64_386_32.S
24552 @@ -48,6 +48,10 @@ BEGIN(read)
24553 movl (v), %eax
24554 movl 4(v), %edx
24555 RET_ENDP
24556 +BEGIN(read_unchecked)
24557 + movl (v), %eax
24558 + movl 4(v), %edx
24559 +RET_ENDP
24560 #undef v
24561
24562 #define v %esi
24563 @@ -55,6 +59,10 @@ BEGIN(set)
24564 movl %ebx, (v)
24565 movl %ecx, 4(v)
24566 RET_ENDP
24567 +BEGIN(set_unchecked)
24568 + movl %ebx, (v)
24569 + movl %ecx, 4(v)
24570 +RET_ENDP
24571 #undef v
24572
24573 #define v %esi
24574 @@ -70,6 +78,20 @@ RET_ENDP
24575 BEGIN(add)
24576 addl %eax, (v)
24577 adcl %edx, 4(v)
24578 +
24579 +#ifdef CONFIG_PAX_REFCOUNT
24580 + jno 0f
24581 + subl %eax, (v)
24582 + sbbl %edx, 4(v)
24583 + int $4
24584 +0:
24585 + _ASM_EXTABLE(0b, 0b)
24586 +#endif
24587 +
24588 +RET_ENDP
24589 +BEGIN(add_unchecked)
24590 + addl %eax, (v)
24591 + adcl %edx, 4(v)
24592 RET_ENDP
24593 #undef v
24594
24595 @@ -77,6 +99,24 @@ RET_ENDP
24596 BEGIN(add_return)
24597 addl (v), %eax
24598 adcl 4(v), %edx
24599 +
24600 +#ifdef CONFIG_PAX_REFCOUNT
24601 + into
24602 +1234:
24603 + _ASM_EXTABLE(1234b, 2f)
24604 +#endif
24605 +
24606 + movl %eax, (v)
24607 + movl %edx, 4(v)
24608 +
24609 +#ifdef CONFIG_PAX_REFCOUNT
24610 +2:
24611 +#endif
24612 +
24613 +RET_ENDP
24614 +BEGIN(add_return_unchecked)
24615 + addl (v), %eax
24616 + adcl 4(v), %edx
24617 movl %eax, (v)
24618 movl %edx, 4(v)
24619 RET_ENDP
24620 @@ -86,6 +126,20 @@ RET_ENDP
24621 BEGIN(sub)
24622 subl %eax, (v)
24623 sbbl %edx, 4(v)
24624 +
24625 +#ifdef CONFIG_PAX_REFCOUNT
24626 + jno 0f
24627 + addl %eax, (v)
24628 + adcl %edx, 4(v)
24629 + int $4
24630 +0:
24631 + _ASM_EXTABLE(0b, 0b)
24632 +#endif
24633 +
24634 +RET_ENDP
24635 +BEGIN(sub_unchecked)
24636 + subl %eax, (v)
24637 + sbbl %edx, 4(v)
24638 RET_ENDP
24639 #undef v
24640
24641 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24642 sbbl $0, %edx
24643 addl (v), %eax
24644 adcl 4(v), %edx
24645 +
24646 +#ifdef CONFIG_PAX_REFCOUNT
24647 + into
24648 +1234:
24649 + _ASM_EXTABLE(1234b, 2f)
24650 +#endif
24651 +
24652 + movl %eax, (v)
24653 + movl %edx, 4(v)
24654 +
24655 +#ifdef CONFIG_PAX_REFCOUNT
24656 +2:
24657 +#endif
24658 +
24659 +RET_ENDP
24660 +BEGIN(sub_return_unchecked)
24661 + negl %edx
24662 + negl %eax
24663 + sbbl $0, %edx
24664 + addl (v), %eax
24665 + adcl 4(v), %edx
24666 movl %eax, (v)
24667 movl %edx, 4(v)
24668 RET_ENDP
24669 @@ -105,6 +180,20 @@ RET_ENDP
24670 BEGIN(inc)
24671 addl $1, (v)
24672 adcl $0, 4(v)
24673 +
24674 +#ifdef CONFIG_PAX_REFCOUNT
24675 + jno 0f
24676 + subl $1, (v)
24677 + sbbl $0, 4(v)
24678 + int $4
24679 +0:
24680 + _ASM_EXTABLE(0b, 0b)
24681 +#endif
24682 +
24683 +RET_ENDP
24684 +BEGIN(inc_unchecked)
24685 + addl $1, (v)
24686 + adcl $0, 4(v)
24687 RET_ENDP
24688 #undef v
24689
24690 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24691 movl 4(v), %edx
24692 addl $1, %eax
24693 adcl $0, %edx
24694 +
24695 +#ifdef CONFIG_PAX_REFCOUNT
24696 + into
24697 +1234:
24698 + _ASM_EXTABLE(1234b, 2f)
24699 +#endif
24700 +
24701 + movl %eax, (v)
24702 + movl %edx, 4(v)
24703 +
24704 +#ifdef CONFIG_PAX_REFCOUNT
24705 +2:
24706 +#endif
24707 +
24708 +RET_ENDP
24709 +BEGIN(inc_return_unchecked)
24710 + movl (v), %eax
24711 + movl 4(v), %edx
24712 + addl $1, %eax
24713 + adcl $0, %edx
24714 movl %eax, (v)
24715 movl %edx, 4(v)
24716 RET_ENDP
24717 @@ -123,6 +232,20 @@ RET_ENDP
24718 BEGIN(dec)
24719 subl $1, (v)
24720 sbbl $0, 4(v)
24721 +
24722 +#ifdef CONFIG_PAX_REFCOUNT
24723 + jno 0f
24724 + addl $1, (v)
24725 + adcl $0, 4(v)
24726 + int $4
24727 +0:
24728 + _ASM_EXTABLE(0b, 0b)
24729 +#endif
24730 +
24731 +RET_ENDP
24732 +BEGIN(dec_unchecked)
24733 + subl $1, (v)
24734 + sbbl $0, 4(v)
24735 RET_ENDP
24736 #undef v
24737
24738 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24739 movl 4(v), %edx
24740 subl $1, %eax
24741 sbbl $0, %edx
24742 +
24743 +#ifdef CONFIG_PAX_REFCOUNT
24744 + into
24745 +1234:
24746 + _ASM_EXTABLE(1234b, 2f)
24747 +#endif
24748 +
24749 + movl %eax, (v)
24750 + movl %edx, 4(v)
24751 +
24752 +#ifdef CONFIG_PAX_REFCOUNT
24753 +2:
24754 +#endif
24755 +
24756 +RET_ENDP
24757 +BEGIN(dec_return_unchecked)
24758 + movl (v), %eax
24759 + movl 4(v), %edx
24760 + subl $1, %eax
24761 + sbbl $0, %edx
24762 movl %eax, (v)
24763 movl %edx, 4(v)
24764 RET_ENDP
24765 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24766 adcl %edx, %edi
24767 addl (v), %eax
24768 adcl 4(v), %edx
24769 +
24770 +#ifdef CONFIG_PAX_REFCOUNT
24771 + into
24772 +1234:
24773 + _ASM_EXTABLE(1234b, 2f)
24774 +#endif
24775 +
24776 cmpl %eax, %ecx
24777 je 3f
24778 1:
24779 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24780 1:
24781 addl $1, %eax
24782 adcl $0, %edx
24783 +
24784 +#ifdef CONFIG_PAX_REFCOUNT
24785 + into
24786 +1234:
24787 + _ASM_EXTABLE(1234b, 2f)
24788 +#endif
24789 +
24790 movl %eax, (v)
24791 movl %edx, 4(v)
24792 movl $1, %eax
24793 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24794 movl 4(v), %edx
24795 subl $1, %eax
24796 sbbl $0, %edx
24797 +
24798 +#ifdef CONFIG_PAX_REFCOUNT
24799 + into
24800 +1234:
24801 + _ASM_EXTABLE(1234b, 1f)
24802 +#endif
24803 +
24804 js 1f
24805 movl %eax, (v)
24806 movl %edx, 4(v)
24807 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24808 index f5cc9eb..51fa319 100644
24809 --- a/arch/x86/lib/atomic64_cx8_32.S
24810 +++ b/arch/x86/lib/atomic64_cx8_32.S
24811 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24812 CFI_STARTPROC
24813
24814 read64 %ecx
24815 + pax_force_retaddr
24816 ret
24817 CFI_ENDPROC
24818 ENDPROC(atomic64_read_cx8)
24819
24820 +ENTRY(atomic64_read_unchecked_cx8)
24821 + CFI_STARTPROC
24822 +
24823 + read64 %ecx
24824 + pax_force_retaddr
24825 + ret
24826 + CFI_ENDPROC
24827 +ENDPROC(atomic64_read_unchecked_cx8)
24828 +
24829 ENTRY(atomic64_set_cx8)
24830 CFI_STARTPROC
24831
24832 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24833 cmpxchg8b (%esi)
24834 jne 1b
24835
24836 + pax_force_retaddr
24837 ret
24838 CFI_ENDPROC
24839 ENDPROC(atomic64_set_cx8)
24840
24841 +ENTRY(atomic64_set_unchecked_cx8)
24842 + CFI_STARTPROC
24843 +
24844 +1:
24845 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24846 + * are atomic on 586 and newer */
24847 + cmpxchg8b (%esi)
24848 + jne 1b
24849 +
24850 + pax_force_retaddr
24851 + ret
24852 + CFI_ENDPROC
24853 +ENDPROC(atomic64_set_unchecked_cx8)
24854 +
24855 ENTRY(atomic64_xchg_cx8)
24856 CFI_STARTPROC
24857
24858 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24859 cmpxchg8b (%esi)
24860 jne 1b
24861
24862 + pax_force_retaddr
24863 ret
24864 CFI_ENDPROC
24865 ENDPROC(atomic64_xchg_cx8)
24866
24867 -.macro addsub_return func ins insc
24868 -ENTRY(atomic64_\func\()_return_cx8)
24869 +.macro addsub_return func ins insc unchecked=""
24870 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24871 CFI_STARTPROC
24872 SAVE ebp
24873 SAVE ebx
24874 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24875 movl %edx, %ecx
24876 \ins\()l %esi, %ebx
24877 \insc\()l %edi, %ecx
24878 +
24879 +.ifb \unchecked
24880 +#ifdef CONFIG_PAX_REFCOUNT
24881 + into
24882 +2:
24883 + _ASM_EXTABLE(2b, 3f)
24884 +#endif
24885 +.endif
24886 +
24887 LOCK_PREFIX
24888 cmpxchg8b (%ebp)
24889 jne 1b
24890 -
24891 -10:
24892 movl %ebx, %eax
24893 movl %ecx, %edx
24894 +
24895 +.ifb \unchecked
24896 +#ifdef CONFIG_PAX_REFCOUNT
24897 +3:
24898 +#endif
24899 +.endif
24900 +
24901 RESTORE edi
24902 RESTORE esi
24903 RESTORE ebx
24904 RESTORE ebp
24905 + pax_force_retaddr
24906 ret
24907 CFI_ENDPROC
24908 -ENDPROC(atomic64_\func\()_return_cx8)
24909 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24910 .endm
24911
24912 addsub_return add add adc
24913 addsub_return sub sub sbb
24914 +addsub_return add add adc _unchecked
24915 +addsub_return sub sub sbb _unchecked
24916
24917 -.macro incdec_return func ins insc
24918 -ENTRY(atomic64_\func\()_return_cx8)
24919 +.macro incdec_return func ins insc unchecked=""
24920 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24921 CFI_STARTPROC
24922 SAVE ebx
24923
24924 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24925 movl %edx, %ecx
24926 \ins\()l $1, %ebx
24927 \insc\()l $0, %ecx
24928 +
24929 +.ifb \unchecked
24930 +#ifdef CONFIG_PAX_REFCOUNT
24931 + into
24932 +2:
24933 + _ASM_EXTABLE(2b, 3f)
24934 +#endif
24935 +.endif
24936 +
24937 LOCK_PREFIX
24938 cmpxchg8b (%esi)
24939 jne 1b
24940
24941 -10:
24942 movl %ebx, %eax
24943 movl %ecx, %edx
24944 +
24945 +.ifb \unchecked
24946 +#ifdef CONFIG_PAX_REFCOUNT
24947 +3:
24948 +#endif
24949 +.endif
24950 +
24951 RESTORE ebx
24952 + pax_force_retaddr
24953 ret
24954 CFI_ENDPROC
24955 -ENDPROC(atomic64_\func\()_return_cx8)
24956 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24957 .endm
24958
24959 incdec_return inc add adc
24960 incdec_return dec sub sbb
24961 +incdec_return inc add adc _unchecked
24962 +incdec_return dec sub sbb _unchecked
24963
24964 ENTRY(atomic64_dec_if_positive_cx8)
24965 CFI_STARTPROC
24966 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24967 movl %edx, %ecx
24968 subl $1, %ebx
24969 sbb $0, %ecx
24970 +
24971 +#ifdef CONFIG_PAX_REFCOUNT
24972 + into
24973 +1234:
24974 + _ASM_EXTABLE(1234b, 2f)
24975 +#endif
24976 +
24977 js 2f
24978 LOCK_PREFIX
24979 cmpxchg8b (%esi)
24980 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24981 movl %ebx, %eax
24982 movl %ecx, %edx
24983 RESTORE ebx
24984 + pax_force_retaddr
24985 ret
24986 CFI_ENDPROC
24987 ENDPROC(atomic64_dec_if_positive_cx8)
24988 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24989 movl %edx, %ecx
24990 addl %ebp, %ebx
24991 adcl %edi, %ecx
24992 +
24993 +#ifdef CONFIG_PAX_REFCOUNT
24994 + into
24995 +1234:
24996 + _ASM_EXTABLE(1234b, 3f)
24997 +#endif
24998 +
24999 LOCK_PREFIX
25000 cmpxchg8b (%esi)
25001 jne 1b
25002 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
25003 CFI_ADJUST_CFA_OFFSET -8
25004 RESTORE ebx
25005 RESTORE ebp
25006 + pax_force_retaddr
25007 ret
25008 4:
25009 cmpl %edx, 4(%esp)
25010 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
25011 xorl %ecx, %ecx
25012 addl $1, %ebx
25013 adcl %edx, %ecx
25014 +
25015 +#ifdef CONFIG_PAX_REFCOUNT
25016 + into
25017 +1234:
25018 + _ASM_EXTABLE(1234b, 3f)
25019 +#endif
25020 +
25021 LOCK_PREFIX
25022 cmpxchg8b (%esi)
25023 jne 1b
25024 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
25025 movl $1, %eax
25026 3:
25027 RESTORE ebx
25028 + pax_force_retaddr
25029 ret
25030 CFI_ENDPROC
25031 ENDPROC(atomic64_inc_not_zero_cx8)
25032 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
25033 index 2af5df3..62b1a5a 100644
25034 --- a/arch/x86/lib/checksum_32.S
25035 +++ b/arch/x86/lib/checksum_32.S
25036 @@ -29,7 +29,8 @@
25037 #include <asm/dwarf2.h>
25038 #include <asm/errno.h>
25039 #include <asm/asm.h>
25040 -
25041 +#include <asm/segment.h>
25042 +
25043 /*
25044 * computes a partial checksum, e.g. for TCP/UDP fragments
25045 */
25046 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
25047
25048 #define ARGBASE 16
25049 #define FP 12
25050 -
25051 -ENTRY(csum_partial_copy_generic)
25052 +
25053 +ENTRY(csum_partial_copy_generic_to_user)
25054 CFI_STARTPROC
25055 +
25056 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25057 + pushl_cfi %gs
25058 + popl_cfi %es
25059 + jmp csum_partial_copy_generic
25060 +#endif
25061 +
25062 +ENTRY(csum_partial_copy_generic_from_user)
25063 +
25064 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25065 + pushl_cfi %gs
25066 + popl_cfi %ds
25067 +#endif
25068 +
25069 +ENTRY(csum_partial_copy_generic)
25070 subl $4,%esp
25071 CFI_ADJUST_CFA_OFFSET 4
25072 pushl_cfi %edi
25073 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
25074 jmp 4f
25075 SRC(1: movw (%esi), %bx )
25076 addl $2, %esi
25077 -DST( movw %bx, (%edi) )
25078 +DST( movw %bx, %es:(%edi) )
25079 addl $2, %edi
25080 addw %bx, %ax
25081 adcl $0, %eax
25082 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
25083 SRC(1: movl (%esi), %ebx )
25084 SRC( movl 4(%esi), %edx )
25085 adcl %ebx, %eax
25086 -DST( movl %ebx, (%edi) )
25087 +DST( movl %ebx, %es:(%edi) )
25088 adcl %edx, %eax
25089 -DST( movl %edx, 4(%edi) )
25090 +DST( movl %edx, %es:4(%edi) )
25091
25092 SRC( movl 8(%esi), %ebx )
25093 SRC( movl 12(%esi), %edx )
25094 adcl %ebx, %eax
25095 -DST( movl %ebx, 8(%edi) )
25096 +DST( movl %ebx, %es:8(%edi) )
25097 adcl %edx, %eax
25098 -DST( movl %edx, 12(%edi) )
25099 +DST( movl %edx, %es:12(%edi) )
25100
25101 SRC( movl 16(%esi), %ebx )
25102 SRC( movl 20(%esi), %edx )
25103 adcl %ebx, %eax
25104 -DST( movl %ebx, 16(%edi) )
25105 +DST( movl %ebx, %es:16(%edi) )
25106 adcl %edx, %eax
25107 -DST( movl %edx, 20(%edi) )
25108 +DST( movl %edx, %es:20(%edi) )
25109
25110 SRC( movl 24(%esi), %ebx )
25111 SRC( movl 28(%esi), %edx )
25112 adcl %ebx, %eax
25113 -DST( movl %ebx, 24(%edi) )
25114 +DST( movl %ebx, %es:24(%edi) )
25115 adcl %edx, %eax
25116 -DST( movl %edx, 28(%edi) )
25117 +DST( movl %edx, %es:28(%edi) )
25118
25119 lea 32(%esi), %esi
25120 lea 32(%edi), %edi
25121 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
25122 shrl $2, %edx # This clears CF
25123 SRC(3: movl (%esi), %ebx )
25124 adcl %ebx, %eax
25125 -DST( movl %ebx, (%edi) )
25126 +DST( movl %ebx, %es:(%edi) )
25127 lea 4(%esi), %esi
25128 lea 4(%edi), %edi
25129 dec %edx
25130 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
25131 jb 5f
25132 SRC( movw (%esi), %cx )
25133 leal 2(%esi), %esi
25134 -DST( movw %cx, (%edi) )
25135 +DST( movw %cx, %es:(%edi) )
25136 leal 2(%edi), %edi
25137 je 6f
25138 shll $16,%ecx
25139 SRC(5: movb (%esi), %cl )
25140 -DST( movb %cl, (%edi) )
25141 +DST( movb %cl, %es:(%edi) )
25142 6: addl %ecx, %eax
25143 adcl $0, %eax
25144 7:
25145 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
25146
25147 6001:
25148 movl ARGBASE+20(%esp), %ebx # src_err_ptr
25149 - movl $-EFAULT, (%ebx)
25150 + movl $-EFAULT, %ss:(%ebx)
25151
25152 # zero the complete destination - computing the rest
25153 # is too much work
25154 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
25155
25156 6002:
25157 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25158 - movl $-EFAULT,(%ebx)
25159 + movl $-EFAULT,%ss:(%ebx)
25160 jmp 5000b
25161
25162 .previous
25163
25164 + pushl_cfi %ss
25165 + popl_cfi %ds
25166 + pushl_cfi %ss
25167 + popl_cfi %es
25168 popl_cfi %ebx
25169 CFI_RESTORE ebx
25170 popl_cfi %esi
25171 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
25172 popl_cfi %ecx # equivalent to addl $4,%esp
25173 ret
25174 CFI_ENDPROC
25175 -ENDPROC(csum_partial_copy_generic)
25176 +ENDPROC(csum_partial_copy_generic_to_user)
25177
25178 #else
25179
25180 /* Version for PentiumII/PPro */
25181
25182 #define ROUND1(x) \
25183 + nop; nop; nop; \
25184 SRC(movl x(%esi), %ebx ) ; \
25185 addl %ebx, %eax ; \
25186 - DST(movl %ebx, x(%edi) ) ;
25187 + DST(movl %ebx, %es:x(%edi)) ;
25188
25189 #define ROUND(x) \
25190 + nop; nop; nop; \
25191 SRC(movl x(%esi), %ebx ) ; \
25192 adcl %ebx, %eax ; \
25193 - DST(movl %ebx, x(%edi) ) ;
25194 + DST(movl %ebx, %es:x(%edi)) ;
25195
25196 #define ARGBASE 12
25197 -
25198 -ENTRY(csum_partial_copy_generic)
25199 +
25200 +ENTRY(csum_partial_copy_generic_to_user)
25201 CFI_STARTPROC
25202 +
25203 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25204 + pushl_cfi %gs
25205 + popl_cfi %es
25206 + jmp csum_partial_copy_generic
25207 +#endif
25208 +
25209 +ENTRY(csum_partial_copy_generic_from_user)
25210 +
25211 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25212 + pushl_cfi %gs
25213 + popl_cfi %ds
25214 +#endif
25215 +
25216 +ENTRY(csum_partial_copy_generic)
25217 pushl_cfi %ebx
25218 CFI_REL_OFFSET ebx, 0
25219 pushl_cfi %edi
25220 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
25221 subl %ebx, %edi
25222 lea -1(%esi),%edx
25223 andl $-32,%edx
25224 - lea 3f(%ebx,%ebx), %ebx
25225 + lea 3f(%ebx,%ebx,2), %ebx
25226 testl %esi, %esi
25227 jmp *%ebx
25228 1: addl $64,%esi
25229 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
25230 jb 5f
25231 SRC( movw (%esi), %dx )
25232 leal 2(%esi), %esi
25233 -DST( movw %dx, (%edi) )
25234 +DST( movw %dx, %es:(%edi) )
25235 leal 2(%edi), %edi
25236 je 6f
25237 shll $16,%edx
25238 5:
25239 SRC( movb (%esi), %dl )
25240 -DST( movb %dl, (%edi) )
25241 +DST( movb %dl, %es:(%edi) )
25242 6: addl %edx, %eax
25243 adcl $0, %eax
25244 7:
25245 .section .fixup, "ax"
25246 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
25247 - movl $-EFAULT, (%ebx)
25248 + movl $-EFAULT, %ss:(%ebx)
25249 # zero the complete destination (computing the rest is too much work)
25250 movl ARGBASE+8(%esp),%edi # dst
25251 movl ARGBASE+12(%esp),%ecx # len
25252 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
25253 rep; stosb
25254 jmp 7b
25255 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25256 - movl $-EFAULT, (%ebx)
25257 + movl $-EFAULT, %ss:(%ebx)
25258 jmp 7b
25259 .previous
25260
25261 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25262 + pushl_cfi %ss
25263 + popl_cfi %ds
25264 + pushl_cfi %ss
25265 + popl_cfi %es
25266 +#endif
25267 +
25268 popl_cfi %esi
25269 CFI_RESTORE esi
25270 popl_cfi %edi
25271 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25272 CFI_RESTORE ebx
25273 ret
25274 CFI_ENDPROC
25275 -ENDPROC(csum_partial_copy_generic)
25276 +ENDPROC(csum_partial_copy_generic_to_user)
25277
25278 #undef ROUND
25279 #undef ROUND1
25280 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25281 index f2145cf..cea889d 100644
25282 --- a/arch/x86/lib/clear_page_64.S
25283 +++ b/arch/x86/lib/clear_page_64.S
25284 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25285 movl $4096/8,%ecx
25286 xorl %eax,%eax
25287 rep stosq
25288 + pax_force_retaddr
25289 ret
25290 CFI_ENDPROC
25291 ENDPROC(clear_page_c)
25292 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25293 movl $4096,%ecx
25294 xorl %eax,%eax
25295 rep stosb
25296 + pax_force_retaddr
25297 ret
25298 CFI_ENDPROC
25299 ENDPROC(clear_page_c_e)
25300 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25301 leaq 64(%rdi),%rdi
25302 jnz .Lloop
25303 nop
25304 + pax_force_retaddr
25305 ret
25306 CFI_ENDPROC
25307 .Lclear_page_end:
25308 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25309
25310 #include <asm/cpufeature.h>
25311
25312 - .section .altinstr_replacement,"ax"
25313 + .section .altinstr_replacement,"a"
25314 1: .byte 0xeb /* jmp <disp8> */
25315 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25316 2: .byte 0xeb /* jmp <disp8> */
25317 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25318 index 1e572c5..2a162cd 100644
25319 --- a/arch/x86/lib/cmpxchg16b_emu.S
25320 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25321 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25322
25323 popf
25324 mov $1, %al
25325 + pax_force_retaddr
25326 ret
25327
25328 not_same:
25329 popf
25330 xor %al,%al
25331 + pax_force_retaddr
25332 ret
25333
25334 CFI_ENDPROC
25335 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25336 index 176cca6..1166c50 100644
25337 --- a/arch/x86/lib/copy_page_64.S
25338 +++ b/arch/x86/lib/copy_page_64.S
25339 @@ -9,6 +9,7 @@ copy_page_rep:
25340 CFI_STARTPROC
25341 movl $4096/8, %ecx
25342 rep movsq
25343 + pax_force_retaddr
25344 ret
25345 CFI_ENDPROC
25346 ENDPROC(copy_page_rep)
25347 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25348
25349 ENTRY(copy_page)
25350 CFI_STARTPROC
25351 - subq $2*8, %rsp
25352 - CFI_ADJUST_CFA_OFFSET 2*8
25353 + subq $3*8, %rsp
25354 + CFI_ADJUST_CFA_OFFSET 3*8
25355 movq %rbx, (%rsp)
25356 CFI_REL_OFFSET rbx, 0
25357 movq %r12, 1*8(%rsp)
25358 CFI_REL_OFFSET r12, 1*8
25359 + movq %r13, 2*8(%rsp)
25360 + CFI_REL_OFFSET r13, 2*8
25361
25362 movl $(4096/64)-5, %ecx
25363 .p2align 4
25364 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25365 movq 0x8*2(%rsi), %rdx
25366 movq 0x8*3(%rsi), %r8
25367 movq 0x8*4(%rsi), %r9
25368 - movq 0x8*5(%rsi), %r10
25369 + movq 0x8*5(%rsi), %r13
25370 movq 0x8*6(%rsi), %r11
25371 movq 0x8*7(%rsi), %r12
25372
25373 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25374 movq %rdx, 0x8*2(%rdi)
25375 movq %r8, 0x8*3(%rdi)
25376 movq %r9, 0x8*4(%rdi)
25377 - movq %r10, 0x8*5(%rdi)
25378 + movq %r13, 0x8*5(%rdi)
25379 movq %r11, 0x8*6(%rdi)
25380 movq %r12, 0x8*7(%rdi)
25381
25382 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25383 movq 0x8*2(%rsi), %rdx
25384 movq 0x8*3(%rsi), %r8
25385 movq 0x8*4(%rsi), %r9
25386 - movq 0x8*5(%rsi), %r10
25387 + movq 0x8*5(%rsi), %r13
25388 movq 0x8*6(%rsi), %r11
25389 movq 0x8*7(%rsi), %r12
25390
25391 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25392 movq %rdx, 0x8*2(%rdi)
25393 movq %r8, 0x8*3(%rdi)
25394 movq %r9, 0x8*4(%rdi)
25395 - movq %r10, 0x8*5(%rdi)
25396 + movq %r13, 0x8*5(%rdi)
25397 movq %r11, 0x8*6(%rdi)
25398 movq %r12, 0x8*7(%rdi)
25399
25400 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25401 CFI_RESTORE rbx
25402 movq 1*8(%rsp), %r12
25403 CFI_RESTORE r12
25404 - addq $2*8, %rsp
25405 - CFI_ADJUST_CFA_OFFSET -2*8
25406 + movq 2*8(%rsp), %r13
25407 + CFI_RESTORE r13
25408 + addq $3*8, %rsp
25409 + CFI_ADJUST_CFA_OFFSET -3*8
25410 + pax_force_retaddr
25411 ret
25412 .Lcopy_page_end:
25413 CFI_ENDPROC
25414 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25415
25416 #include <asm/cpufeature.h>
25417
25418 - .section .altinstr_replacement,"ax"
25419 + .section .altinstr_replacement,"a"
25420 1: .byte 0xeb /* jmp <disp8> */
25421 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25422 2:
25423 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25424 index a30ca15..d25fab6 100644
25425 --- a/arch/x86/lib/copy_user_64.S
25426 +++ b/arch/x86/lib/copy_user_64.S
25427 @@ -18,6 +18,7 @@
25428 #include <asm/alternative-asm.h>
25429 #include <asm/asm.h>
25430 #include <asm/smap.h>
25431 +#include <asm/pgtable.h>
25432
25433 /*
25434 * By placing feature2 after feature1 in altinstructions section, we logically
25435 @@ -31,7 +32,7 @@
25436 .byte 0xe9 /* 32bit jump */
25437 .long \orig-1f /* by default jump to orig */
25438 1:
25439 - .section .altinstr_replacement,"ax"
25440 + .section .altinstr_replacement,"a"
25441 2: .byte 0xe9 /* near jump with 32bit immediate */
25442 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25443 3: .byte 0xe9 /* near jump with 32bit immediate */
25444 @@ -70,47 +71,20 @@
25445 #endif
25446 .endm
25447
25448 -/* Standard copy_to_user with segment limit checking */
25449 -ENTRY(_copy_to_user)
25450 - CFI_STARTPROC
25451 - GET_THREAD_INFO(%rax)
25452 - movq %rdi,%rcx
25453 - addq %rdx,%rcx
25454 - jc bad_to_user
25455 - cmpq TI_addr_limit(%rax),%rcx
25456 - ja bad_to_user
25457 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25458 - copy_user_generic_unrolled,copy_user_generic_string, \
25459 - copy_user_enhanced_fast_string
25460 - CFI_ENDPROC
25461 -ENDPROC(_copy_to_user)
25462 -
25463 -/* Standard copy_from_user with segment limit checking */
25464 -ENTRY(_copy_from_user)
25465 - CFI_STARTPROC
25466 - GET_THREAD_INFO(%rax)
25467 - movq %rsi,%rcx
25468 - addq %rdx,%rcx
25469 - jc bad_from_user
25470 - cmpq TI_addr_limit(%rax),%rcx
25471 - ja bad_from_user
25472 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25473 - copy_user_generic_unrolled,copy_user_generic_string, \
25474 - copy_user_enhanced_fast_string
25475 - CFI_ENDPROC
25476 -ENDPROC(_copy_from_user)
25477 -
25478 .section .fixup,"ax"
25479 /* must zero dest */
25480 ENTRY(bad_from_user)
25481 bad_from_user:
25482 CFI_STARTPROC
25483 + testl %edx,%edx
25484 + js bad_to_user
25485 movl %edx,%ecx
25486 xorl %eax,%eax
25487 rep
25488 stosb
25489 bad_to_user:
25490 movl %edx,%eax
25491 + pax_force_retaddr
25492 ret
25493 CFI_ENDPROC
25494 ENDPROC(bad_from_user)
25495 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25496 jz 17f
25497 1: movq (%rsi),%r8
25498 2: movq 1*8(%rsi),%r9
25499 -3: movq 2*8(%rsi),%r10
25500 +3: movq 2*8(%rsi),%rax
25501 4: movq 3*8(%rsi),%r11
25502 5: movq %r8,(%rdi)
25503 6: movq %r9,1*8(%rdi)
25504 -7: movq %r10,2*8(%rdi)
25505 +7: movq %rax,2*8(%rdi)
25506 8: movq %r11,3*8(%rdi)
25507 9: movq 4*8(%rsi),%r8
25508 10: movq 5*8(%rsi),%r9
25509 -11: movq 6*8(%rsi),%r10
25510 +11: movq 6*8(%rsi),%rax
25511 12: movq 7*8(%rsi),%r11
25512 13: movq %r8,4*8(%rdi)
25513 14: movq %r9,5*8(%rdi)
25514 -15: movq %r10,6*8(%rdi)
25515 +15: movq %rax,6*8(%rdi)
25516 16: movq %r11,7*8(%rdi)
25517 leaq 64(%rsi),%rsi
25518 leaq 64(%rdi),%rdi
25519 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25520 jnz 21b
25521 23: xor %eax,%eax
25522 ASM_CLAC
25523 + pax_force_retaddr
25524 ret
25525
25526 .section .fixup,"ax"
25527 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25528 movsb
25529 4: xorl %eax,%eax
25530 ASM_CLAC
25531 + pax_force_retaddr
25532 ret
25533
25534 .section .fixup,"ax"
25535 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25536 movsb
25537 2: xorl %eax,%eax
25538 ASM_CLAC
25539 + pax_force_retaddr
25540 ret
25541
25542 .section .fixup,"ax"
25543 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25544 index 6a4f43c..f5f9e26 100644
25545 --- a/arch/x86/lib/copy_user_nocache_64.S
25546 +++ b/arch/x86/lib/copy_user_nocache_64.S
25547 @@ -8,6 +8,7 @@
25548
25549 #include <linux/linkage.h>
25550 #include <asm/dwarf2.h>
25551 +#include <asm/alternative-asm.h>
25552
25553 #define FIX_ALIGNMENT 1
25554
25555 @@ -16,6 +17,7 @@
25556 #include <asm/thread_info.h>
25557 #include <asm/asm.h>
25558 #include <asm/smap.h>
25559 +#include <asm/pgtable.h>
25560
25561 .macro ALIGN_DESTINATION
25562 #ifdef FIX_ALIGNMENT
25563 @@ -49,6 +51,15 @@
25564 */
25565 ENTRY(__copy_user_nocache)
25566 CFI_STARTPROC
25567 +
25568 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25569 + mov $PAX_USER_SHADOW_BASE,%rcx
25570 + cmp %rcx,%rsi
25571 + jae 1f
25572 + add %rcx,%rsi
25573 +1:
25574 +#endif
25575 +
25576 ASM_STAC
25577 cmpl $8,%edx
25578 jb 20f /* less then 8 bytes, go to byte copy loop */
25579 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25580 jz 17f
25581 1: movq (%rsi),%r8
25582 2: movq 1*8(%rsi),%r9
25583 -3: movq 2*8(%rsi),%r10
25584 +3: movq 2*8(%rsi),%rax
25585 4: movq 3*8(%rsi),%r11
25586 5: movnti %r8,(%rdi)
25587 6: movnti %r9,1*8(%rdi)
25588 -7: movnti %r10,2*8(%rdi)
25589 +7: movnti %rax,2*8(%rdi)
25590 8: movnti %r11,3*8(%rdi)
25591 9: movq 4*8(%rsi),%r8
25592 10: movq 5*8(%rsi),%r9
25593 -11: movq 6*8(%rsi),%r10
25594 +11: movq 6*8(%rsi),%rax
25595 12: movq 7*8(%rsi),%r11
25596 13: movnti %r8,4*8(%rdi)
25597 14: movnti %r9,5*8(%rdi)
25598 -15: movnti %r10,6*8(%rdi)
25599 +15: movnti %rax,6*8(%rdi)
25600 16: movnti %r11,7*8(%rdi)
25601 leaq 64(%rsi),%rsi
25602 leaq 64(%rdi),%rdi
25603 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25604 23: xorl %eax,%eax
25605 ASM_CLAC
25606 sfence
25607 + pax_force_retaddr
25608 ret
25609
25610 .section .fixup,"ax"
25611 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25612 index 2419d5f..953ee51 100644
25613 --- a/arch/x86/lib/csum-copy_64.S
25614 +++ b/arch/x86/lib/csum-copy_64.S
25615 @@ -9,6 +9,7 @@
25616 #include <asm/dwarf2.h>
25617 #include <asm/errno.h>
25618 #include <asm/asm.h>
25619 +#include <asm/alternative-asm.h>
25620
25621 /*
25622 * Checksum copy with exception handling.
25623 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25624 CFI_RESTORE rbp
25625 addq $7*8, %rsp
25626 CFI_ADJUST_CFA_OFFSET -7*8
25627 + pax_force_retaddr 0, 1
25628 ret
25629 CFI_RESTORE_STATE
25630
25631 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25632 index 25b7ae8..169fafc 100644
25633 --- a/arch/x86/lib/csum-wrappers_64.c
25634 +++ b/arch/x86/lib/csum-wrappers_64.c
25635 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25636 len -= 2;
25637 }
25638 }
25639 - isum = csum_partial_copy_generic((__force const void *)src,
25640 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25641 dst, len, isum, errp, NULL);
25642 if (unlikely(*errp))
25643 goto out_err;
25644 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25645 }
25646
25647 *errp = 0;
25648 - return csum_partial_copy_generic(src, (void __force *)dst,
25649 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25650 len, isum, NULL, errp);
25651 }
25652 EXPORT_SYMBOL(csum_partial_copy_to_user);
25653 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25654 index 156b9c8..b144132 100644
25655 --- a/arch/x86/lib/getuser.S
25656 +++ b/arch/x86/lib/getuser.S
25657 @@ -34,17 +34,40 @@
25658 #include <asm/thread_info.h>
25659 #include <asm/asm.h>
25660 #include <asm/smap.h>
25661 +#include <asm/segment.h>
25662 +#include <asm/pgtable.h>
25663 +#include <asm/alternative-asm.h>
25664 +
25665 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25666 +#define __copyuser_seg gs;
25667 +#else
25668 +#define __copyuser_seg
25669 +#endif
25670
25671 .text
25672 ENTRY(__get_user_1)
25673 CFI_STARTPROC
25674 +
25675 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25676 GET_THREAD_INFO(%_ASM_DX)
25677 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25678 jae bad_get_user
25679 ASM_STAC
25680 -1: movzb (%_ASM_AX),%edx
25681 +
25682 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25683 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25684 + cmp %_ASM_DX,%_ASM_AX
25685 + jae 1234f
25686 + add %_ASM_DX,%_ASM_AX
25687 +1234:
25688 +#endif
25689 +
25690 +#endif
25691 +
25692 +1: __copyuser_seg movzb (%_ASM_AX),%edx
25693 xor %eax,%eax
25694 ASM_CLAC
25695 + pax_force_retaddr
25696 ret
25697 CFI_ENDPROC
25698 ENDPROC(__get_user_1)
25699 @@ -52,14 +75,28 @@ ENDPROC(__get_user_1)
25700 ENTRY(__get_user_2)
25701 CFI_STARTPROC
25702 add $1,%_ASM_AX
25703 +
25704 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25705 jc bad_get_user
25706 GET_THREAD_INFO(%_ASM_DX)
25707 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25708 jae bad_get_user
25709 ASM_STAC
25710 -2: movzwl -1(%_ASM_AX),%edx
25711 +
25712 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25713 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25714 + cmp %_ASM_DX,%_ASM_AX
25715 + jae 1234f
25716 + add %_ASM_DX,%_ASM_AX
25717 +1234:
25718 +#endif
25719 +
25720 +#endif
25721 +
25722 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25723 xor %eax,%eax
25724 ASM_CLAC
25725 + pax_force_retaddr
25726 ret
25727 CFI_ENDPROC
25728 ENDPROC(__get_user_2)
25729 @@ -67,14 +104,28 @@ ENDPROC(__get_user_2)
25730 ENTRY(__get_user_4)
25731 CFI_STARTPROC
25732 add $3,%_ASM_AX
25733 +
25734 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25735 jc bad_get_user
25736 GET_THREAD_INFO(%_ASM_DX)
25737 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25738 jae bad_get_user
25739 ASM_STAC
25740 -3: mov -3(%_ASM_AX),%edx
25741 +
25742 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25743 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25744 + cmp %_ASM_DX,%_ASM_AX
25745 + jae 1234f
25746 + add %_ASM_DX,%_ASM_AX
25747 +1234:
25748 +#endif
25749 +
25750 +#endif
25751 +
25752 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
25753 xor %eax,%eax
25754 ASM_CLAC
25755 + pax_force_retaddr
25756 ret
25757 CFI_ENDPROC
25758 ENDPROC(__get_user_4)
25759 @@ -87,10 +138,20 @@ ENTRY(__get_user_8)
25760 GET_THREAD_INFO(%_ASM_DX)
25761 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25762 jae bad_get_user
25763 +
25764 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25765 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25766 + cmp %_ASM_DX,%_ASM_AX
25767 + jae 1234f
25768 + add %_ASM_DX,%_ASM_AX
25769 +1234:
25770 +#endif
25771 +
25772 ASM_STAC
25773 4: movq -7(%_ASM_AX),%_ASM_DX
25774 xor %eax,%eax
25775 ASM_CLAC
25776 + pax_force_retaddr
25777 ret
25778 CFI_ENDPROC
25779 ENDPROC(__get_user_8)
25780 @@ -101,6 +162,7 @@ bad_get_user:
25781 xor %edx,%edx
25782 mov $(-EFAULT),%_ASM_AX
25783 ASM_CLAC
25784 + pax_force_retaddr
25785 ret
25786 CFI_ENDPROC
25787 END(bad_get_user)
25788 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25789 index 54fcffe..7be149e 100644
25790 --- a/arch/x86/lib/insn.c
25791 +++ b/arch/x86/lib/insn.c
25792 @@ -20,8 +20,10 @@
25793
25794 #ifdef __KERNEL__
25795 #include <linux/string.h>
25796 +#include <asm/pgtable_types.h>
25797 #else
25798 #include <string.h>
25799 +#define ktla_ktva(addr) addr
25800 #endif
25801 #include <asm/inat.h>
25802 #include <asm/insn.h>
25803 @@ -53,8 +55,8 @@
25804 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25805 {
25806 memset(insn, 0, sizeof(*insn));
25807 - insn->kaddr = kaddr;
25808 - insn->next_byte = kaddr;
25809 + insn->kaddr = ktla_ktva(kaddr);
25810 + insn->next_byte = ktla_ktva(kaddr);
25811 insn->x86_64 = x86_64 ? 1 : 0;
25812 insn->opnd_bytes = 4;
25813 if (x86_64)
25814 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25815 index 05a95e7..326f2fa 100644
25816 --- a/arch/x86/lib/iomap_copy_64.S
25817 +++ b/arch/x86/lib/iomap_copy_64.S
25818 @@ -17,6 +17,7 @@
25819
25820 #include <linux/linkage.h>
25821 #include <asm/dwarf2.h>
25822 +#include <asm/alternative-asm.h>
25823
25824 /*
25825 * override generic version in lib/iomap_copy.c
25826 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25827 CFI_STARTPROC
25828 movl %edx,%ecx
25829 rep movsd
25830 + pax_force_retaddr
25831 ret
25832 CFI_ENDPROC
25833 ENDPROC(__iowrite32_copy)
25834 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25835 index 1c273be..da9cc0e 100644
25836 --- a/arch/x86/lib/memcpy_64.S
25837 +++ b/arch/x86/lib/memcpy_64.S
25838 @@ -33,6 +33,7 @@
25839 rep movsq
25840 movl %edx, %ecx
25841 rep movsb
25842 + pax_force_retaddr
25843 ret
25844 .Lmemcpy_e:
25845 .previous
25846 @@ -49,6 +50,7 @@
25847 movq %rdi, %rax
25848 movq %rdx, %rcx
25849 rep movsb
25850 + pax_force_retaddr
25851 ret
25852 .Lmemcpy_e_e:
25853 .previous
25854 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25855 */
25856 movq 0*8(%rsi), %r8
25857 movq 1*8(%rsi), %r9
25858 - movq 2*8(%rsi), %r10
25859 + movq 2*8(%rsi), %rcx
25860 movq 3*8(%rsi), %r11
25861 leaq 4*8(%rsi), %rsi
25862
25863 movq %r8, 0*8(%rdi)
25864 movq %r9, 1*8(%rdi)
25865 - movq %r10, 2*8(%rdi)
25866 + movq %rcx, 2*8(%rdi)
25867 movq %r11, 3*8(%rdi)
25868 leaq 4*8(%rdi), %rdi
25869 jae .Lcopy_forward_loop
25870 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25871 subq $0x20, %rdx
25872 movq -1*8(%rsi), %r8
25873 movq -2*8(%rsi), %r9
25874 - movq -3*8(%rsi), %r10
25875 + movq -3*8(%rsi), %rcx
25876 movq -4*8(%rsi), %r11
25877 leaq -4*8(%rsi), %rsi
25878 movq %r8, -1*8(%rdi)
25879 movq %r9, -2*8(%rdi)
25880 - movq %r10, -3*8(%rdi)
25881 + movq %rcx, -3*8(%rdi)
25882 movq %r11, -4*8(%rdi)
25883 leaq -4*8(%rdi), %rdi
25884 jae .Lcopy_backward_loop
25885 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25886 */
25887 movq 0*8(%rsi), %r8
25888 movq 1*8(%rsi), %r9
25889 - movq -2*8(%rsi, %rdx), %r10
25890 + movq -2*8(%rsi, %rdx), %rcx
25891 movq -1*8(%rsi, %rdx), %r11
25892 movq %r8, 0*8(%rdi)
25893 movq %r9, 1*8(%rdi)
25894 - movq %r10, -2*8(%rdi, %rdx)
25895 + movq %rcx, -2*8(%rdi, %rdx)
25896 movq %r11, -1*8(%rdi, %rdx)
25897 + pax_force_retaddr
25898 retq
25899 .p2align 4
25900 .Lless_16bytes:
25901 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25902 movq -1*8(%rsi, %rdx), %r9
25903 movq %r8, 0*8(%rdi)
25904 movq %r9, -1*8(%rdi, %rdx)
25905 + pax_force_retaddr
25906 retq
25907 .p2align 4
25908 .Lless_8bytes:
25909 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25910 movl -4(%rsi, %rdx), %r8d
25911 movl %ecx, (%rdi)
25912 movl %r8d, -4(%rdi, %rdx)
25913 + pax_force_retaddr
25914 retq
25915 .p2align 4
25916 .Lless_3bytes:
25917 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25918 movb %cl, (%rdi)
25919
25920 .Lend:
25921 + pax_force_retaddr
25922 retq
25923 CFI_ENDPROC
25924 ENDPROC(memcpy)
25925 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25926 index ee16461..c39c199 100644
25927 --- a/arch/x86/lib/memmove_64.S
25928 +++ b/arch/x86/lib/memmove_64.S
25929 @@ -61,13 +61,13 @@ ENTRY(memmove)
25930 5:
25931 sub $0x20, %rdx
25932 movq 0*8(%rsi), %r11
25933 - movq 1*8(%rsi), %r10
25934 + movq 1*8(%rsi), %rcx
25935 movq 2*8(%rsi), %r9
25936 movq 3*8(%rsi), %r8
25937 leaq 4*8(%rsi), %rsi
25938
25939 movq %r11, 0*8(%rdi)
25940 - movq %r10, 1*8(%rdi)
25941 + movq %rcx, 1*8(%rdi)
25942 movq %r9, 2*8(%rdi)
25943 movq %r8, 3*8(%rdi)
25944 leaq 4*8(%rdi), %rdi
25945 @@ -81,10 +81,10 @@ ENTRY(memmove)
25946 4:
25947 movq %rdx, %rcx
25948 movq -8(%rsi, %rdx), %r11
25949 - lea -8(%rdi, %rdx), %r10
25950 + lea -8(%rdi, %rdx), %r9
25951 shrq $3, %rcx
25952 rep movsq
25953 - movq %r11, (%r10)
25954 + movq %r11, (%r9)
25955 jmp 13f
25956 .Lmemmove_end_forward:
25957
25958 @@ -95,14 +95,14 @@ ENTRY(memmove)
25959 7:
25960 movq %rdx, %rcx
25961 movq (%rsi), %r11
25962 - movq %rdi, %r10
25963 + movq %rdi, %r9
25964 leaq -8(%rsi, %rdx), %rsi
25965 leaq -8(%rdi, %rdx), %rdi
25966 shrq $3, %rcx
25967 std
25968 rep movsq
25969 cld
25970 - movq %r11, (%r10)
25971 + movq %r11, (%r9)
25972 jmp 13f
25973
25974 /*
25975 @@ -127,13 +127,13 @@ ENTRY(memmove)
25976 8:
25977 subq $0x20, %rdx
25978 movq -1*8(%rsi), %r11
25979 - movq -2*8(%rsi), %r10
25980 + movq -2*8(%rsi), %rcx
25981 movq -3*8(%rsi), %r9
25982 movq -4*8(%rsi), %r8
25983 leaq -4*8(%rsi), %rsi
25984
25985 movq %r11, -1*8(%rdi)
25986 - movq %r10, -2*8(%rdi)
25987 + movq %rcx, -2*8(%rdi)
25988 movq %r9, -3*8(%rdi)
25989 movq %r8, -4*8(%rdi)
25990 leaq -4*8(%rdi), %rdi
25991 @@ -151,11 +151,11 @@ ENTRY(memmove)
25992 * Move data from 16 bytes to 31 bytes.
25993 */
25994 movq 0*8(%rsi), %r11
25995 - movq 1*8(%rsi), %r10
25996 + movq 1*8(%rsi), %rcx
25997 movq -2*8(%rsi, %rdx), %r9
25998 movq -1*8(%rsi, %rdx), %r8
25999 movq %r11, 0*8(%rdi)
26000 - movq %r10, 1*8(%rdi)
26001 + movq %rcx, 1*8(%rdi)
26002 movq %r9, -2*8(%rdi, %rdx)
26003 movq %r8, -1*8(%rdi, %rdx)
26004 jmp 13f
26005 @@ -167,9 +167,9 @@ ENTRY(memmove)
26006 * Move data from 8 bytes to 15 bytes.
26007 */
26008 movq 0*8(%rsi), %r11
26009 - movq -1*8(%rsi, %rdx), %r10
26010 + movq -1*8(%rsi, %rdx), %r9
26011 movq %r11, 0*8(%rdi)
26012 - movq %r10, -1*8(%rdi, %rdx)
26013 + movq %r9, -1*8(%rdi, %rdx)
26014 jmp 13f
26015 10:
26016 cmpq $4, %rdx
26017 @@ -178,9 +178,9 @@ ENTRY(memmove)
26018 * Move data from 4 bytes to 7 bytes.
26019 */
26020 movl (%rsi), %r11d
26021 - movl -4(%rsi, %rdx), %r10d
26022 + movl -4(%rsi, %rdx), %r9d
26023 movl %r11d, (%rdi)
26024 - movl %r10d, -4(%rdi, %rdx)
26025 + movl %r9d, -4(%rdi, %rdx)
26026 jmp 13f
26027 11:
26028 cmp $2, %rdx
26029 @@ -189,9 +189,9 @@ ENTRY(memmove)
26030 * Move data from 2 bytes to 3 bytes.
26031 */
26032 movw (%rsi), %r11w
26033 - movw -2(%rsi, %rdx), %r10w
26034 + movw -2(%rsi, %rdx), %r9w
26035 movw %r11w, (%rdi)
26036 - movw %r10w, -2(%rdi, %rdx)
26037 + movw %r9w, -2(%rdi, %rdx)
26038 jmp 13f
26039 12:
26040 cmp $1, %rdx
26041 @@ -202,6 +202,7 @@ ENTRY(memmove)
26042 movb (%rsi), %r11b
26043 movb %r11b, (%rdi)
26044 13:
26045 + pax_force_retaddr
26046 retq
26047 CFI_ENDPROC
26048
26049 @@ -210,6 +211,7 @@ ENTRY(memmove)
26050 /* Forward moving data. */
26051 movq %rdx, %rcx
26052 rep movsb
26053 + pax_force_retaddr
26054 retq
26055 .Lmemmove_end_forward_efs:
26056 .previous
26057 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
26058 index 2dcb380..963660a 100644
26059 --- a/arch/x86/lib/memset_64.S
26060 +++ b/arch/x86/lib/memset_64.S
26061 @@ -30,6 +30,7 @@
26062 movl %edx,%ecx
26063 rep stosb
26064 movq %r9,%rax
26065 + pax_force_retaddr
26066 ret
26067 .Lmemset_e:
26068 .previous
26069 @@ -52,6 +53,7 @@
26070 movq %rdx,%rcx
26071 rep stosb
26072 movq %r9,%rax
26073 + pax_force_retaddr
26074 ret
26075 .Lmemset_e_e:
26076 .previous
26077 @@ -59,7 +61,7 @@
26078 ENTRY(memset)
26079 ENTRY(__memset)
26080 CFI_STARTPROC
26081 - movq %rdi,%r10
26082 + movq %rdi,%r11
26083
26084 /* expand byte value */
26085 movzbl %sil,%ecx
26086 @@ -117,7 +119,8 @@ ENTRY(__memset)
26087 jnz .Lloop_1
26088
26089 .Lende:
26090 - movq %r10,%rax
26091 + movq %r11,%rax
26092 + pax_force_retaddr
26093 ret
26094
26095 CFI_RESTORE_STATE
26096 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
26097 index c9f2d9b..e7fd2c0 100644
26098 --- a/arch/x86/lib/mmx_32.c
26099 +++ b/arch/x86/lib/mmx_32.c
26100 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26101 {
26102 void *p;
26103 int i;
26104 + unsigned long cr0;
26105
26106 if (unlikely(in_interrupt()))
26107 return __memcpy(to, from, len);
26108 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26109 kernel_fpu_begin();
26110
26111 __asm__ __volatile__ (
26112 - "1: prefetch (%0)\n" /* This set is 28 bytes */
26113 - " prefetch 64(%0)\n"
26114 - " prefetch 128(%0)\n"
26115 - " prefetch 192(%0)\n"
26116 - " prefetch 256(%0)\n"
26117 + "1: prefetch (%1)\n" /* This set is 28 bytes */
26118 + " prefetch 64(%1)\n"
26119 + " prefetch 128(%1)\n"
26120 + " prefetch 192(%1)\n"
26121 + " prefetch 256(%1)\n"
26122 "2: \n"
26123 ".section .fixup, \"ax\"\n"
26124 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26125 + "3: \n"
26126 +
26127 +#ifdef CONFIG_PAX_KERNEXEC
26128 + " movl %%cr0, %0\n"
26129 + " movl %0, %%eax\n"
26130 + " andl $0xFFFEFFFF, %%eax\n"
26131 + " movl %%eax, %%cr0\n"
26132 +#endif
26133 +
26134 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26135 +
26136 +#ifdef CONFIG_PAX_KERNEXEC
26137 + " movl %0, %%cr0\n"
26138 +#endif
26139 +
26140 " jmp 2b\n"
26141 ".previous\n"
26142 _ASM_EXTABLE(1b, 3b)
26143 - : : "r" (from));
26144 + : "=&r" (cr0) : "r" (from) : "ax");
26145
26146 for ( ; i > 5; i--) {
26147 __asm__ __volatile__ (
26148 - "1: prefetch 320(%0)\n"
26149 - "2: movq (%0), %%mm0\n"
26150 - " movq 8(%0), %%mm1\n"
26151 - " movq 16(%0), %%mm2\n"
26152 - " movq 24(%0), %%mm3\n"
26153 - " movq %%mm0, (%1)\n"
26154 - " movq %%mm1, 8(%1)\n"
26155 - " movq %%mm2, 16(%1)\n"
26156 - " movq %%mm3, 24(%1)\n"
26157 - " movq 32(%0), %%mm0\n"
26158 - " movq 40(%0), %%mm1\n"
26159 - " movq 48(%0), %%mm2\n"
26160 - " movq 56(%0), %%mm3\n"
26161 - " movq %%mm0, 32(%1)\n"
26162 - " movq %%mm1, 40(%1)\n"
26163 - " movq %%mm2, 48(%1)\n"
26164 - " movq %%mm3, 56(%1)\n"
26165 + "1: prefetch 320(%1)\n"
26166 + "2: movq (%1), %%mm0\n"
26167 + " movq 8(%1), %%mm1\n"
26168 + " movq 16(%1), %%mm2\n"
26169 + " movq 24(%1), %%mm3\n"
26170 + " movq %%mm0, (%2)\n"
26171 + " movq %%mm1, 8(%2)\n"
26172 + " movq %%mm2, 16(%2)\n"
26173 + " movq %%mm3, 24(%2)\n"
26174 + " movq 32(%1), %%mm0\n"
26175 + " movq 40(%1), %%mm1\n"
26176 + " movq 48(%1), %%mm2\n"
26177 + " movq 56(%1), %%mm3\n"
26178 + " movq %%mm0, 32(%2)\n"
26179 + " movq %%mm1, 40(%2)\n"
26180 + " movq %%mm2, 48(%2)\n"
26181 + " movq %%mm3, 56(%2)\n"
26182 ".section .fixup, \"ax\"\n"
26183 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26184 + "3:\n"
26185 +
26186 +#ifdef CONFIG_PAX_KERNEXEC
26187 + " movl %%cr0, %0\n"
26188 + " movl %0, %%eax\n"
26189 + " andl $0xFFFEFFFF, %%eax\n"
26190 + " movl %%eax, %%cr0\n"
26191 +#endif
26192 +
26193 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26194 +
26195 +#ifdef CONFIG_PAX_KERNEXEC
26196 + " movl %0, %%cr0\n"
26197 +#endif
26198 +
26199 " jmp 2b\n"
26200 ".previous\n"
26201 _ASM_EXTABLE(1b, 3b)
26202 - : : "r" (from), "r" (to) : "memory");
26203 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26204
26205 from += 64;
26206 to += 64;
26207 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
26208 static void fast_copy_page(void *to, void *from)
26209 {
26210 int i;
26211 + unsigned long cr0;
26212
26213 kernel_fpu_begin();
26214
26215 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
26216 * but that is for later. -AV
26217 */
26218 __asm__ __volatile__(
26219 - "1: prefetch (%0)\n"
26220 - " prefetch 64(%0)\n"
26221 - " prefetch 128(%0)\n"
26222 - " prefetch 192(%0)\n"
26223 - " prefetch 256(%0)\n"
26224 + "1: prefetch (%1)\n"
26225 + " prefetch 64(%1)\n"
26226 + " prefetch 128(%1)\n"
26227 + " prefetch 192(%1)\n"
26228 + " prefetch 256(%1)\n"
26229 "2: \n"
26230 ".section .fixup, \"ax\"\n"
26231 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26232 + "3: \n"
26233 +
26234 +#ifdef CONFIG_PAX_KERNEXEC
26235 + " movl %%cr0, %0\n"
26236 + " movl %0, %%eax\n"
26237 + " andl $0xFFFEFFFF, %%eax\n"
26238 + " movl %%eax, %%cr0\n"
26239 +#endif
26240 +
26241 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26242 +
26243 +#ifdef CONFIG_PAX_KERNEXEC
26244 + " movl %0, %%cr0\n"
26245 +#endif
26246 +
26247 " jmp 2b\n"
26248 ".previous\n"
26249 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26250 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26251
26252 for (i = 0; i < (4096-320)/64; i++) {
26253 __asm__ __volatile__ (
26254 - "1: prefetch 320(%0)\n"
26255 - "2: movq (%0), %%mm0\n"
26256 - " movntq %%mm0, (%1)\n"
26257 - " movq 8(%0), %%mm1\n"
26258 - " movntq %%mm1, 8(%1)\n"
26259 - " movq 16(%0), %%mm2\n"
26260 - " movntq %%mm2, 16(%1)\n"
26261 - " movq 24(%0), %%mm3\n"
26262 - " movntq %%mm3, 24(%1)\n"
26263 - " movq 32(%0), %%mm4\n"
26264 - " movntq %%mm4, 32(%1)\n"
26265 - " movq 40(%0), %%mm5\n"
26266 - " movntq %%mm5, 40(%1)\n"
26267 - " movq 48(%0), %%mm6\n"
26268 - " movntq %%mm6, 48(%1)\n"
26269 - " movq 56(%0), %%mm7\n"
26270 - " movntq %%mm7, 56(%1)\n"
26271 + "1: prefetch 320(%1)\n"
26272 + "2: movq (%1), %%mm0\n"
26273 + " movntq %%mm0, (%2)\n"
26274 + " movq 8(%1), %%mm1\n"
26275 + " movntq %%mm1, 8(%2)\n"
26276 + " movq 16(%1), %%mm2\n"
26277 + " movntq %%mm2, 16(%2)\n"
26278 + " movq 24(%1), %%mm3\n"
26279 + " movntq %%mm3, 24(%2)\n"
26280 + " movq 32(%1), %%mm4\n"
26281 + " movntq %%mm4, 32(%2)\n"
26282 + " movq 40(%1), %%mm5\n"
26283 + " movntq %%mm5, 40(%2)\n"
26284 + " movq 48(%1), %%mm6\n"
26285 + " movntq %%mm6, 48(%2)\n"
26286 + " movq 56(%1), %%mm7\n"
26287 + " movntq %%mm7, 56(%2)\n"
26288 ".section .fixup, \"ax\"\n"
26289 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26290 + "3:\n"
26291 +
26292 +#ifdef CONFIG_PAX_KERNEXEC
26293 + " movl %%cr0, %0\n"
26294 + " movl %0, %%eax\n"
26295 + " andl $0xFFFEFFFF, %%eax\n"
26296 + " movl %%eax, %%cr0\n"
26297 +#endif
26298 +
26299 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26300 +
26301 +#ifdef CONFIG_PAX_KERNEXEC
26302 + " movl %0, %%cr0\n"
26303 +#endif
26304 +
26305 " jmp 2b\n"
26306 ".previous\n"
26307 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26308 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26309
26310 from += 64;
26311 to += 64;
26312 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26313 static void fast_copy_page(void *to, void *from)
26314 {
26315 int i;
26316 + unsigned long cr0;
26317
26318 kernel_fpu_begin();
26319
26320 __asm__ __volatile__ (
26321 - "1: prefetch (%0)\n"
26322 - " prefetch 64(%0)\n"
26323 - " prefetch 128(%0)\n"
26324 - " prefetch 192(%0)\n"
26325 - " prefetch 256(%0)\n"
26326 + "1: prefetch (%1)\n"
26327 + " prefetch 64(%1)\n"
26328 + " prefetch 128(%1)\n"
26329 + " prefetch 192(%1)\n"
26330 + " prefetch 256(%1)\n"
26331 "2: \n"
26332 ".section .fixup, \"ax\"\n"
26333 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26334 + "3: \n"
26335 +
26336 +#ifdef CONFIG_PAX_KERNEXEC
26337 + " movl %%cr0, %0\n"
26338 + " movl %0, %%eax\n"
26339 + " andl $0xFFFEFFFF, %%eax\n"
26340 + " movl %%eax, %%cr0\n"
26341 +#endif
26342 +
26343 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26344 +
26345 +#ifdef CONFIG_PAX_KERNEXEC
26346 + " movl %0, %%cr0\n"
26347 +#endif
26348 +
26349 " jmp 2b\n"
26350 ".previous\n"
26351 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26352 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26353
26354 for (i = 0; i < 4096/64; i++) {
26355 __asm__ __volatile__ (
26356 - "1: prefetch 320(%0)\n"
26357 - "2: movq (%0), %%mm0\n"
26358 - " movq 8(%0), %%mm1\n"
26359 - " movq 16(%0), %%mm2\n"
26360 - " movq 24(%0), %%mm3\n"
26361 - " movq %%mm0, (%1)\n"
26362 - " movq %%mm1, 8(%1)\n"
26363 - " movq %%mm2, 16(%1)\n"
26364 - " movq %%mm3, 24(%1)\n"
26365 - " movq 32(%0), %%mm0\n"
26366 - " movq 40(%0), %%mm1\n"
26367 - " movq 48(%0), %%mm2\n"
26368 - " movq 56(%0), %%mm3\n"
26369 - " movq %%mm0, 32(%1)\n"
26370 - " movq %%mm1, 40(%1)\n"
26371 - " movq %%mm2, 48(%1)\n"
26372 - " movq %%mm3, 56(%1)\n"
26373 + "1: prefetch 320(%1)\n"
26374 + "2: movq (%1), %%mm0\n"
26375 + " movq 8(%1), %%mm1\n"
26376 + " movq 16(%1), %%mm2\n"
26377 + " movq 24(%1), %%mm3\n"
26378 + " movq %%mm0, (%2)\n"
26379 + " movq %%mm1, 8(%2)\n"
26380 + " movq %%mm2, 16(%2)\n"
26381 + " movq %%mm3, 24(%2)\n"
26382 + " movq 32(%1), %%mm0\n"
26383 + " movq 40(%1), %%mm1\n"
26384 + " movq 48(%1), %%mm2\n"
26385 + " movq 56(%1), %%mm3\n"
26386 + " movq %%mm0, 32(%2)\n"
26387 + " movq %%mm1, 40(%2)\n"
26388 + " movq %%mm2, 48(%2)\n"
26389 + " movq %%mm3, 56(%2)\n"
26390 ".section .fixup, \"ax\"\n"
26391 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26392 + "3:\n"
26393 +
26394 +#ifdef CONFIG_PAX_KERNEXEC
26395 + " movl %%cr0, %0\n"
26396 + " movl %0, %%eax\n"
26397 + " andl $0xFFFEFFFF, %%eax\n"
26398 + " movl %%eax, %%cr0\n"
26399 +#endif
26400 +
26401 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26402 +
26403 +#ifdef CONFIG_PAX_KERNEXEC
26404 + " movl %0, %%cr0\n"
26405 +#endif
26406 +
26407 " jmp 2b\n"
26408 ".previous\n"
26409 _ASM_EXTABLE(1b, 3b)
26410 - : : "r" (from), "r" (to) : "memory");
26411 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26412
26413 from += 64;
26414 to += 64;
26415 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26416 index f6d13ee..aca5f0b 100644
26417 --- a/arch/x86/lib/msr-reg.S
26418 +++ b/arch/x86/lib/msr-reg.S
26419 @@ -3,6 +3,7 @@
26420 #include <asm/dwarf2.h>
26421 #include <asm/asm.h>
26422 #include <asm/msr.h>
26423 +#include <asm/alternative-asm.h>
26424
26425 #ifdef CONFIG_X86_64
26426 /*
26427 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26428 CFI_STARTPROC
26429 pushq_cfi %rbx
26430 pushq_cfi %rbp
26431 - movq %rdi, %r10 /* Save pointer */
26432 + movq %rdi, %r9 /* Save pointer */
26433 xorl %r11d, %r11d /* Return value */
26434 movl (%rdi), %eax
26435 movl 4(%rdi), %ecx
26436 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26437 movl 28(%rdi), %edi
26438 CFI_REMEMBER_STATE
26439 1: \op
26440 -2: movl %eax, (%r10)
26441 +2: movl %eax, (%r9)
26442 movl %r11d, %eax /* Return value */
26443 - movl %ecx, 4(%r10)
26444 - movl %edx, 8(%r10)
26445 - movl %ebx, 12(%r10)
26446 - movl %ebp, 20(%r10)
26447 - movl %esi, 24(%r10)
26448 - movl %edi, 28(%r10)
26449 + movl %ecx, 4(%r9)
26450 + movl %edx, 8(%r9)
26451 + movl %ebx, 12(%r9)
26452 + movl %ebp, 20(%r9)
26453 + movl %esi, 24(%r9)
26454 + movl %edi, 28(%r9)
26455 popq_cfi %rbp
26456 popq_cfi %rbx
26457 + pax_force_retaddr
26458 ret
26459 3:
26460 CFI_RESTORE_STATE
26461 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26462 index fc6ba17..04471c5 100644
26463 --- a/arch/x86/lib/putuser.S
26464 +++ b/arch/x86/lib/putuser.S
26465 @@ -16,7 +16,9 @@
26466 #include <asm/errno.h>
26467 #include <asm/asm.h>
26468 #include <asm/smap.h>
26469 -
26470 +#include <asm/segment.h>
26471 +#include <asm/pgtable.h>
26472 +#include <asm/alternative-asm.h>
26473
26474 /*
26475 * __put_user_X
26476 @@ -30,57 +32,125 @@
26477 * as they get called from within inline assembly.
26478 */
26479
26480 -#define ENTER CFI_STARTPROC ; \
26481 - GET_THREAD_INFO(%_ASM_BX)
26482 -#define EXIT ASM_CLAC ; \
26483 - ret ; \
26484 +#define ENTER CFI_STARTPROC
26485 +#define EXIT ASM_CLAC ; \
26486 + pax_force_retaddr ; \
26487 + ret ; \
26488 CFI_ENDPROC
26489
26490 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26491 +#define _DEST %_ASM_CX,%_ASM_BX
26492 +#else
26493 +#define _DEST %_ASM_CX
26494 +#endif
26495 +
26496 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26497 +#define __copyuser_seg gs;
26498 +#else
26499 +#define __copyuser_seg
26500 +#endif
26501 +
26502 .text
26503 ENTRY(__put_user_1)
26504 ENTER
26505 +
26506 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26507 + GET_THREAD_INFO(%_ASM_BX)
26508 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26509 jae bad_put_user
26510 ASM_STAC
26511 -1: movb %al,(%_ASM_CX)
26512 +
26513 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26514 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26515 + cmp %_ASM_BX,%_ASM_CX
26516 + jb 1234f
26517 + xor %ebx,%ebx
26518 +1234:
26519 +#endif
26520 +
26521 +#endif
26522 +
26523 +1: __copyuser_seg movb %al,(_DEST)
26524 xor %eax,%eax
26525 EXIT
26526 ENDPROC(__put_user_1)
26527
26528 ENTRY(__put_user_2)
26529 ENTER
26530 +
26531 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26532 + GET_THREAD_INFO(%_ASM_BX)
26533 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26534 sub $1,%_ASM_BX
26535 cmp %_ASM_BX,%_ASM_CX
26536 jae bad_put_user
26537 ASM_STAC
26538 -2: movw %ax,(%_ASM_CX)
26539 +
26540 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26541 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26542 + cmp %_ASM_BX,%_ASM_CX
26543 + jb 1234f
26544 + xor %ebx,%ebx
26545 +1234:
26546 +#endif
26547 +
26548 +#endif
26549 +
26550 +2: __copyuser_seg movw %ax,(_DEST)
26551 xor %eax,%eax
26552 EXIT
26553 ENDPROC(__put_user_2)
26554
26555 ENTRY(__put_user_4)
26556 ENTER
26557 +
26558 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26559 + GET_THREAD_INFO(%_ASM_BX)
26560 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26561 sub $3,%_ASM_BX
26562 cmp %_ASM_BX,%_ASM_CX
26563 jae bad_put_user
26564 ASM_STAC
26565 -3: movl %eax,(%_ASM_CX)
26566 +
26567 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26568 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26569 + cmp %_ASM_BX,%_ASM_CX
26570 + jb 1234f
26571 + xor %ebx,%ebx
26572 +1234:
26573 +#endif
26574 +
26575 +#endif
26576 +
26577 +3: __copyuser_seg movl %eax,(_DEST)
26578 xor %eax,%eax
26579 EXIT
26580 ENDPROC(__put_user_4)
26581
26582 ENTRY(__put_user_8)
26583 ENTER
26584 +
26585 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26586 + GET_THREAD_INFO(%_ASM_BX)
26587 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26588 sub $7,%_ASM_BX
26589 cmp %_ASM_BX,%_ASM_CX
26590 jae bad_put_user
26591 ASM_STAC
26592 -4: mov %_ASM_AX,(%_ASM_CX)
26593 +
26594 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26595 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26596 + cmp %_ASM_BX,%_ASM_CX
26597 + jb 1234f
26598 + xor %ebx,%ebx
26599 +1234:
26600 +#endif
26601 +
26602 +#endif
26603 +
26604 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26605 #ifdef CONFIG_X86_32
26606 -5: movl %edx,4(%_ASM_CX)
26607 +5: __copyuser_seg movl %edx,4(_DEST)
26608 #endif
26609 xor %eax,%eax
26610 EXIT
26611 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26612 index 1cad221..de671ee 100644
26613 --- a/arch/x86/lib/rwlock.S
26614 +++ b/arch/x86/lib/rwlock.S
26615 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26616 FRAME
26617 0: LOCK_PREFIX
26618 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26619 +
26620 +#ifdef CONFIG_PAX_REFCOUNT
26621 + jno 1234f
26622 + LOCK_PREFIX
26623 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26624 + int $4
26625 +1234:
26626 + _ASM_EXTABLE(1234b, 1234b)
26627 +#endif
26628 +
26629 1: rep; nop
26630 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26631 jne 1b
26632 LOCK_PREFIX
26633 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26634 +
26635 +#ifdef CONFIG_PAX_REFCOUNT
26636 + jno 1234f
26637 + LOCK_PREFIX
26638 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26639 + int $4
26640 +1234:
26641 + _ASM_EXTABLE(1234b, 1234b)
26642 +#endif
26643 +
26644 jnz 0b
26645 ENDFRAME
26646 + pax_force_retaddr
26647 ret
26648 CFI_ENDPROC
26649 END(__write_lock_failed)
26650 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26651 FRAME
26652 0: LOCK_PREFIX
26653 READ_LOCK_SIZE(inc) (%__lock_ptr)
26654 +
26655 +#ifdef CONFIG_PAX_REFCOUNT
26656 + jno 1234f
26657 + LOCK_PREFIX
26658 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26659 + int $4
26660 +1234:
26661 + _ASM_EXTABLE(1234b, 1234b)
26662 +#endif
26663 +
26664 1: rep; nop
26665 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26666 js 1b
26667 LOCK_PREFIX
26668 READ_LOCK_SIZE(dec) (%__lock_ptr)
26669 +
26670 +#ifdef CONFIG_PAX_REFCOUNT
26671 + jno 1234f
26672 + LOCK_PREFIX
26673 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26674 + int $4
26675 +1234:
26676 + _ASM_EXTABLE(1234b, 1234b)
26677 +#endif
26678 +
26679 js 0b
26680 ENDFRAME
26681 + pax_force_retaddr
26682 ret
26683 CFI_ENDPROC
26684 END(__read_lock_failed)
26685 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26686 index 5dff5f0..cadebf4 100644
26687 --- a/arch/x86/lib/rwsem.S
26688 +++ b/arch/x86/lib/rwsem.S
26689 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26690 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26691 CFI_RESTORE __ASM_REG(dx)
26692 restore_common_regs
26693 + pax_force_retaddr
26694 ret
26695 CFI_ENDPROC
26696 ENDPROC(call_rwsem_down_read_failed)
26697 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26698 movq %rax,%rdi
26699 call rwsem_down_write_failed
26700 restore_common_regs
26701 + pax_force_retaddr
26702 ret
26703 CFI_ENDPROC
26704 ENDPROC(call_rwsem_down_write_failed)
26705 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26706 movq %rax,%rdi
26707 call rwsem_wake
26708 restore_common_regs
26709 -1: ret
26710 +1: pax_force_retaddr
26711 + ret
26712 CFI_ENDPROC
26713 ENDPROC(call_rwsem_wake)
26714
26715 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26716 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26717 CFI_RESTORE __ASM_REG(dx)
26718 restore_common_regs
26719 + pax_force_retaddr
26720 ret
26721 CFI_ENDPROC
26722 ENDPROC(call_rwsem_downgrade_wake)
26723 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26724 index a63efd6..ccecad8 100644
26725 --- a/arch/x86/lib/thunk_64.S
26726 +++ b/arch/x86/lib/thunk_64.S
26727 @@ -8,6 +8,7 @@
26728 #include <linux/linkage.h>
26729 #include <asm/dwarf2.h>
26730 #include <asm/calling.h>
26731 +#include <asm/alternative-asm.h>
26732
26733 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26734 .macro THUNK name, func, put_ret_addr_in_rdi=0
26735 @@ -41,5 +42,6 @@
26736 SAVE_ARGS
26737 restore:
26738 RESTORE_ARGS
26739 + pax_force_retaddr
26740 ret
26741 CFI_ENDPROC
26742 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26743 index f0312d7..9c39d63 100644
26744 --- a/arch/x86/lib/usercopy_32.c
26745 +++ b/arch/x86/lib/usercopy_32.c
26746 @@ -42,11 +42,13 @@ do { \
26747 int __d0; \
26748 might_fault(); \
26749 __asm__ __volatile__( \
26750 + __COPYUSER_SET_ES \
26751 ASM_STAC "\n" \
26752 "0: rep; stosl\n" \
26753 " movl %2,%0\n" \
26754 "1: rep; stosb\n" \
26755 "2: " ASM_CLAC "\n" \
26756 + __COPYUSER_RESTORE_ES \
26757 ".section .fixup,\"ax\"\n" \
26758 "3: lea 0(%2,%0,4),%0\n" \
26759 " jmp 2b\n" \
26760 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26761
26762 #ifdef CONFIG_X86_INTEL_USERCOPY
26763 static unsigned long
26764 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26765 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26766 {
26767 int d0, d1;
26768 __asm__ __volatile__(
26769 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26770 " .align 2,0x90\n"
26771 "3: movl 0(%4), %%eax\n"
26772 "4: movl 4(%4), %%edx\n"
26773 - "5: movl %%eax, 0(%3)\n"
26774 - "6: movl %%edx, 4(%3)\n"
26775 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26776 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26777 "7: movl 8(%4), %%eax\n"
26778 "8: movl 12(%4),%%edx\n"
26779 - "9: movl %%eax, 8(%3)\n"
26780 - "10: movl %%edx, 12(%3)\n"
26781 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26782 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26783 "11: movl 16(%4), %%eax\n"
26784 "12: movl 20(%4), %%edx\n"
26785 - "13: movl %%eax, 16(%3)\n"
26786 - "14: movl %%edx, 20(%3)\n"
26787 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26788 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26789 "15: movl 24(%4), %%eax\n"
26790 "16: movl 28(%4), %%edx\n"
26791 - "17: movl %%eax, 24(%3)\n"
26792 - "18: movl %%edx, 28(%3)\n"
26793 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26794 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26795 "19: movl 32(%4), %%eax\n"
26796 "20: movl 36(%4), %%edx\n"
26797 - "21: movl %%eax, 32(%3)\n"
26798 - "22: movl %%edx, 36(%3)\n"
26799 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26800 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26801 "23: movl 40(%4), %%eax\n"
26802 "24: movl 44(%4), %%edx\n"
26803 - "25: movl %%eax, 40(%3)\n"
26804 - "26: movl %%edx, 44(%3)\n"
26805 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26806 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26807 "27: movl 48(%4), %%eax\n"
26808 "28: movl 52(%4), %%edx\n"
26809 - "29: movl %%eax, 48(%3)\n"
26810 - "30: movl %%edx, 52(%3)\n"
26811 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26812 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26813 "31: movl 56(%4), %%eax\n"
26814 "32: movl 60(%4), %%edx\n"
26815 - "33: movl %%eax, 56(%3)\n"
26816 - "34: movl %%edx, 60(%3)\n"
26817 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26818 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26819 " addl $-64, %0\n"
26820 " addl $64, %4\n"
26821 " addl $64, %3\n"
26822 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26823 " shrl $2, %0\n"
26824 " andl $3, %%eax\n"
26825 " cld\n"
26826 + __COPYUSER_SET_ES
26827 "99: rep; movsl\n"
26828 "36: movl %%eax, %0\n"
26829 "37: rep; movsb\n"
26830 "100:\n"
26831 + __COPYUSER_RESTORE_ES
26832 ".section .fixup,\"ax\"\n"
26833 "101: lea 0(%%eax,%0,4),%0\n"
26834 " jmp 100b\n"
26835 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26836 }
26837
26838 static unsigned long
26839 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26840 +{
26841 + int d0, d1;
26842 + __asm__ __volatile__(
26843 + " .align 2,0x90\n"
26844 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26845 + " cmpl $67, %0\n"
26846 + " jbe 3f\n"
26847 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26848 + " .align 2,0x90\n"
26849 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26850 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26851 + "5: movl %%eax, 0(%3)\n"
26852 + "6: movl %%edx, 4(%3)\n"
26853 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26854 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26855 + "9: movl %%eax, 8(%3)\n"
26856 + "10: movl %%edx, 12(%3)\n"
26857 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26858 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26859 + "13: movl %%eax, 16(%3)\n"
26860 + "14: movl %%edx, 20(%3)\n"
26861 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26862 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26863 + "17: movl %%eax, 24(%3)\n"
26864 + "18: movl %%edx, 28(%3)\n"
26865 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26866 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26867 + "21: movl %%eax, 32(%3)\n"
26868 + "22: movl %%edx, 36(%3)\n"
26869 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26870 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26871 + "25: movl %%eax, 40(%3)\n"
26872 + "26: movl %%edx, 44(%3)\n"
26873 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26874 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26875 + "29: movl %%eax, 48(%3)\n"
26876 + "30: movl %%edx, 52(%3)\n"
26877 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26878 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26879 + "33: movl %%eax, 56(%3)\n"
26880 + "34: movl %%edx, 60(%3)\n"
26881 + " addl $-64, %0\n"
26882 + " addl $64, %4\n"
26883 + " addl $64, %3\n"
26884 + " cmpl $63, %0\n"
26885 + " ja 1b\n"
26886 + "35: movl %0, %%eax\n"
26887 + " shrl $2, %0\n"
26888 + " andl $3, %%eax\n"
26889 + " cld\n"
26890 + "99: rep; "__copyuser_seg" movsl\n"
26891 + "36: movl %%eax, %0\n"
26892 + "37: rep; "__copyuser_seg" movsb\n"
26893 + "100:\n"
26894 + ".section .fixup,\"ax\"\n"
26895 + "101: lea 0(%%eax,%0,4),%0\n"
26896 + " jmp 100b\n"
26897 + ".previous\n"
26898 + _ASM_EXTABLE(1b,100b)
26899 + _ASM_EXTABLE(2b,100b)
26900 + _ASM_EXTABLE(3b,100b)
26901 + _ASM_EXTABLE(4b,100b)
26902 + _ASM_EXTABLE(5b,100b)
26903 + _ASM_EXTABLE(6b,100b)
26904 + _ASM_EXTABLE(7b,100b)
26905 + _ASM_EXTABLE(8b,100b)
26906 + _ASM_EXTABLE(9b,100b)
26907 + _ASM_EXTABLE(10b,100b)
26908 + _ASM_EXTABLE(11b,100b)
26909 + _ASM_EXTABLE(12b,100b)
26910 + _ASM_EXTABLE(13b,100b)
26911 + _ASM_EXTABLE(14b,100b)
26912 + _ASM_EXTABLE(15b,100b)
26913 + _ASM_EXTABLE(16b,100b)
26914 + _ASM_EXTABLE(17b,100b)
26915 + _ASM_EXTABLE(18b,100b)
26916 + _ASM_EXTABLE(19b,100b)
26917 + _ASM_EXTABLE(20b,100b)
26918 + _ASM_EXTABLE(21b,100b)
26919 + _ASM_EXTABLE(22b,100b)
26920 + _ASM_EXTABLE(23b,100b)
26921 + _ASM_EXTABLE(24b,100b)
26922 + _ASM_EXTABLE(25b,100b)
26923 + _ASM_EXTABLE(26b,100b)
26924 + _ASM_EXTABLE(27b,100b)
26925 + _ASM_EXTABLE(28b,100b)
26926 + _ASM_EXTABLE(29b,100b)
26927 + _ASM_EXTABLE(30b,100b)
26928 + _ASM_EXTABLE(31b,100b)
26929 + _ASM_EXTABLE(32b,100b)
26930 + _ASM_EXTABLE(33b,100b)
26931 + _ASM_EXTABLE(34b,100b)
26932 + _ASM_EXTABLE(35b,100b)
26933 + _ASM_EXTABLE(36b,100b)
26934 + _ASM_EXTABLE(37b,100b)
26935 + _ASM_EXTABLE(99b,101b)
26936 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26937 + : "1"(to), "2"(from), "0"(size)
26938 + : "eax", "edx", "memory");
26939 + return size;
26940 +}
26941 +
26942 +static unsigned long __size_overflow(3)
26943 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26944 {
26945 int d0, d1;
26946 __asm__ __volatile__(
26947 " .align 2,0x90\n"
26948 - "0: movl 32(%4), %%eax\n"
26949 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26950 " cmpl $67, %0\n"
26951 " jbe 2f\n"
26952 - "1: movl 64(%4), %%eax\n"
26953 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26954 " .align 2,0x90\n"
26955 - "2: movl 0(%4), %%eax\n"
26956 - "21: movl 4(%4), %%edx\n"
26957 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26958 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26959 " movl %%eax, 0(%3)\n"
26960 " movl %%edx, 4(%3)\n"
26961 - "3: movl 8(%4), %%eax\n"
26962 - "31: movl 12(%4),%%edx\n"
26963 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26964 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26965 " movl %%eax, 8(%3)\n"
26966 " movl %%edx, 12(%3)\n"
26967 - "4: movl 16(%4), %%eax\n"
26968 - "41: movl 20(%4), %%edx\n"
26969 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26970 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26971 " movl %%eax, 16(%3)\n"
26972 " movl %%edx, 20(%3)\n"
26973 - "10: movl 24(%4), %%eax\n"
26974 - "51: movl 28(%4), %%edx\n"
26975 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26976 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26977 " movl %%eax, 24(%3)\n"
26978 " movl %%edx, 28(%3)\n"
26979 - "11: movl 32(%4), %%eax\n"
26980 - "61: movl 36(%4), %%edx\n"
26981 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26982 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26983 " movl %%eax, 32(%3)\n"
26984 " movl %%edx, 36(%3)\n"
26985 - "12: movl 40(%4), %%eax\n"
26986 - "71: movl 44(%4), %%edx\n"
26987 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26988 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26989 " movl %%eax, 40(%3)\n"
26990 " movl %%edx, 44(%3)\n"
26991 - "13: movl 48(%4), %%eax\n"
26992 - "81: movl 52(%4), %%edx\n"
26993 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26994 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26995 " movl %%eax, 48(%3)\n"
26996 " movl %%edx, 52(%3)\n"
26997 - "14: movl 56(%4), %%eax\n"
26998 - "91: movl 60(%4), %%edx\n"
26999 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27000 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27001 " movl %%eax, 56(%3)\n"
27002 " movl %%edx, 60(%3)\n"
27003 " addl $-64, %0\n"
27004 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27005 " shrl $2, %0\n"
27006 " andl $3, %%eax\n"
27007 " cld\n"
27008 - "6: rep; movsl\n"
27009 + "6: rep; "__copyuser_seg" movsl\n"
27010 " movl %%eax,%0\n"
27011 - "7: rep; movsb\n"
27012 + "7: rep; "__copyuser_seg" movsb\n"
27013 "8:\n"
27014 ".section .fixup,\"ax\"\n"
27015 "9: lea 0(%%eax,%0,4),%0\n"
27016 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27017 * hyoshiok@miraclelinux.com
27018 */
27019
27020 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27021 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
27022 const void __user *from, unsigned long size)
27023 {
27024 int d0, d1;
27025
27026 __asm__ __volatile__(
27027 " .align 2,0x90\n"
27028 - "0: movl 32(%4), %%eax\n"
27029 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27030 " cmpl $67, %0\n"
27031 " jbe 2f\n"
27032 - "1: movl 64(%4), %%eax\n"
27033 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27034 " .align 2,0x90\n"
27035 - "2: movl 0(%4), %%eax\n"
27036 - "21: movl 4(%4), %%edx\n"
27037 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27038 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27039 " movnti %%eax, 0(%3)\n"
27040 " movnti %%edx, 4(%3)\n"
27041 - "3: movl 8(%4), %%eax\n"
27042 - "31: movl 12(%4),%%edx\n"
27043 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27044 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27045 " movnti %%eax, 8(%3)\n"
27046 " movnti %%edx, 12(%3)\n"
27047 - "4: movl 16(%4), %%eax\n"
27048 - "41: movl 20(%4), %%edx\n"
27049 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27050 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27051 " movnti %%eax, 16(%3)\n"
27052 " movnti %%edx, 20(%3)\n"
27053 - "10: movl 24(%4), %%eax\n"
27054 - "51: movl 28(%4), %%edx\n"
27055 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27056 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27057 " movnti %%eax, 24(%3)\n"
27058 " movnti %%edx, 28(%3)\n"
27059 - "11: movl 32(%4), %%eax\n"
27060 - "61: movl 36(%4), %%edx\n"
27061 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27062 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27063 " movnti %%eax, 32(%3)\n"
27064 " movnti %%edx, 36(%3)\n"
27065 - "12: movl 40(%4), %%eax\n"
27066 - "71: movl 44(%4), %%edx\n"
27067 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27068 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27069 " movnti %%eax, 40(%3)\n"
27070 " movnti %%edx, 44(%3)\n"
27071 - "13: movl 48(%4), %%eax\n"
27072 - "81: movl 52(%4), %%edx\n"
27073 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27074 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27075 " movnti %%eax, 48(%3)\n"
27076 " movnti %%edx, 52(%3)\n"
27077 - "14: movl 56(%4), %%eax\n"
27078 - "91: movl 60(%4), %%edx\n"
27079 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27080 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27081 " movnti %%eax, 56(%3)\n"
27082 " movnti %%edx, 60(%3)\n"
27083 " addl $-64, %0\n"
27084 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27085 " shrl $2, %0\n"
27086 " andl $3, %%eax\n"
27087 " cld\n"
27088 - "6: rep; movsl\n"
27089 + "6: rep; "__copyuser_seg" movsl\n"
27090 " movl %%eax,%0\n"
27091 - "7: rep; movsb\n"
27092 + "7: rep; "__copyuser_seg" movsb\n"
27093 "8:\n"
27094 ".section .fixup,\"ax\"\n"
27095 "9: lea 0(%%eax,%0,4),%0\n"
27096 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27097 return size;
27098 }
27099
27100 -static unsigned long __copy_user_intel_nocache(void *to,
27101 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
27102 const void __user *from, unsigned long size)
27103 {
27104 int d0, d1;
27105
27106 __asm__ __volatile__(
27107 " .align 2,0x90\n"
27108 - "0: movl 32(%4), %%eax\n"
27109 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27110 " cmpl $67, %0\n"
27111 " jbe 2f\n"
27112 - "1: movl 64(%4), %%eax\n"
27113 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27114 " .align 2,0x90\n"
27115 - "2: movl 0(%4), %%eax\n"
27116 - "21: movl 4(%4), %%edx\n"
27117 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27118 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27119 " movnti %%eax, 0(%3)\n"
27120 " movnti %%edx, 4(%3)\n"
27121 - "3: movl 8(%4), %%eax\n"
27122 - "31: movl 12(%4),%%edx\n"
27123 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27124 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27125 " movnti %%eax, 8(%3)\n"
27126 " movnti %%edx, 12(%3)\n"
27127 - "4: movl 16(%4), %%eax\n"
27128 - "41: movl 20(%4), %%edx\n"
27129 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27130 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27131 " movnti %%eax, 16(%3)\n"
27132 " movnti %%edx, 20(%3)\n"
27133 - "10: movl 24(%4), %%eax\n"
27134 - "51: movl 28(%4), %%edx\n"
27135 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27136 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27137 " movnti %%eax, 24(%3)\n"
27138 " movnti %%edx, 28(%3)\n"
27139 - "11: movl 32(%4), %%eax\n"
27140 - "61: movl 36(%4), %%edx\n"
27141 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27142 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27143 " movnti %%eax, 32(%3)\n"
27144 " movnti %%edx, 36(%3)\n"
27145 - "12: movl 40(%4), %%eax\n"
27146 - "71: movl 44(%4), %%edx\n"
27147 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27148 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27149 " movnti %%eax, 40(%3)\n"
27150 " movnti %%edx, 44(%3)\n"
27151 - "13: movl 48(%4), %%eax\n"
27152 - "81: movl 52(%4), %%edx\n"
27153 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27154 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27155 " movnti %%eax, 48(%3)\n"
27156 " movnti %%edx, 52(%3)\n"
27157 - "14: movl 56(%4), %%eax\n"
27158 - "91: movl 60(%4), %%edx\n"
27159 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27160 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27161 " movnti %%eax, 56(%3)\n"
27162 " movnti %%edx, 60(%3)\n"
27163 " addl $-64, %0\n"
27164 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
27165 " shrl $2, %0\n"
27166 " andl $3, %%eax\n"
27167 " cld\n"
27168 - "6: rep; movsl\n"
27169 + "6: rep; "__copyuser_seg" movsl\n"
27170 " movl %%eax,%0\n"
27171 - "7: rep; movsb\n"
27172 + "7: rep; "__copyuser_seg" movsb\n"
27173 "8:\n"
27174 ".section .fixup,\"ax\"\n"
27175 "9: lea 0(%%eax,%0,4),%0\n"
27176 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
27177 */
27178 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
27179 unsigned long size);
27180 -unsigned long __copy_user_intel(void __user *to, const void *from,
27181 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
27182 + unsigned long size);
27183 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
27184 unsigned long size);
27185 unsigned long __copy_user_zeroing_intel_nocache(void *to,
27186 const void __user *from, unsigned long size);
27187 #endif /* CONFIG_X86_INTEL_USERCOPY */
27188
27189 /* Generic arbitrary sized copy. */
27190 -#define __copy_user(to, from, size) \
27191 +#define __copy_user(to, from, size, prefix, set, restore) \
27192 do { \
27193 int __d0, __d1, __d2; \
27194 __asm__ __volatile__( \
27195 + set \
27196 " cmp $7,%0\n" \
27197 " jbe 1f\n" \
27198 " movl %1,%0\n" \
27199 " negl %0\n" \
27200 " andl $7,%0\n" \
27201 " subl %0,%3\n" \
27202 - "4: rep; movsb\n" \
27203 + "4: rep; "prefix"movsb\n" \
27204 " movl %3,%0\n" \
27205 " shrl $2,%0\n" \
27206 " andl $3,%3\n" \
27207 " .align 2,0x90\n" \
27208 - "0: rep; movsl\n" \
27209 + "0: rep; "prefix"movsl\n" \
27210 " movl %3,%0\n" \
27211 - "1: rep; movsb\n" \
27212 + "1: rep; "prefix"movsb\n" \
27213 "2:\n" \
27214 + restore \
27215 ".section .fixup,\"ax\"\n" \
27216 "5: addl %3,%0\n" \
27217 " jmp 2b\n" \
27218 @@ -538,14 +650,14 @@ do { \
27219 " negl %0\n" \
27220 " andl $7,%0\n" \
27221 " subl %0,%3\n" \
27222 - "4: rep; movsb\n" \
27223 + "4: rep; "__copyuser_seg"movsb\n" \
27224 " movl %3,%0\n" \
27225 " shrl $2,%0\n" \
27226 " andl $3,%3\n" \
27227 " .align 2,0x90\n" \
27228 - "0: rep; movsl\n" \
27229 + "0: rep; "__copyuser_seg"movsl\n" \
27230 " movl %3,%0\n" \
27231 - "1: rep; movsb\n" \
27232 + "1: rep; "__copyuser_seg"movsb\n" \
27233 "2:\n" \
27234 ".section .fixup,\"ax\"\n" \
27235 "5: addl %3,%0\n" \
27236 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
27237 {
27238 stac();
27239 if (movsl_is_ok(to, from, n))
27240 - __copy_user(to, from, n);
27241 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
27242 else
27243 - n = __copy_user_intel(to, from, n);
27244 + n = __generic_copy_to_user_intel(to, from, n);
27245 clac();
27246 return n;
27247 }
27248 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27249 {
27250 stac();
27251 if (movsl_is_ok(to, from, n))
27252 - __copy_user(to, from, n);
27253 + __copy_user(to, from, n, __copyuser_seg, "", "");
27254 else
27255 - n = __copy_user_intel((void __user *)to,
27256 - (const void *)from, n);
27257 + n = __generic_copy_from_user_intel(to, from, n);
27258 clac();
27259 return n;
27260 }
27261 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27262 if (n > 64 && cpu_has_xmm2)
27263 n = __copy_user_intel_nocache(to, from, n);
27264 else
27265 - __copy_user(to, from, n);
27266 + __copy_user(to, from, n, __copyuser_seg, "", "");
27267 #else
27268 - __copy_user(to, from, n);
27269 + __copy_user(to, from, n, __copyuser_seg, "", "");
27270 #endif
27271 clac();
27272 return n;
27273 }
27274 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27275
27276 -/**
27277 - * copy_to_user: - Copy a block of data into user space.
27278 - * @to: Destination address, in user space.
27279 - * @from: Source address, in kernel space.
27280 - * @n: Number of bytes to copy.
27281 - *
27282 - * Context: User context only. This function may sleep.
27283 - *
27284 - * Copy data from kernel space to user space.
27285 - *
27286 - * Returns number of bytes that could not be copied.
27287 - * On success, this will be zero.
27288 - */
27289 -unsigned long
27290 -copy_to_user(void __user *to, const void *from, unsigned long n)
27291 -{
27292 - if (access_ok(VERIFY_WRITE, to, n))
27293 - n = __copy_to_user(to, from, n);
27294 - return n;
27295 -}
27296 -EXPORT_SYMBOL(copy_to_user);
27297 -
27298 -/**
27299 - * copy_from_user: - Copy a block of data from user space.
27300 - * @to: Destination address, in kernel space.
27301 - * @from: Source address, in user space.
27302 - * @n: Number of bytes to copy.
27303 - *
27304 - * Context: User context only. This function may sleep.
27305 - *
27306 - * Copy data from user space to kernel space.
27307 - *
27308 - * Returns number of bytes that could not be copied.
27309 - * On success, this will be zero.
27310 - *
27311 - * If some data could not be copied, this function will pad the copied
27312 - * data to the requested size using zero bytes.
27313 - */
27314 -unsigned long
27315 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27316 -{
27317 - if (access_ok(VERIFY_READ, from, n))
27318 - n = __copy_from_user(to, from, n);
27319 - else
27320 - memset(to, 0, n);
27321 - return n;
27322 -}
27323 -EXPORT_SYMBOL(_copy_from_user);
27324 -
27325 void copy_from_user_overflow(void)
27326 {
27327 WARN(1, "Buffer overflow detected!\n");
27328 }
27329 EXPORT_SYMBOL(copy_from_user_overflow);
27330 +
27331 +void copy_to_user_overflow(void)
27332 +{
27333 + WARN(1, "Buffer overflow detected!\n");
27334 +}
27335 +EXPORT_SYMBOL(copy_to_user_overflow);
27336 +
27337 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27338 +void __set_fs(mm_segment_t x)
27339 +{
27340 + switch (x.seg) {
27341 + case 0:
27342 + loadsegment(gs, 0);
27343 + break;
27344 + case TASK_SIZE_MAX:
27345 + loadsegment(gs, __USER_DS);
27346 + break;
27347 + case -1UL:
27348 + loadsegment(gs, __KERNEL_DS);
27349 + break;
27350 + default:
27351 + BUG();
27352 + }
27353 + return;
27354 +}
27355 +EXPORT_SYMBOL(__set_fs);
27356 +
27357 +void set_fs(mm_segment_t x)
27358 +{
27359 + current_thread_info()->addr_limit = x;
27360 + __set_fs(x);
27361 +}
27362 +EXPORT_SYMBOL(set_fs);
27363 +#endif
27364 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27365 index 906fea3..ee8a097 100644
27366 --- a/arch/x86/lib/usercopy_64.c
27367 +++ b/arch/x86/lib/usercopy_64.c
27368 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27369 _ASM_EXTABLE(0b,3b)
27370 _ASM_EXTABLE(1b,2b)
27371 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27372 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27373 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27374 [zero] "r" (0UL), [eight] "r" (8UL));
27375 clac();
27376 return size;
27377 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27378 }
27379 EXPORT_SYMBOL(clear_user);
27380
27381 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27382 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27383 {
27384 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27385 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27386 - }
27387 - return len;
27388 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27389 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27390 + return len;
27391 }
27392 EXPORT_SYMBOL(copy_in_user);
27393
27394 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27395 * it is not necessary to optimize tail handling.
27396 */
27397 unsigned long
27398 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27399 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27400 {
27401 char c;
27402 unsigned zero_len;
27403 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27404 clac();
27405 return len;
27406 }
27407 +
27408 +void copy_from_user_overflow(void)
27409 +{
27410 + WARN(1, "Buffer overflow detected!\n");
27411 +}
27412 +EXPORT_SYMBOL(copy_from_user_overflow);
27413 +
27414 +void copy_to_user_overflow(void)
27415 +{
27416 + WARN(1, "Buffer overflow detected!\n");
27417 +}
27418 +EXPORT_SYMBOL(copy_to_user_overflow);
27419 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27420 index 903ec1e..c4166b2 100644
27421 --- a/arch/x86/mm/extable.c
27422 +++ b/arch/x86/mm/extable.c
27423 @@ -6,12 +6,24 @@
27424 static inline unsigned long
27425 ex_insn_addr(const struct exception_table_entry *x)
27426 {
27427 - return (unsigned long)&x->insn + x->insn;
27428 + unsigned long reloc = 0;
27429 +
27430 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27431 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27432 +#endif
27433 +
27434 + return (unsigned long)&x->insn + x->insn + reloc;
27435 }
27436 static inline unsigned long
27437 ex_fixup_addr(const struct exception_table_entry *x)
27438 {
27439 - return (unsigned long)&x->fixup + x->fixup;
27440 + unsigned long reloc = 0;
27441 +
27442 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27443 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27444 +#endif
27445 +
27446 + return (unsigned long)&x->fixup + x->fixup + reloc;
27447 }
27448
27449 int fixup_exception(struct pt_regs *regs)
27450 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27451 unsigned long new_ip;
27452
27453 #ifdef CONFIG_PNPBIOS
27454 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27455 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27456 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27457 extern u32 pnp_bios_is_utter_crap;
27458 pnp_bios_is_utter_crap = 1;
27459 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27460 i += 4;
27461 p->fixup -= i;
27462 i += 4;
27463 +
27464 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27465 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27466 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27467 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27468 +#endif
27469 +
27470 }
27471 }
27472
27473 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27474 index fb674fd..223a693 100644
27475 --- a/arch/x86/mm/fault.c
27476 +++ b/arch/x86/mm/fault.c
27477 @@ -13,12 +13,19 @@
27478 #include <linux/perf_event.h> /* perf_sw_event */
27479 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27480 #include <linux/prefetch.h> /* prefetchw */
27481 +#include <linux/unistd.h>
27482 +#include <linux/compiler.h>
27483
27484 #include <asm/traps.h> /* dotraplinkage, ... */
27485 #include <asm/pgalloc.h> /* pgd_*(), ... */
27486 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27487 #include <asm/fixmap.h> /* VSYSCALL_START */
27488 #include <asm/context_tracking.h> /* exception_enter(), ... */
27489 +#include <asm/tlbflush.h>
27490 +
27491 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27492 +#include <asm/stacktrace.h>
27493 +#endif
27494
27495 /*
27496 * Page fault error code bits:
27497 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27498 int ret = 0;
27499
27500 /* kprobe_running() needs smp_processor_id() */
27501 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27502 + if (kprobes_built_in() && !user_mode(regs)) {
27503 preempt_disable();
27504 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27505 ret = 1;
27506 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27507 return !instr_lo || (instr_lo>>1) == 1;
27508 case 0x00:
27509 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27510 - if (probe_kernel_address(instr, opcode))
27511 + if (user_mode(regs)) {
27512 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27513 + return 0;
27514 + } else if (probe_kernel_address(instr, opcode))
27515 return 0;
27516
27517 *prefetch = (instr_lo == 0xF) &&
27518 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27519 while (instr < max_instr) {
27520 unsigned char opcode;
27521
27522 - if (probe_kernel_address(instr, opcode))
27523 + if (user_mode(regs)) {
27524 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27525 + break;
27526 + } else if (probe_kernel_address(instr, opcode))
27527 break;
27528
27529 instr++;
27530 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27531 force_sig_info(si_signo, &info, tsk);
27532 }
27533
27534 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27535 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27536 +#endif
27537 +
27538 +#ifdef CONFIG_PAX_EMUTRAMP
27539 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27540 +#endif
27541 +
27542 +#ifdef CONFIG_PAX_PAGEEXEC
27543 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27544 +{
27545 + pgd_t *pgd;
27546 + pud_t *pud;
27547 + pmd_t *pmd;
27548 +
27549 + pgd = pgd_offset(mm, address);
27550 + if (!pgd_present(*pgd))
27551 + return NULL;
27552 + pud = pud_offset(pgd, address);
27553 + if (!pud_present(*pud))
27554 + return NULL;
27555 + pmd = pmd_offset(pud, address);
27556 + if (!pmd_present(*pmd))
27557 + return NULL;
27558 + return pmd;
27559 +}
27560 +#endif
27561 +
27562 DEFINE_SPINLOCK(pgd_lock);
27563 LIST_HEAD(pgd_list);
27564
27565 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27566 for (address = VMALLOC_START & PMD_MASK;
27567 address >= TASK_SIZE && address < FIXADDR_TOP;
27568 address += PMD_SIZE) {
27569 +
27570 +#ifdef CONFIG_PAX_PER_CPU_PGD
27571 + unsigned long cpu;
27572 +#else
27573 struct page *page;
27574 +#endif
27575
27576 spin_lock(&pgd_lock);
27577 +
27578 +#ifdef CONFIG_PAX_PER_CPU_PGD
27579 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27580 + pgd_t *pgd = get_cpu_pgd(cpu);
27581 + pmd_t *ret;
27582 +#else
27583 list_for_each_entry(page, &pgd_list, lru) {
27584 + pgd_t *pgd;
27585 spinlock_t *pgt_lock;
27586 pmd_t *ret;
27587
27588 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27589 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27590
27591 spin_lock(pgt_lock);
27592 - ret = vmalloc_sync_one(page_address(page), address);
27593 + pgd = page_address(page);
27594 +#endif
27595 +
27596 + ret = vmalloc_sync_one(pgd, address);
27597 +
27598 +#ifndef CONFIG_PAX_PER_CPU_PGD
27599 spin_unlock(pgt_lock);
27600 +#endif
27601
27602 if (!ret)
27603 break;
27604 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27605 * an interrupt in the middle of a task switch..
27606 */
27607 pgd_paddr = read_cr3();
27608 +
27609 +#ifdef CONFIG_PAX_PER_CPU_PGD
27610 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27611 +#endif
27612 +
27613 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27614 if (!pmd_k)
27615 return -1;
27616 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27617 * happen within a race in page table update. In the later
27618 * case just flush:
27619 */
27620 +
27621 +#ifdef CONFIG_PAX_PER_CPU_PGD
27622 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27623 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27624 +#else
27625 pgd = pgd_offset(current->active_mm, address);
27626 +#endif
27627 +
27628 pgd_ref = pgd_offset_k(address);
27629 if (pgd_none(*pgd_ref))
27630 return -1;
27631 @@ -541,7 +612,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27632 static int is_errata100(struct pt_regs *regs, unsigned long address)
27633 {
27634 #ifdef CONFIG_X86_64
27635 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27636 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27637 return 1;
27638 #endif
27639 return 0;
27640 @@ -568,7 +639,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27641 }
27642
27643 static const char nx_warning[] = KERN_CRIT
27644 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27645 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27646
27647 static void
27648 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27649 @@ -577,15 +648,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27650 if (!oops_may_print())
27651 return;
27652
27653 - if (error_code & PF_INSTR) {
27654 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27655 unsigned int level;
27656
27657 pte_t *pte = lookup_address(address, &level);
27658
27659 if (pte && pte_present(*pte) && !pte_exec(*pte))
27660 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27661 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27662 }
27663
27664 +#ifdef CONFIG_PAX_KERNEXEC
27665 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27666 + if (current->signal->curr_ip)
27667 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27668 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27669 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27670 + else
27671 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27672 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27673 + }
27674 +#endif
27675 +
27676 printk(KERN_ALERT "BUG: unable to handle kernel ");
27677 if (address < PAGE_SIZE)
27678 printk(KERN_CONT "NULL pointer dereference");
27679 @@ -748,6 +831,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27680 return;
27681 }
27682 #endif
27683 +
27684 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27685 + if (pax_is_fetch_fault(regs, error_code, address)) {
27686 +
27687 +#ifdef CONFIG_PAX_EMUTRAMP
27688 + switch (pax_handle_fetch_fault(regs)) {
27689 + case 2:
27690 + return;
27691 + }
27692 +#endif
27693 +
27694 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27695 + do_group_exit(SIGKILL);
27696 + }
27697 +#endif
27698 +
27699 /* Kernel addresses are always protection faults: */
27700 if (address >= TASK_SIZE)
27701 error_code |= PF_PROT;
27702 @@ -833,7 +932,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27703 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27704 printk(KERN_ERR
27705 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27706 - tsk->comm, tsk->pid, address);
27707 + tsk->comm, task_pid_nr(tsk), address);
27708 code = BUS_MCEERR_AR;
27709 }
27710 #endif
27711 @@ -896,6 +995,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27712 return 1;
27713 }
27714
27715 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27716 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27717 +{
27718 + pte_t *pte;
27719 + pmd_t *pmd;
27720 + spinlock_t *ptl;
27721 + unsigned char pte_mask;
27722 +
27723 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27724 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27725 + return 0;
27726 +
27727 + /* PaX: it's our fault, let's handle it if we can */
27728 +
27729 + /* PaX: take a look at read faults before acquiring any locks */
27730 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27731 + /* instruction fetch attempt from a protected page in user mode */
27732 + up_read(&mm->mmap_sem);
27733 +
27734 +#ifdef CONFIG_PAX_EMUTRAMP
27735 + switch (pax_handle_fetch_fault(regs)) {
27736 + case 2:
27737 + return 1;
27738 + }
27739 +#endif
27740 +
27741 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27742 + do_group_exit(SIGKILL);
27743 + }
27744 +
27745 + pmd = pax_get_pmd(mm, address);
27746 + if (unlikely(!pmd))
27747 + return 0;
27748 +
27749 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27750 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27751 + pte_unmap_unlock(pte, ptl);
27752 + return 0;
27753 + }
27754 +
27755 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27756 + /* write attempt to a protected page in user mode */
27757 + pte_unmap_unlock(pte, ptl);
27758 + return 0;
27759 + }
27760 +
27761 +#ifdef CONFIG_SMP
27762 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27763 +#else
27764 + if (likely(address > get_limit(regs->cs)))
27765 +#endif
27766 + {
27767 + set_pte(pte, pte_mkread(*pte));
27768 + __flush_tlb_one(address);
27769 + pte_unmap_unlock(pte, ptl);
27770 + up_read(&mm->mmap_sem);
27771 + return 1;
27772 + }
27773 +
27774 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27775 +
27776 + /*
27777 + * PaX: fill DTLB with user rights and retry
27778 + */
27779 + __asm__ __volatile__ (
27780 + "orb %2,(%1)\n"
27781 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27782 +/*
27783 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27784 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27785 + * page fault when examined during a TLB load attempt. this is true not only
27786 + * for PTEs holding a non-present entry but also present entries that will
27787 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27788 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27789 + * for our target pages since their PTEs are simply not in the TLBs at all.
27790 +
27791 + * the best thing in omitting it is that we gain around 15-20% speed in the
27792 + * fast path of the page fault handler and can get rid of tracing since we
27793 + * can no longer flush unintended entries.
27794 + */
27795 + "invlpg (%0)\n"
27796 +#endif
27797 + __copyuser_seg"testb $0,(%0)\n"
27798 + "xorb %3,(%1)\n"
27799 + :
27800 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27801 + : "memory", "cc");
27802 + pte_unmap_unlock(pte, ptl);
27803 + up_read(&mm->mmap_sem);
27804 + return 1;
27805 +}
27806 +#endif
27807 +
27808 /*
27809 * Handle a spurious fault caused by a stale TLB entry.
27810 *
27811 @@ -968,6 +1160,9 @@ int show_unhandled_signals = 1;
27812 static inline int
27813 access_error(unsigned long error_code, struct vm_area_struct *vma)
27814 {
27815 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27816 + return 1;
27817 +
27818 if (error_code & PF_WRITE) {
27819 /* write, present and write, not present: */
27820 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27821 @@ -996,7 +1191,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27822 if (error_code & PF_USER)
27823 return false;
27824
27825 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27826 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27827 return false;
27828
27829 return true;
27830 @@ -1012,18 +1207,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27831 {
27832 struct vm_area_struct *vma;
27833 struct task_struct *tsk;
27834 - unsigned long address;
27835 struct mm_struct *mm;
27836 int fault;
27837 int write = error_code & PF_WRITE;
27838 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27839 (write ? FAULT_FLAG_WRITE : 0);
27840
27841 - tsk = current;
27842 - mm = tsk->mm;
27843 -
27844 /* Get the faulting address: */
27845 - address = read_cr2();
27846 + unsigned long address = read_cr2();
27847 +
27848 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27849 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
27850 + if (!search_exception_tables(regs->ip)) {
27851 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27852 + bad_area_nosemaphore(regs, error_code, address);
27853 + return;
27854 + }
27855 + if (address < PAX_USER_SHADOW_BASE) {
27856 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27857 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27858 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27859 + } else
27860 + address -= PAX_USER_SHADOW_BASE;
27861 + }
27862 +#endif
27863 +
27864 + tsk = current;
27865 + mm = tsk->mm;
27866
27867 /*
27868 * Detect and handle instructions that would cause a page fault for
27869 @@ -1084,7 +1294,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27870 * User-mode registers count as a user access even for any
27871 * potential system fault or CPU buglet:
27872 */
27873 - if (user_mode_vm(regs)) {
27874 + if (user_mode(regs)) {
27875 local_irq_enable();
27876 error_code |= PF_USER;
27877 } else {
27878 @@ -1146,6 +1356,11 @@ retry:
27879 might_sleep();
27880 }
27881
27882 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27883 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27884 + return;
27885 +#endif
27886 +
27887 vma = find_vma(mm, address);
27888 if (unlikely(!vma)) {
27889 bad_area(regs, error_code, address);
27890 @@ -1157,18 +1372,24 @@ retry:
27891 bad_area(regs, error_code, address);
27892 return;
27893 }
27894 - if (error_code & PF_USER) {
27895 - /*
27896 - * Accessing the stack below %sp is always a bug.
27897 - * The large cushion allows instructions like enter
27898 - * and pusha to work. ("enter $65535, $31" pushes
27899 - * 32 pointers and then decrements %sp by 65535.)
27900 - */
27901 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27902 - bad_area(regs, error_code, address);
27903 - return;
27904 - }
27905 + /*
27906 + * Accessing the stack below %sp is always a bug.
27907 + * The large cushion allows instructions like enter
27908 + * and pusha to work. ("enter $65535, $31" pushes
27909 + * 32 pointers and then decrements %sp by 65535.)
27910 + */
27911 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27912 + bad_area(regs, error_code, address);
27913 + return;
27914 }
27915 +
27916 +#ifdef CONFIG_PAX_SEGMEXEC
27917 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27918 + bad_area(regs, error_code, address);
27919 + return;
27920 + }
27921 +#endif
27922 +
27923 if (unlikely(expand_stack(vma, address))) {
27924 bad_area(regs, error_code, address);
27925 return;
27926 @@ -1232,3 +1453,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27927 __do_page_fault(regs, error_code);
27928 exception_exit(regs);
27929 }
27930 +
27931 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27932 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27933 +{
27934 + struct mm_struct *mm = current->mm;
27935 + unsigned long ip = regs->ip;
27936 +
27937 + if (v8086_mode(regs))
27938 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27939 +
27940 +#ifdef CONFIG_PAX_PAGEEXEC
27941 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27942 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27943 + return true;
27944 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27945 + return true;
27946 + return false;
27947 + }
27948 +#endif
27949 +
27950 +#ifdef CONFIG_PAX_SEGMEXEC
27951 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27952 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27953 + return true;
27954 + return false;
27955 + }
27956 +#endif
27957 +
27958 + return false;
27959 +}
27960 +#endif
27961 +
27962 +#ifdef CONFIG_PAX_EMUTRAMP
27963 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27964 +{
27965 + int err;
27966 +
27967 + do { /* PaX: libffi trampoline emulation */
27968 + unsigned char mov, jmp;
27969 + unsigned int addr1, addr2;
27970 +
27971 +#ifdef CONFIG_X86_64
27972 + if ((regs->ip + 9) >> 32)
27973 + break;
27974 +#endif
27975 +
27976 + err = get_user(mov, (unsigned char __user *)regs->ip);
27977 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27978 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27979 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27980 +
27981 + if (err)
27982 + break;
27983 +
27984 + if (mov == 0xB8 && jmp == 0xE9) {
27985 + regs->ax = addr1;
27986 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27987 + return 2;
27988 + }
27989 + } while (0);
27990 +
27991 + do { /* PaX: gcc trampoline emulation #1 */
27992 + unsigned char mov1, mov2;
27993 + unsigned short jmp;
27994 + unsigned int addr1, addr2;
27995 +
27996 +#ifdef CONFIG_X86_64
27997 + if ((regs->ip + 11) >> 32)
27998 + break;
27999 +#endif
28000 +
28001 + err = get_user(mov1, (unsigned char __user *)regs->ip);
28002 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28003 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
28004 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28005 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
28006 +
28007 + if (err)
28008 + break;
28009 +
28010 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
28011 + regs->cx = addr1;
28012 + regs->ax = addr2;
28013 + regs->ip = addr2;
28014 + return 2;
28015 + }
28016 + } while (0);
28017 +
28018 + do { /* PaX: gcc trampoline emulation #2 */
28019 + unsigned char mov, jmp;
28020 + unsigned int addr1, addr2;
28021 +
28022 +#ifdef CONFIG_X86_64
28023 + if ((regs->ip + 9) >> 32)
28024 + break;
28025 +#endif
28026 +
28027 + err = get_user(mov, (unsigned char __user *)regs->ip);
28028 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28029 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
28030 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28031 +
28032 + if (err)
28033 + break;
28034 +
28035 + if (mov == 0xB9 && jmp == 0xE9) {
28036 + regs->cx = addr1;
28037 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
28038 + return 2;
28039 + }
28040 + } while (0);
28041 +
28042 + return 1; /* PaX in action */
28043 +}
28044 +
28045 +#ifdef CONFIG_X86_64
28046 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
28047 +{
28048 + int err;
28049 +
28050 + do { /* PaX: libffi trampoline emulation */
28051 + unsigned short mov1, mov2, jmp1;
28052 + unsigned char stcclc, jmp2;
28053 + unsigned long addr1, addr2;
28054 +
28055 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28056 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28057 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28058 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28059 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
28060 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
28061 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
28062 +
28063 + if (err)
28064 + break;
28065 +
28066 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28067 + regs->r11 = addr1;
28068 + regs->r10 = addr2;
28069 + if (stcclc == 0xF8)
28070 + regs->flags &= ~X86_EFLAGS_CF;
28071 + else
28072 + regs->flags |= X86_EFLAGS_CF;
28073 + regs->ip = addr1;
28074 + return 2;
28075 + }
28076 + } while (0);
28077 +
28078 + do { /* PaX: gcc trampoline emulation #1 */
28079 + unsigned short mov1, mov2, jmp1;
28080 + unsigned char jmp2;
28081 + unsigned int addr1;
28082 + unsigned long addr2;
28083 +
28084 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28085 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
28086 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
28087 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
28088 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
28089 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
28090 +
28091 + if (err)
28092 + break;
28093 +
28094 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28095 + regs->r11 = addr1;
28096 + regs->r10 = addr2;
28097 + regs->ip = addr1;
28098 + return 2;
28099 + }
28100 + } while (0);
28101 +
28102 + do { /* PaX: gcc trampoline emulation #2 */
28103 + unsigned short mov1, mov2, jmp1;
28104 + unsigned char jmp2;
28105 + unsigned long addr1, addr2;
28106 +
28107 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28108 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28109 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28110 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28111 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
28112 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
28113 +
28114 + if (err)
28115 + break;
28116 +
28117 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28118 + regs->r11 = addr1;
28119 + regs->r10 = addr2;
28120 + regs->ip = addr1;
28121 + return 2;
28122 + }
28123 + } while (0);
28124 +
28125 + return 1; /* PaX in action */
28126 +}
28127 +#endif
28128 +
28129 +/*
28130 + * PaX: decide what to do with offenders (regs->ip = fault address)
28131 + *
28132 + * returns 1 when task should be killed
28133 + * 2 when gcc trampoline was detected
28134 + */
28135 +static int pax_handle_fetch_fault(struct pt_regs *regs)
28136 +{
28137 + if (v8086_mode(regs))
28138 + return 1;
28139 +
28140 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
28141 + return 1;
28142 +
28143 +#ifdef CONFIG_X86_32
28144 + return pax_handle_fetch_fault_32(regs);
28145 +#else
28146 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
28147 + return pax_handle_fetch_fault_32(regs);
28148 + else
28149 + return pax_handle_fetch_fault_64(regs);
28150 +#endif
28151 +}
28152 +#endif
28153 +
28154 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28155 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
28156 +{
28157 + long i;
28158 +
28159 + printk(KERN_ERR "PAX: bytes at PC: ");
28160 + for (i = 0; i < 20; i++) {
28161 + unsigned char c;
28162 + if (get_user(c, (unsigned char __force_user *)pc+i))
28163 + printk(KERN_CONT "?? ");
28164 + else
28165 + printk(KERN_CONT "%02x ", c);
28166 + }
28167 + printk("\n");
28168 +
28169 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
28170 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
28171 + unsigned long c;
28172 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
28173 +#ifdef CONFIG_X86_32
28174 + printk(KERN_CONT "???????? ");
28175 +#else
28176 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
28177 + printk(KERN_CONT "???????? ???????? ");
28178 + else
28179 + printk(KERN_CONT "???????????????? ");
28180 +#endif
28181 + } else {
28182 +#ifdef CONFIG_X86_64
28183 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
28184 + printk(KERN_CONT "%08x ", (unsigned int)c);
28185 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
28186 + } else
28187 +#endif
28188 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
28189 + }
28190 + }
28191 + printk("\n");
28192 +}
28193 +#endif
28194 +
28195 +/**
28196 + * probe_kernel_write(): safely attempt to write to a location
28197 + * @dst: address to write to
28198 + * @src: pointer to the data that shall be written
28199 + * @size: size of the data chunk
28200 + *
28201 + * Safely write to address @dst from the buffer at @src. If a kernel fault
28202 + * happens, handle that and return -EFAULT.
28203 + */
28204 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
28205 +{
28206 + long ret;
28207 + mm_segment_t old_fs = get_fs();
28208 +
28209 + set_fs(KERNEL_DS);
28210 + pagefault_disable();
28211 + pax_open_kernel();
28212 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
28213 + pax_close_kernel();
28214 + pagefault_enable();
28215 + set_fs(old_fs);
28216 +
28217 + return ret ? -EFAULT : 0;
28218 +}
28219 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
28220 index dd74e46..7d26398 100644
28221 --- a/arch/x86/mm/gup.c
28222 +++ b/arch/x86/mm/gup.c
28223 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
28224 addr = start;
28225 len = (unsigned long) nr_pages << PAGE_SHIFT;
28226 end = start + len;
28227 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28228 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28229 (void __user *)start, len)))
28230 return 0;
28231
28232 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
28233 index 6f31ee5..8ee4164 100644
28234 --- a/arch/x86/mm/highmem_32.c
28235 +++ b/arch/x86/mm/highmem_32.c
28236 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
28237 idx = type + KM_TYPE_NR*smp_processor_id();
28238 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28239 BUG_ON(!pte_none(*(kmap_pte-idx)));
28240 +
28241 + pax_open_kernel();
28242 set_pte(kmap_pte-idx, mk_pte(page, prot));
28243 + pax_close_kernel();
28244 +
28245 arch_flush_lazy_mmu_mode();
28246
28247 return (void *)vaddr;
28248 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
28249 index ae1aa71..56316db 100644
28250 --- a/arch/x86/mm/hugetlbpage.c
28251 +++ b/arch/x86/mm/hugetlbpage.c
28252 @@ -279,6 +279,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
28253 info.flags = 0;
28254 info.length = len;
28255 info.low_limit = TASK_UNMAPPED_BASE;
28256 +
28257 +#ifdef CONFIG_PAX_RANDMMAP
28258 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28259 + info.low_limit += current->mm->delta_mmap;
28260 +#endif
28261 +
28262 info.high_limit = TASK_SIZE;
28263 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28264 info.align_offset = 0;
28265 @@ -311,6 +317,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28266 VM_BUG_ON(addr != -ENOMEM);
28267 info.flags = 0;
28268 info.low_limit = TASK_UNMAPPED_BASE;
28269 +
28270 +#ifdef CONFIG_PAX_RANDMMAP
28271 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28272 + info.low_limit += current->mm->delta_mmap;
28273 +#endif
28274 +
28275 info.high_limit = TASK_SIZE;
28276 addr = vm_unmapped_area(&info);
28277 }
28278 @@ -325,10 +337,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28279 struct hstate *h = hstate_file(file);
28280 struct mm_struct *mm = current->mm;
28281 struct vm_area_struct *vma;
28282 + unsigned long pax_task_size = TASK_SIZE;
28283 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28284
28285 if (len & ~huge_page_mask(h))
28286 return -EINVAL;
28287 - if (len > TASK_SIZE)
28288 +
28289 +#ifdef CONFIG_PAX_SEGMEXEC
28290 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28291 + pax_task_size = SEGMEXEC_TASK_SIZE;
28292 +#endif
28293 +
28294 + pax_task_size -= PAGE_SIZE;
28295 +
28296 + if (len > pax_task_size)
28297 return -ENOMEM;
28298
28299 if (flags & MAP_FIXED) {
28300 @@ -337,11 +359,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28301 return addr;
28302 }
28303
28304 +#ifdef CONFIG_PAX_RANDMMAP
28305 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28306 +#endif
28307 +
28308 if (addr) {
28309 addr = ALIGN(addr, huge_page_size(h));
28310 vma = find_vma(mm, addr);
28311 - if (TASK_SIZE - len >= addr &&
28312 - (!vma || addr + len <= vma->vm_start))
28313 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28314 return addr;
28315 }
28316 if (mm->get_unmapped_area == arch_get_unmapped_area)
28317 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28318 index d7aea41..0fc945b 100644
28319 --- a/arch/x86/mm/init.c
28320 +++ b/arch/x86/mm/init.c
28321 @@ -4,6 +4,7 @@
28322 #include <linux/swap.h>
28323 #include <linux/memblock.h>
28324 #include <linux/bootmem.h> /* for max_low_pfn */
28325 +#include <linux/tboot.h>
28326
28327 #include <asm/cacheflush.h>
28328 #include <asm/e820.h>
28329 @@ -16,6 +17,8 @@
28330 #include <asm/tlb.h>
28331 #include <asm/proto.h>
28332 #include <asm/dma.h> /* for MAX_DMA_PFN */
28333 +#include <asm/desc.h>
28334 +#include <asm/bios_ebda.h>
28335
28336 unsigned long __initdata pgt_buf_start;
28337 unsigned long __meminitdata pgt_buf_end;
28338 @@ -44,7 +47,7 @@ static void __init find_early_table_space(struct map_range *mr, int nr_range)
28339 {
28340 int i;
28341 unsigned long puds = 0, pmds = 0, ptes = 0, tables;
28342 - unsigned long start = 0, good_end;
28343 + unsigned long start = 0x100000, good_end;
28344 phys_addr_t base;
28345
28346 for (i = 0; i < nr_range; i++) {
28347 @@ -321,10 +324,40 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
28348 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28349 * mmio resources as well as potential bios/acpi data regions.
28350 */
28351 +
28352 +#ifdef CONFIG_GRKERNSEC_KMEM
28353 +static unsigned int ebda_start __read_only;
28354 +static unsigned int ebda_end __read_only;
28355 +#endif
28356 +
28357 int devmem_is_allowed(unsigned long pagenr)
28358 {
28359 - if (pagenr < 256)
28360 +#ifdef CONFIG_GRKERNSEC_KMEM
28361 + /* allow BDA */
28362 + if (!pagenr)
28363 return 1;
28364 + /* allow EBDA */
28365 + if (pagenr >= ebda_start && pagenr < ebda_end)
28366 + return 1;
28367 + /* if tboot is in use, allow access to its hardcoded serial log range */
28368 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28369 + return 1;
28370 +#else
28371 + if (!pagenr)
28372 + return 1;
28373 +#ifdef CONFIG_VM86
28374 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28375 + return 1;
28376 +#endif
28377 +#endif
28378 +
28379 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28380 + return 1;
28381 +#ifdef CONFIG_GRKERNSEC_KMEM
28382 + /* throw out everything else below 1MB */
28383 + if (pagenr <= 256)
28384 + return 0;
28385 +#endif
28386 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28387 return 0;
28388 if (!page_is_ram(pagenr))
28389 @@ -381,8 +414,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28390 #endif
28391 }
28392
28393 +#ifdef CONFIG_GRKERNSEC_KMEM
28394 +static inline void gr_init_ebda(void)
28395 +{
28396 + unsigned int ebda_addr;
28397 + unsigned int ebda_size = 0;
28398 +
28399 + ebda_addr = get_bios_ebda();
28400 + if (ebda_addr) {
28401 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28402 + ebda_size <<= 10;
28403 + }
28404 + if (ebda_addr && ebda_size) {
28405 + ebda_start = ebda_addr >> PAGE_SHIFT;
28406 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28407 + } else {
28408 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28409 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28410 + }
28411 +}
28412 +#else
28413 +static inline void gr_init_ebda(void) { }
28414 +#endif
28415 +
28416 void free_initmem(void)
28417 {
28418 +#ifdef CONFIG_PAX_KERNEXEC
28419 +#ifdef CONFIG_X86_32
28420 + /* PaX: limit KERNEL_CS to actual size */
28421 + unsigned long addr, limit;
28422 + struct desc_struct d;
28423 + int cpu;
28424 +#else
28425 + pgd_t *pgd;
28426 + pud_t *pud;
28427 + pmd_t *pmd;
28428 + unsigned long addr, end;
28429 +#endif
28430 +#endif
28431 +
28432 + gr_init_ebda();
28433 +
28434 +#ifdef CONFIG_PAX_KERNEXEC
28435 +#ifdef CONFIG_X86_32
28436 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28437 + limit = (limit - 1UL) >> PAGE_SHIFT;
28438 +
28439 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28440 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28441 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28442 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28443 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28444 + }
28445 +
28446 + /* PaX: make KERNEL_CS read-only */
28447 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28448 + if (!paravirt_enabled())
28449 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28450 +/*
28451 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28452 + pgd = pgd_offset_k(addr);
28453 + pud = pud_offset(pgd, addr);
28454 + pmd = pmd_offset(pud, addr);
28455 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28456 + }
28457 +*/
28458 +#ifdef CONFIG_X86_PAE
28459 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28460 +/*
28461 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28462 + pgd = pgd_offset_k(addr);
28463 + pud = pud_offset(pgd, addr);
28464 + pmd = pmd_offset(pud, addr);
28465 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28466 + }
28467 +*/
28468 +#endif
28469 +
28470 +#ifdef CONFIG_MODULES
28471 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28472 +#endif
28473 +
28474 +#else
28475 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28476 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28477 + pgd = pgd_offset_k(addr);
28478 + pud = pud_offset(pgd, addr);
28479 + pmd = pmd_offset(pud, addr);
28480 + if (!pmd_present(*pmd))
28481 + continue;
28482 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28483 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28484 + else
28485 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28486 + }
28487 +
28488 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28489 + end = addr + KERNEL_IMAGE_SIZE;
28490 + for (; addr < end; addr += PMD_SIZE) {
28491 + pgd = pgd_offset_k(addr);
28492 + pud = pud_offset(pgd, addr);
28493 + pmd = pmd_offset(pud, addr);
28494 + if (!pmd_present(*pmd))
28495 + continue;
28496 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28497 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28498 + }
28499 +#endif
28500 +
28501 + flush_tlb_all();
28502 +#endif
28503 +
28504 free_init_pages("unused kernel memory",
28505 (unsigned long)(&__init_begin),
28506 (unsigned long)(&__init_end));
28507 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28508 index 745d66b..56bf568 100644
28509 --- a/arch/x86/mm/init_32.c
28510 +++ b/arch/x86/mm/init_32.c
28511 @@ -73,36 +73,6 @@ static __init void *alloc_low_page(void)
28512 }
28513
28514 /*
28515 - * Creates a middle page table and puts a pointer to it in the
28516 - * given global directory entry. This only returns the gd entry
28517 - * in non-PAE compilation mode, since the middle layer is folded.
28518 - */
28519 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28520 -{
28521 - pud_t *pud;
28522 - pmd_t *pmd_table;
28523 -
28524 -#ifdef CONFIG_X86_PAE
28525 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28526 - if (after_bootmem)
28527 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
28528 - else
28529 - pmd_table = (pmd_t *)alloc_low_page();
28530 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28531 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28532 - pud = pud_offset(pgd, 0);
28533 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28534 -
28535 - return pmd_table;
28536 - }
28537 -#endif
28538 - pud = pud_offset(pgd, 0);
28539 - pmd_table = pmd_offset(pud, 0);
28540 -
28541 - return pmd_table;
28542 -}
28543 -
28544 -/*
28545 * Create a page table and place a pointer to it in a middle page
28546 * directory entry:
28547 */
28548 @@ -122,13 +92,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28549 page_table = (pte_t *)alloc_low_page();
28550
28551 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28552 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28553 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28554 +#else
28555 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28556 +#endif
28557 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28558 }
28559
28560 return pte_offset_kernel(pmd, 0);
28561 }
28562
28563 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28564 +{
28565 + pud_t *pud;
28566 + pmd_t *pmd_table;
28567 +
28568 + pud = pud_offset(pgd, 0);
28569 + pmd_table = pmd_offset(pud, 0);
28570 +
28571 + return pmd_table;
28572 +}
28573 +
28574 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28575 {
28576 int pgd_idx = pgd_index(vaddr);
28577 @@ -202,6 +187,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28578 int pgd_idx, pmd_idx;
28579 unsigned long vaddr;
28580 pgd_t *pgd;
28581 + pud_t *pud;
28582 pmd_t *pmd;
28583 pte_t *pte = NULL;
28584
28585 @@ -211,8 +197,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28586 pgd = pgd_base + pgd_idx;
28587
28588 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28589 - pmd = one_md_table_init(pgd);
28590 - pmd = pmd + pmd_index(vaddr);
28591 + pud = pud_offset(pgd, vaddr);
28592 + pmd = pmd_offset(pud, vaddr);
28593 +
28594 +#ifdef CONFIG_X86_PAE
28595 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28596 +#endif
28597 +
28598 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28599 pmd++, pmd_idx++) {
28600 pte = page_table_kmap_check(one_page_table_init(pmd),
28601 @@ -224,11 +215,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28602 }
28603 }
28604
28605 -static inline int is_kernel_text(unsigned long addr)
28606 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28607 {
28608 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28609 - return 1;
28610 - return 0;
28611 + if ((start > ktla_ktva((unsigned long)_etext) ||
28612 + end <= ktla_ktva((unsigned long)_stext)) &&
28613 + (start > ktla_ktva((unsigned long)_einittext) ||
28614 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28615 +
28616 +#ifdef CONFIG_ACPI_SLEEP
28617 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28618 +#endif
28619 +
28620 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28621 + return 0;
28622 + return 1;
28623 }
28624
28625 /*
28626 @@ -245,9 +245,10 @@ kernel_physical_mapping_init(unsigned long start,
28627 unsigned long last_map_addr = end;
28628 unsigned long start_pfn, end_pfn;
28629 pgd_t *pgd_base = swapper_pg_dir;
28630 - int pgd_idx, pmd_idx, pte_ofs;
28631 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28632 unsigned long pfn;
28633 pgd_t *pgd;
28634 + pud_t *pud;
28635 pmd_t *pmd;
28636 pte_t *pte;
28637 unsigned pages_2m, pages_4k;
28638 @@ -280,8 +281,13 @@ repeat:
28639 pfn = start_pfn;
28640 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28641 pgd = pgd_base + pgd_idx;
28642 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28643 - pmd = one_md_table_init(pgd);
28644 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28645 + pud = pud_offset(pgd, 0);
28646 + pmd = pmd_offset(pud, 0);
28647 +
28648 +#ifdef CONFIG_X86_PAE
28649 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28650 +#endif
28651
28652 if (pfn >= end_pfn)
28653 continue;
28654 @@ -293,14 +299,13 @@ repeat:
28655 #endif
28656 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28657 pmd++, pmd_idx++) {
28658 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28659 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28660
28661 /*
28662 * Map with big pages if possible, otherwise
28663 * create normal page tables:
28664 */
28665 if (use_pse) {
28666 - unsigned int addr2;
28667 pgprot_t prot = PAGE_KERNEL_LARGE;
28668 /*
28669 * first pass will use the same initial
28670 @@ -310,11 +315,7 @@ repeat:
28671 __pgprot(PTE_IDENT_ATTR |
28672 _PAGE_PSE);
28673
28674 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28675 - PAGE_OFFSET + PAGE_SIZE-1;
28676 -
28677 - if (is_kernel_text(addr) ||
28678 - is_kernel_text(addr2))
28679 + if (is_kernel_text(address, address + PMD_SIZE))
28680 prot = PAGE_KERNEL_LARGE_EXEC;
28681
28682 pages_2m++;
28683 @@ -331,7 +332,7 @@ repeat:
28684 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28685 pte += pte_ofs;
28686 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28687 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28688 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28689 pgprot_t prot = PAGE_KERNEL;
28690 /*
28691 * first pass will use the same initial
28692 @@ -339,7 +340,7 @@ repeat:
28693 */
28694 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28695
28696 - if (is_kernel_text(addr))
28697 + if (is_kernel_text(address, address + PAGE_SIZE))
28698 prot = PAGE_KERNEL_EXEC;
28699
28700 pages_4k++;
28701 @@ -465,7 +466,7 @@ void __init native_pagetable_init(void)
28702
28703 pud = pud_offset(pgd, va);
28704 pmd = pmd_offset(pud, va);
28705 - if (!pmd_present(*pmd))
28706 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
28707 break;
28708
28709 pte = pte_offset_kernel(pmd, va);
28710 @@ -514,12 +515,10 @@ void __init early_ioremap_page_table_range_init(void)
28711
28712 static void __init pagetable_init(void)
28713 {
28714 - pgd_t *pgd_base = swapper_pg_dir;
28715 -
28716 - permanent_kmaps_init(pgd_base);
28717 + permanent_kmaps_init(swapper_pg_dir);
28718 }
28719
28720 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28721 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28722 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28723
28724 /* user-defined highmem size */
28725 @@ -728,6 +727,12 @@ void __init mem_init(void)
28726
28727 pci_iommu_alloc();
28728
28729 +#ifdef CONFIG_PAX_PER_CPU_PGD
28730 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28731 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28732 + KERNEL_PGD_PTRS);
28733 +#endif
28734 +
28735 #ifdef CONFIG_FLATMEM
28736 BUG_ON(!mem_map);
28737 #endif
28738 @@ -754,7 +759,7 @@ void __init mem_init(void)
28739 reservedpages++;
28740
28741 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28742 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28743 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28744 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28745
28746 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28747 @@ -795,10 +800,10 @@ void __init mem_init(void)
28748 ((unsigned long)&__init_end -
28749 (unsigned long)&__init_begin) >> 10,
28750
28751 - (unsigned long)&_etext, (unsigned long)&_edata,
28752 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28753 + (unsigned long)&_sdata, (unsigned long)&_edata,
28754 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28755
28756 - (unsigned long)&_text, (unsigned long)&_etext,
28757 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28758 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28759
28760 /*
28761 @@ -876,6 +881,7 @@ void set_kernel_text_rw(void)
28762 if (!kernel_set_to_readonly)
28763 return;
28764
28765 + start = ktla_ktva(start);
28766 pr_debug("Set kernel text: %lx - %lx for read write\n",
28767 start, start+size);
28768
28769 @@ -890,6 +896,7 @@ void set_kernel_text_ro(void)
28770 if (!kernel_set_to_readonly)
28771 return;
28772
28773 + start = ktla_ktva(start);
28774 pr_debug("Set kernel text: %lx - %lx for read only\n",
28775 start, start+size);
28776
28777 @@ -918,6 +925,7 @@ void mark_rodata_ro(void)
28778 unsigned long start = PFN_ALIGN(_text);
28779 unsigned long size = PFN_ALIGN(_etext) - start;
28780
28781 + start = ktla_ktva(start);
28782 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28783 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28784 size >> 10);
28785 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28786 index 75c9a6a..498d677 100644
28787 --- a/arch/x86/mm/init_64.c
28788 +++ b/arch/x86/mm/init_64.c
28789 @@ -74,7 +74,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28790 * around without checking the pgd every time.
28791 */
28792
28793 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28794 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28795 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28796
28797 int force_personality32;
28798 @@ -107,12 +107,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28799
28800 for (address = start; address <= end; address += PGDIR_SIZE) {
28801 const pgd_t *pgd_ref = pgd_offset_k(address);
28802 +
28803 +#ifdef CONFIG_PAX_PER_CPU_PGD
28804 + unsigned long cpu;
28805 +#else
28806 struct page *page;
28807 +#endif
28808
28809 if (pgd_none(*pgd_ref))
28810 continue;
28811
28812 spin_lock(&pgd_lock);
28813 +
28814 +#ifdef CONFIG_PAX_PER_CPU_PGD
28815 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28816 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28817 +#else
28818 list_for_each_entry(page, &pgd_list, lru) {
28819 pgd_t *pgd;
28820 spinlock_t *pgt_lock;
28821 @@ -121,6 +131,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28822 /* the pgt_lock only for Xen */
28823 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28824 spin_lock(pgt_lock);
28825 +#endif
28826
28827 if (pgd_none(*pgd))
28828 set_pgd(pgd, *pgd_ref);
28829 @@ -128,7 +139,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28830 BUG_ON(pgd_page_vaddr(*pgd)
28831 != pgd_page_vaddr(*pgd_ref));
28832
28833 +#ifndef CONFIG_PAX_PER_CPU_PGD
28834 spin_unlock(pgt_lock);
28835 +#endif
28836 +
28837 }
28838 spin_unlock(&pgd_lock);
28839 }
28840 @@ -161,7 +175,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28841 {
28842 if (pgd_none(*pgd)) {
28843 pud_t *pud = (pud_t *)spp_getpage();
28844 - pgd_populate(&init_mm, pgd, pud);
28845 + pgd_populate_kernel(&init_mm, pgd, pud);
28846 if (pud != pud_offset(pgd, 0))
28847 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28848 pud, pud_offset(pgd, 0));
28849 @@ -173,7 +187,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28850 {
28851 if (pud_none(*pud)) {
28852 pmd_t *pmd = (pmd_t *) spp_getpage();
28853 - pud_populate(&init_mm, pud, pmd);
28854 + pud_populate_kernel(&init_mm, pud, pmd);
28855 if (pmd != pmd_offset(pud, 0))
28856 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28857 pmd, pmd_offset(pud, 0));
28858 @@ -202,7 +216,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28859 pmd = fill_pmd(pud, vaddr);
28860 pte = fill_pte(pmd, vaddr);
28861
28862 + pax_open_kernel();
28863 set_pte(pte, new_pte);
28864 + pax_close_kernel();
28865
28866 /*
28867 * It's enough to flush this one mapping.
28868 @@ -261,14 +277,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28869 pgd = pgd_offset_k((unsigned long)__va(phys));
28870 if (pgd_none(*pgd)) {
28871 pud = (pud_t *) spp_getpage();
28872 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28873 - _PAGE_USER));
28874 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28875 }
28876 pud = pud_offset(pgd, (unsigned long)__va(phys));
28877 if (pud_none(*pud)) {
28878 pmd = (pmd_t *) spp_getpage();
28879 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28880 - _PAGE_USER));
28881 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28882 }
28883 pmd = pmd_offset(pud, phys);
28884 BUG_ON(!pmd_none(*pmd));
28885 @@ -329,7 +343,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
28886 if (pfn >= pgt_buf_top)
28887 panic("alloc_low_page: ran out of memory");
28888
28889 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28890 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28891 clear_page(adr);
28892 *phys = pfn * PAGE_SIZE;
28893 return adr;
28894 @@ -345,7 +359,7 @@ static __ref void *map_low_page(void *virt)
28895
28896 phys = __pa(virt);
28897 left = phys & (PAGE_SIZE - 1);
28898 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28899 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28900 adr = (void *)(((unsigned long)adr) | left);
28901
28902 return adr;
28903 @@ -553,7 +567,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28904 unmap_low_page(pmd);
28905
28906 spin_lock(&init_mm.page_table_lock);
28907 - pud_populate(&init_mm, pud, __va(pmd_phys));
28908 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
28909 spin_unlock(&init_mm.page_table_lock);
28910 }
28911 __flush_tlb_all();
28912 @@ -599,7 +613,7 @@ kernel_physical_mapping_init(unsigned long start,
28913 unmap_low_page(pud);
28914
28915 spin_lock(&init_mm.page_table_lock);
28916 - pgd_populate(&init_mm, pgd, __va(pud_phys));
28917 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
28918 spin_unlock(&init_mm.page_table_lock);
28919 pgd_changed = true;
28920 }
28921 @@ -693,6 +707,12 @@ void __init mem_init(void)
28922
28923 pci_iommu_alloc();
28924
28925 +#ifdef CONFIG_PAX_PER_CPU_PGD
28926 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28927 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28928 + KERNEL_PGD_PTRS);
28929 +#endif
28930 +
28931 /* clear_bss() already clear the empty_zero_page */
28932
28933 reservedpages = 0;
28934 @@ -856,8 +876,8 @@ int kern_addr_valid(unsigned long addr)
28935 static struct vm_area_struct gate_vma = {
28936 .vm_start = VSYSCALL_START,
28937 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28938 - .vm_page_prot = PAGE_READONLY_EXEC,
28939 - .vm_flags = VM_READ | VM_EXEC
28940 + .vm_page_prot = PAGE_READONLY,
28941 + .vm_flags = VM_READ
28942 };
28943
28944 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28945 @@ -891,7 +911,7 @@ int in_gate_area_no_mm(unsigned long addr)
28946
28947 const char *arch_vma_name(struct vm_area_struct *vma)
28948 {
28949 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28950 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28951 return "[vdso]";
28952 if (vma == &gate_vma)
28953 return "[vsyscall]";
28954 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28955 index 7b179b4..6bd17777 100644
28956 --- a/arch/x86/mm/iomap_32.c
28957 +++ b/arch/x86/mm/iomap_32.c
28958 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28959 type = kmap_atomic_idx_push();
28960 idx = type + KM_TYPE_NR * smp_processor_id();
28961 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28962 +
28963 + pax_open_kernel();
28964 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28965 + pax_close_kernel();
28966 +
28967 arch_flush_lazy_mmu_mode();
28968
28969 return (void *)vaddr;
28970 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28971 index 78fe3f1..73b95e2 100644
28972 --- a/arch/x86/mm/ioremap.c
28973 +++ b/arch/x86/mm/ioremap.c
28974 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28975 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28976 int is_ram = page_is_ram(pfn);
28977
28978 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28979 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28980 return NULL;
28981 WARN_ON_ONCE(is_ram);
28982 }
28983 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28984 *
28985 * Caller must ensure there is only one unmapping for the same pointer.
28986 */
28987 -void iounmap(volatile void __iomem *addr)
28988 +void iounmap(const volatile void __iomem *addr)
28989 {
28990 struct vm_struct *p, *o;
28991
28992 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28993
28994 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28995 if (page_is_ram(start >> PAGE_SHIFT))
28996 +#ifdef CONFIG_HIGHMEM
28997 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28998 +#endif
28999 return __va(phys);
29000
29001 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
29002 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29003 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
29004 {
29005 if (page_is_ram(phys >> PAGE_SHIFT))
29006 +#ifdef CONFIG_HIGHMEM
29007 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
29008 +#endif
29009 return;
29010
29011 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
29012 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
29013 early_param("early_ioremap_debug", early_ioremap_debug_setup);
29014
29015 static __initdata int after_paging_init;
29016 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
29017 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
29018
29019 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
29020 {
29021 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
29022 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
29023
29024 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
29025 - memset(bm_pte, 0, sizeof(bm_pte));
29026 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
29027 + pmd_populate_user(&init_mm, pmd, bm_pte);
29028
29029 /*
29030 * The boot-ioremap range spans multiple pmds, for which
29031 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
29032 index d87dd6d..bf3fa66 100644
29033 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
29034 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
29035 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
29036 * memory (e.g. tracked pages)? For now, we need this to avoid
29037 * invoking kmemcheck for PnP BIOS calls.
29038 */
29039 - if (regs->flags & X86_VM_MASK)
29040 + if (v8086_mode(regs))
29041 return false;
29042 - if (regs->cs != __KERNEL_CS)
29043 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
29044 return false;
29045
29046 pte = kmemcheck_pte_lookup(address);
29047 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
29048 index 845df68..1d8d29f 100644
29049 --- a/arch/x86/mm/mmap.c
29050 +++ b/arch/x86/mm/mmap.c
29051 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
29052 * Leave an at least ~128 MB hole with possible stack randomization.
29053 */
29054 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
29055 -#define MAX_GAP (TASK_SIZE/6*5)
29056 +#define MAX_GAP (pax_task_size/6*5)
29057
29058 static int mmap_is_legacy(void)
29059 {
29060 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
29061 return rnd << PAGE_SHIFT;
29062 }
29063
29064 -static unsigned long mmap_base(void)
29065 +static unsigned long mmap_base(struct mm_struct *mm)
29066 {
29067 unsigned long gap = rlimit(RLIMIT_STACK);
29068 + unsigned long pax_task_size = TASK_SIZE;
29069 +
29070 +#ifdef CONFIG_PAX_SEGMEXEC
29071 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29072 + pax_task_size = SEGMEXEC_TASK_SIZE;
29073 +#endif
29074
29075 if (gap < MIN_GAP)
29076 gap = MIN_GAP;
29077 else if (gap > MAX_GAP)
29078 gap = MAX_GAP;
29079
29080 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
29081 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
29082 }
29083
29084 /*
29085 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
29086 * does, but not when emulating X86_32
29087 */
29088 -static unsigned long mmap_legacy_base(void)
29089 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
29090 {
29091 - if (mmap_is_ia32())
29092 + if (mmap_is_ia32()) {
29093 +
29094 +#ifdef CONFIG_PAX_SEGMEXEC
29095 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29096 + return SEGMEXEC_TASK_UNMAPPED_BASE;
29097 + else
29098 +#endif
29099 +
29100 return TASK_UNMAPPED_BASE;
29101 - else
29102 + } else
29103 return TASK_UNMAPPED_BASE + mmap_rnd();
29104 }
29105
29106 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
29107 void arch_pick_mmap_layout(struct mm_struct *mm)
29108 {
29109 if (mmap_is_legacy()) {
29110 - mm->mmap_base = mmap_legacy_base();
29111 + mm->mmap_base = mmap_legacy_base(mm);
29112 +
29113 +#ifdef CONFIG_PAX_RANDMMAP
29114 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29115 + mm->mmap_base += mm->delta_mmap;
29116 +#endif
29117 +
29118 mm->get_unmapped_area = arch_get_unmapped_area;
29119 mm->unmap_area = arch_unmap_area;
29120 } else {
29121 - mm->mmap_base = mmap_base();
29122 + mm->mmap_base = mmap_base(mm);
29123 +
29124 +#ifdef CONFIG_PAX_RANDMMAP
29125 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29126 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
29127 +#endif
29128 +
29129 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
29130 mm->unmap_area = arch_unmap_area_topdown;
29131 }
29132 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
29133 index dc0b727..f612039 100644
29134 --- a/arch/x86/mm/mmio-mod.c
29135 +++ b/arch/x86/mm/mmio-mod.c
29136 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
29137 break;
29138 default:
29139 {
29140 - unsigned char *ip = (unsigned char *)instptr;
29141 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
29142 my_trace->opcode = MMIO_UNKNOWN_OP;
29143 my_trace->width = 0;
29144 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
29145 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
29146 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29147 void __iomem *addr)
29148 {
29149 - static atomic_t next_id;
29150 + static atomic_unchecked_t next_id;
29151 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
29152 /* These are page-unaligned. */
29153 struct mmiotrace_map map = {
29154 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29155 .private = trace
29156 },
29157 .phys = offset,
29158 - .id = atomic_inc_return(&next_id)
29159 + .id = atomic_inc_return_unchecked(&next_id)
29160 };
29161 map.map_id = trace->id;
29162
29163 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
29164 ioremap_trace_core(offset, size, addr);
29165 }
29166
29167 -static void iounmap_trace_core(volatile void __iomem *addr)
29168 +static void iounmap_trace_core(const volatile void __iomem *addr)
29169 {
29170 struct mmiotrace_map map = {
29171 .phys = 0,
29172 @@ -328,7 +328,7 @@ not_enabled:
29173 }
29174 }
29175
29176 -void mmiotrace_iounmap(volatile void __iomem *addr)
29177 +void mmiotrace_iounmap(const volatile void __iomem *addr)
29178 {
29179 might_sleep();
29180 if (is_enabled()) /* recheck and proper locking in *_core() */
29181 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
29182 index 8504f36..5fc68f2 100644
29183 --- a/arch/x86/mm/numa.c
29184 +++ b/arch/x86/mm/numa.c
29185 @@ -478,7 +478,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
29186 return true;
29187 }
29188
29189 -static int __init numa_register_memblks(struct numa_meminfo *mi)
29190 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
29191 {
29192 unsigned long uninitialized_var(pfn_align);
29193 int i, nid;
29194 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
29195 index b008656..773eac2 100644
29196 --- a/arch/x86/mm/pageattr-test.c
29197 +++ b/arch/x86/mm/pageattr-test.c
29198 @@ -36,7 +36,7 @@ enum {
29199
29200 static int pte_testbit(pte_t pte)
29201 {
29202 - return pte_flags(pte) & _PAGE_UNUSED1;
29203 + return pte_flags(pte) & _PAGE_CPA_TEST;
29204 }
29205
29206 struct split_state {
29207 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
29208 index a718e0d..77419bc 100644
29209 --- a/arch/x86/mm/pageattr.c
29210 +++ b/arch/x86/mm/pageattr.c
29211 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29212 */
29213 #ifdef CONFIG_PCI_BIOS
29214 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
29215 - pgprot_val(forbidden) |= _PAGE_NX;
29216 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29217 #endif
29218
29219 /*
29220 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29221 * Does not cover __inittext since that is gone later on. On
29222 * 64bit we do not enforce !NX on the low mapping
29223 */
29224 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
29225 - pgprot_val(forbidden) |= _PAGE_NX;
29226 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
29227 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29228
29229 +#ifdef CONFIG_DEBUG_RODATA
29230 /*
29231 * The .rodata section needs to be read-only. Using the pfn
29232 * catches all aliases.
29233 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29234 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
29235 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
29236 pgprot_val(forbidden) |= _PAGE_RW;
29237 +#endif
29238
29239 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
29240 /*
29241 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29242 }
29243 #endif
29244
29245 +#ifdef CONFIG_PAX_KERNEXEC
29246 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
29247 + pgprot_val(forbidden) |= _PAGE_RW;
29248 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29249 + }
29250 +#endif
29251 +
29252 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
29253
29254 return prot;
29255 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
29256 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
29257 {
29258 /* change init_mm */
29259 + pax_open_kernel();
29260 set_pte_atomic(kpte, pte);
29261 +
29262 #ifdef CONFIG_X86_32
29263 if (!SHARED_KERNEL_PMD) {
29264 +
29265 +#ifdef CONFIG_PAX_PER_CPU_PGD
29266 + unsigned long cpu;
29267 +#else
29268 struct page *page;
29269 +#endif
29270
29271 +#ifdef CONFIG_PAX_PER_CPU_PGD
29272 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29273 + pgd_t *pgd = get_cpu_pgd(cpu);
29274 +#else
29275 list_for_each_entry(page, &pgd_list, lru) {
29276 - pgd_t *pgd;
29277 + pgd_t *pgd = (pgd_t *)page_address(page);
29278 +#endif
29279 +
29280 pud_t *pud;
29281 pmd_t *pmd;
29282
29283 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29284 + pgd += pgd_index(address);
29285 pud = pud_offset(pgd, address);
29286 pmd = pmd_offset(pud, address);
29287 set_pte_atomic((pte_t *)pmd, pte);
29288 }
29289 }
29290 #endif
29291 + pax_close_kernel();
29292 }
29293
29294 static int
29295 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29296 index 0eb572e..92f5c1e 100644
29297 --- a/arch/x86/mm/pat.c
29298 +++ b/arch/x86/mm/pat.c
29299 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29300
29301 if (!entry) {
29302 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29303 - current->comm, current->pid, start, end - 1);
29304 + current->comm, task_pid_nr(current), start, end - 1);
29305 return -EINVAL;
29306 }
29307
29308 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29309
29310 while (cursor < to) {
29311 if (!devmem_is_allowed(pfn)) {
29312 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29313 - current->comm, from, to - 1);
29314 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29315 + current->comm, from, to - 1, cursor);
29316 return 0;
29317 }
29318 cursor += PAGE_SIZE;
29319 @@ -570,7 +570,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29320 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29321 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29322 "for [mem %#010Lx-%#010Lx]\n",
29323 - current->comm, current->pid,
29324 + current->comm, task_pid_nr(current),
29325 cattr_name(flags),
29326 base, (unsigned long long)(base + size-1));
29327 return -EINVAL;
29328 @@ -605,7 +605,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29329 flags = lookup_memtype(paddr);
29330 if (want_flags != flags) {
29331 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29332 - current->comm, current->pid,
29333 + current->comm, task_pid_nr(current),
29334 cattr_name(want_flags),
29335 (unsigned long long)paddr,
29336 (unsigned long long)(paddr + size - 1),
29337 @@ -627,7 +627,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29338 free_memtype(paddr, paddr + size);
29339 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29340 " for [mem %#010Lx-%#010Lx], got %s\n",
29341 - current->comm, current->pid,
29342 + current->comm, task_pid_nr(current),
29343 cattr_name(want_flags),
29344 (unsigned long long)paddr,
29345 (unsigned long long)(paddr + size - 1),
29346 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29347 index 9f0614d..92ae64a 100644
29348 --- a/arch/x86/mm/pf_in.c
29349 +++ b/arch/x86/mm/pf_in.c
29350 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29351 int i;
29352 enum reason_type rv = OTHERS;
29353
29354 - p = (unsigned char *)ins_addr;
29355 + p = (unsigned char *)ktla_ktva(ins_addr);
29356 p += skip_prefix(p, &prf);
29357 p += get_opcode(p, &opcode);
29358
29359 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29360 struct prefix_bits prf;
29361 int i;
29362
29363 - p = (unsigned char *)ins_addr;
29364 + p = (unsigned char *)ktla_ktva(ins_addr);
29365 p += skip_prefix(p, &prf);
29366 p += get_opcode(p, &opcode);
29367
29368 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29369 struct prefix_bits prf;
29370 int i;
29371
29372 - p = (unsigned char *)ins_addr;
29373 + p = (unsigned char *)ktla_ktva(ins_addr);
29374 p += skip_prefix(p, &prf);
29375 p += get_opcode(p, &opcode);
29376
29377 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29378 struct prefix_bits prf;
29379 int i;
29380
29381 - p = (unsigned char *)ins_addr;
29382 + p = (unsigned char *)ktla_ktva(ins_addr);
29383 p += skip_prefix(p, &prf);
29384 p += get_opcode(p, &opcode);
29385 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29386 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29387 struct prefix_bits prf;
29388 int i;
29389
29390 - p = (unsigned char *)ins_addr;
29391 + p = (unsigned char *)ktla_ktva(ins_addr);
29392 p += skip_prefix(p, &prf);
29393 p += get_opcode(p, &opcode);
29394 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29395 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29396 index e27fbf8..8b56dc9 100644
29397 --- a/arch/x86/mm/pgtable.c
29398 +++ b/arch/x86/mm/pgtable.c
29399 @@ -84,10 +84,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29400 list_del(&page->lru);
29401 }
29402
29403 -#define UNSHARED_PTRS_PER_PGD \
29404 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29405 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29406 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29407
29408 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29409 +{
29410 + unsigned int count = USER_PGD_PTRS;
29411
29412 + while (count--)
29413 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29414 +}
29415 +#endif
29416 +
29417 +#ifdef CONFIG_PAX_PER_CPU_PGD
29418 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29419 +{
29420 + unsigned int count = USER_PGD_PTRS;
29421 +
29422 + while (count--) {
29423 + pgd_t pgd;
29424 +
29425 +#ifdef CONFIG_X86_64
29426 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29427 +#else
29428 + pgd = *src++;
29429 +#endif
29430 +
29431 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29432 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29433 +#endif
29434 +
29435 + *dst++ = pgd;
29436 + }
29437 +
29438 +}
29439 +#endif
29440 +
29441 +#ifdef CONFIG_X86_64
29442 +#define pxd_t pud_t
29443 +#define pyd_t pgd_t
29444 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29445 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29446 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29447 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29448 +#define PYD_SIZE PGDIR_SIZE
29449 +#else
29450 +#define pxd_t pmd_t
29451 +#define pyd_t pud_t
29452 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29453 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29454 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29455 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29456 +#define PYD_SIZE PUD_SIZE
29457 +#endif
29458 +
29459 +#ifdef CONFIG_PAX_PER_CPU_PGD
29460 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29461 +static inline void pgd_dtor(pgd_t *pgd) {}
29462 +#else
29463 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29464 {
29465 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29466 @@ -128,6 +182,7 @@ static void pgd_dtor(pgd_t *pgd)
29467 pgd_list_del(pgd);
29468 spin_unlock(&pgd_lock);
29469 }
29470 +#endif
29471
29472 /*
29473 * List of all pgd's needed for non-PAE so it can invalidate entries
29474 @@ -140,7 +195,7 @@ static void pgd_dtor(pgd_t *pgd)
29475 * -- nyc
29476 */
29477
29478 -#ifdef CONFIG_X86_PAE
29479 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29480 /*
29481 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29482 * updating the top-level pagetable entries to guarantee the
29483 @@ -152,7 +207,7 @@ static void pgd_dtor(pgd_t *pgd)
29484 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29485 * and initialize the kernel pmds here.
29486 */
29487 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29488 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29489
29490 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29491 {
29492 @@ -170,36 +225,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29493 */
29494 flush_tlb_mm(mm);
29495 }
29496 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29497 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29498 #else /* !CONFIG_X86_PAE */
29499
29500 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29501 -#define PREALLOCATED_PMDS 0
29502 +#define PREALLOCATED_PXDS 0
29503
29504 #endif /* CONFIG_X86_PAE */
29505
29506 -static void free_pmds(pmd_t *pmds[])
29507 +static void free_pxds(pxd_t *pxds[])
29508 {
29509 int i;
29510
29511 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29512 - if (pmds[i])
29513 - free_page((unsigned long)pmds[i]);
29514 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29515 + if (pxds[i])
29516 + free_page((unsigned long)pxds[i]);
29517 }
29518
29519 -static int preallocate_pmds(pmd_t *pmds[])
29520 +static int preallocate_pxds(pxd_t *pxds[])
29521 {
29522 int i;
29523 bool failed = false;
29524
29525 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29526 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29527 - if (pmd == NULL)
29528 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29529 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29530 + if (pxd == NULL)
29531 failed = true;
29532 - pmds[i] = pmd;
29533 + pxds[i] = pxd;
29534 }
29535
29536 if (failed) {
29537 - free_pmds(pmds);
29538 + free_pxds(pxds);
29539 return -ENOMEM;
29540 }
29541
29542 @@ -212,51 +269,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29543 * preallocate which never got a corresponding vma will need to be
29544 * freed manually.
29545 */
29546 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29547 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29548 {
29549 int i;
29550
29551 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29552 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29553 pgd_t pgd = pgdp[i];
29554
29555 if (pgd_val(pgd) != 0) {
29556 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29557 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29558
29559 - pgdp[i] = native_make_pgd(0);
29560 + set_pgd(pgdp + i, native_make_pgd(0));
29561
29562 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29563 - pmd_free(mm, pmd);
29564 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29565 + pxd_free(mm, pxd);
29566 }
29567 }
29568 }
29569
29570 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29571 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29572 {
29573 - pud_t *pud;
29574 + pyd_t *pyd;
29575 unsigned long addr;
29576 int i;
29577
29578 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29579 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29580 return;
29581
29582 - pud = pud_offset(pgd, 0);
29583 +#ifdef CONFIG_X86_64
29584 + pyd = pyd_offset(mm, 0L);
29585 +#else
29586 + pyd = pyd_offset(pgd, 0L);
29587 +#endif
29588
29589 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29590 - i++, pud++, addr += PUD_SIZE) {
29591 - pmd_t *pmd = pmds[i];
29592 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29593 + i++, pyd++, addr += PYD_SIZE) {
29594 + pxd_t *pxd = pxds[i];
29595
29596 if (i >= KERNEL_PGD_BOUNDARY)
29597 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29598 - sizeof(pmd_t) * PTRS_PER_PMD);
29599 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29600 + sizeof(pxd_t) * PTRS_PER_PMD);
29601
29602 - pud_populate(mm, pud, pmd);
29603 + pyd_populate(mm, pyd, pxd);
29604 }
29605 }
29606
29607 pgd_t *pgd_alloc(struct mm_struct *mm)
29608 {
29609 pgd_t *pgd;
29610 - pmd_t *pmds[PREALLOCATED_PMDS];
29611 + pxd_t *pxds[PREALLOCATED_PXDS];
29612
29613 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29614
29615 @@ -265,11 +326,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29616
29617 mm->pgd = pgd;
29618
29619 - if (preallocate_pmds(pmds) != 0)
29620 + if (preallocate_pxds(pxds) != 0)
29621 goto out_free_pgd;
29622
29623 if (paravirt_pgd_alloc(mm) != 0)
29624 - goto out_free_pmds;
29625 + goto out_free_pxds;
29626
29627 /*
29628 * Make sure that pre-populating the pmds is atomic with
29629 @@ -279,14 +340,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29630 spin_lock(&pgd_lock);
29631
29632 pgd_ctor(mm, pgd);
29633 - pgd_prepopulate_pmd(mm, pgd, pmds);
29634 + pgd_prepopulate_pxd(mm, pgd, pxds);
29635
29636 spin_unlock(&pgd_lock);
29637
29638 return pgd;
29639
29640 -out_free_pmds:
29641 - free_pmds(pmds);
29642 +out_free_pxds:
29643 + free_pxds(pxds);
29644 out_free_pgd:
29645 free_page((unsigned long)pgd);
29646 out:
29647 @@ -295,7 +356,7 @@ out:
29648
29649 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29650 {
29651 - pgd_mop_up_pmds(mm, pgd);
29652 + pgd_mop_up_pxds(mm, pgd);
29653 pgd_dtor(pgd);
29654 paravirt_pgd_free(mm, pgd);
29655 free_page((unsigned long)pgd);
29656 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29657 index a69bcb8..19068ab 100644
29658 --- a/arch/x86/mm/pgtable_32.c
29659 +++ b/arch/x86/mm/pgtable_32.c
29660 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29661 return;
29662 }
29663 pte = pte_offset_kernel(pmd, vaddr);
29664 +
29665 + pax_open_kernel();
29666 if (pte_val(pteval))
29667 set_pte_at(&init_mm, vaddr, pte, pteval);
29668 else
29669 pte_clear(&init_mm, vaddr, pte);
29670 + pax_close_kernel();
29671
29672 /*
29673 * It's enough to flush this one mapping.
29674 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29675 index d2e2735..5c6586f 100644
29676 --- a/arch/x86/mm/physaddr.c
29677 +++ b/arch/x86/mm/physaddr.c
29678 @@ -8,7 +8,7 @@
29679
29680 #ifdef CONFIG_X86_64
29681
29682 -unsigned long __phys_addr(unsigned long x)
29683 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29684 {
29685 if (x >= __START_KERNEL_map) {
29686 x -= __START_KERNEL_map;
29687 @@ -45,7 +45,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29688 #else
29689
29690 #ifdef CONFIG_DEBUG_VIRTUAL
29691 -unsigned long __phys_addr(unsigned long x)
29692 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29693 {
29694 /* VMALLOC_* aren't constants */
29695 VIRTUAL_BUG_ON(x < PAGE_OFFSET);
29696 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29697 index 410531d..0f16030 100644
29698 --- a/arch/x86/mm/setup_nx.c
29699 +++ b/arch/x86/mm/setup_nx.c
29700 @@ -5,8 +5,10 @@
29701 #include <asm/pgtable.h>
29702 #include <asm/proto.h>
29703
29704 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29705 static int disable_nx __cpuinitdata;
29706
29707 +#ifndef CONFIG_PAX_PAGEEXEC
29708 /*
29709 * noexec = on|off
29710 *
29711 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29712 return 0;
29713 }
29714 early_param("noexec", noexec_setup);
29715 +#endif
29716 +
29717 +#endif
29718
29719 void __cpuinit x86_configure_nx(void)
29720 {
29721 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29722 if (cpu_has_nx && !disable_nx)
29723 __supported_pte_mask |= _PAGE_NX;
29724 else
29725 +#endif
29726 __supported_pte_mask &= ~_PAGE_NX;
29727 }
29728
29729 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29730 index 13a6b29..c2fff23 100644
29731 --- a/arch/x86/mm/tlb.c
29732 +++ b/arch/x86/mm/tlb.c
29733 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29734 BUG();
29735 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29736 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29737 +
29738 +#ifndef CONFIG_PAX_PER_CPU_PGD
29739 load_cr3(swapper_pg_dir);
29740 +#endif
29741 +
29742 }
29743 }
29744 EXPORT_SYMBOL_GPL(leave_mm);
29745 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29746 index 877b9a1..a8ecf42 100644
29747 --- a/arch/x86/net/bpf_jit.S
29748 +++ b/arch/x86/net/bpf_jit.S
29749 @@ -9,6 +9,7 @@
29750 */
29751 #include <linux/linkage.h>
29752 #include <asm/dwarf2.h>
29753 +#include <asm/alternative-asm.h>
29754
29755 /*
29756 * Calling convention :
29757 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29758 jle bpf_slow_path_word
29759 mov (SKBDATA,%rsi),%eax
29760 bswap %eax /* ntohl() */
29761 + pax_force_retaddr
29762 ret
29763
29764 sk_load_half:
29765 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29766 jle bpf_slow_path_half
29767 movzwl (SKBDATA,%rsi),%eax
29768 rol $8,%ax # ntohs()
29769 + pax_force_retaddr
29770 ret
29771
29772 sk_load_byte:
29773 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29774 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29775 jle bpf_slow_path_byte
29776 movzbl (SKBDATA,%rsi),%eax
29777 + pax_force_retaddr
29778 ret
29779
29780 /**
29781 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29782 movzbl (SKBDATA,%rsi),%ebx
29783 and $15,%bl
29784 shl $2,%bl
29785 + pax_force_retaddr
29786 ret
29787
29788 /* rsi contains offset and can be scratched */
29789 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29790 js bpf_error
29791 mov -12(%rbp),%eax
29792 bswap %eax
29793 + pax_force_retaddr
29794 ret
29795
29796 bpf_slow_path_half:
29797 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29798 mov -12(%rbp),%ax
29799 rol $8,%ax
29800 movzwl %ax,%eax
29801 + pax_force_retaddr
29802 ret
29803
29804 bpf_slow_path_byte:
29805 bpf_slow_path_common(1)
29806 js bpf_error
29807 movzbl -12(%rbp),%eax
29808 + pax_force_retaddr
29809 ret
29810
29811 bpf_slow_path_byte_msh:
29812 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29813 and $15,%al
29814 shl $2,%al
29815 xchg %eax,%ebx
29816 + pax_force_retaddr
29817 ret
29818
29819 #define sk_negative_common(SIZE) \
29820 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29821 sk_negative_common(4)
29822 mov (%rax), %eax
29823 bswap %eax
29824 + pax_force_retaddr
29825 ret
29826
29827 bpf_slow_path_half_neg:
29828 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29829 mov (%rax),%ax
29830 rol $8,%ax
29831 movzwl %ax,%eax
29832 + pax_force_retaddr
29833 ret
29834
29835 bpf_slow_path_byte_neg:
29836 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29837 .globl sk_load_byte_negative_offset
29838 sk_negative_common(1)
29839 movzbl (%rax), %eax
29840 + pax_force_retaddr
29841 ret
29842
29843 bpf_slow_path_byte_msh_neg:
29844 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29845 and $15,%al
29846 shl $2,%al
29847 xchg %eax,%ebx
29848 + pax_force_retaddr
29849 ret
29850
29851 bpf_error:
29852 @@ -197,4 +210,5 @@ bpf_error:
29853 xor %eax,%eax
29854 mov -8(%rbp),%rbx
29855 leaveq
29856 + pax_force_retaddr
29857 ret
29858 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29859 index d11a470..3f9adff3 100644
29860 --- a/arch/x86/net/bpf_jit_comp.c
29861 +++ b/arch/x86/net/bpf_jit_comp.c
29862 @@ -12,6 +12,7 @@
29863 #include <linux/netdevice.h>
29864 #include <linux/filter.h>
29865 #include <linux/if_vlan.h>
29866 +#include <linux/random.h>
29867
29868 /*
29869 * Conventions :
29870 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29871 return ptr + len;
29872 }
29873
29874 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29875 +#define MAX_INSTR_CODE_SIZE 96
29876 +#else
29877 +#define MAX_INSTR_CODE_SIZE 64
29878 +#endif
29879 +
29880 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29881
29882 #define EMIT1(b1) EMIT(b1, 1)
29883 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29884 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29885 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29886 +
29887 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29888 +/* original constant will appear in ecx */
29889 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29890 +do { \
29891 + /* mov ecx, randkey */ \
29892 + EMIT1(0xb9); \
29893 + EMIT(_key, 4); \
29894 + /* xor ecx, randkey ^ off */ \
29895 + EMIT2(0x81, 0xf1); \
29896 + EMIT((_key) ^ (_off), 4); \
29897 +} while (0)
29898 +
29899 +#define EMIT1_off32(b1, _off) \
29900 +do { \
29901 + switch (b1) { \
29902 + case 0x05: /* add eax, imm32 */ \
29903 + case 0x2d: /* sub eax, imm32 */ \
29904 + case 0x25: /* and eax, imm32 */ \
29905 + case 0x0d: /* or eax, imm32 */ \
29906 + case 0xb8: /* mov eax, imm32 */ \
29907 + case 0x3d: /* cmp eax, imm32 */ \
29908 + case 0xa9: /* test eax, imm32 */ \
29909 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29910 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29911 + break; \
29912 + case 0xbb: /* mov ebx, imm32 */ \
29913 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29914 + /* mov ebx, ecx */ \
29915 + EMIT2(0x89, 0xcb); \
29916 + break; \
29917 + case 0xbe: /* mov esi, imm32 */ \
29918 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29919 + /* mov esi, ecx */ \
29920 + EMIT2(0x89, 0xce); \
29921 + break; \
29922 + case 0xe9: /* jmp rel imm32 */ \
29923 + EMIT1(b1); \
29924 + EMIT(_off, 4); \
29925 + /* prevent fall-through, we're not called if off = 0 */ \
29926 + EMIT(0xcccccccc, 4); \
29927 + EMIT(0xcccccccc, 4); \
29928 + break; \
29929 + default: \
29930 + EMIT1(b1); \
29931 + EMIT(_off, 4); \
29932 + } \
29933 +} while (0)
29934 +
29935 +#define EMIT2_off32(b1, b2, _off) \
29936 +do { \
29937 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29938 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29939 + EMIT(randkey, 4); \
29940 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29941 + EMIT((_off) - randkey, 4); \
29942 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29943 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29944 + /* imul eax, ecx */ \
29945 + EMIT3(0x0f, 0xaf, 0xc1); \
29946 + } else { \
29947 + EMIT2(b1, b2); \
29948 + EMIT(_off, 4); \
29949 + } \
29950 +} while (0)
29951 +#else
29952 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29953 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29954 +#endif
29955
29956 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29957 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29958 @@ -90,6 +165,24 @@ do { \
29959 #define X86_JBE 0x76
29960 #define X86_JA 0x77
29961
29962 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29963 +#define APPEND_FLOW_VERIFY() \
29964 +do { \
29965 + /* mov ecx, randkey */ \
29966 + EMIT1(0xb9); \
29967 + EMIT(randkey, 4); \
29968 + /* cmp ecx, randkey */ \
29969 + EMIT2(0x81, 0xf9); \
29970 + EMIT(randkey, 4); \
29971 + /* jz after 8 int 3s */ \
29972 + EMIT2(0x74, 0x08); \
29973 + EMIT(0xcccccccc, 4); \
29974 + EMIT(0xcccccccc, 4); \
29975 +} while (0)
29976 +#else
29977 +#define APPEND_FLOW_VERIFY() do { } while (0)
29978 +#endif
29979 +
29980 #define EMIT_COND_JMP(op, offset) \
29981 do { \
29982 if (is_near(offset)) \
29983 @@ -97,6 +190,7 @@ do { \
29984 else { \
29985 EMIT2(0x0f, op + 0x10); \
29986 EMIT(offset, 4); /* jxx .+off32 */ \
29987 + APPEND_FLOW_VERIFY(); \
29988 } \
29989 } while (0)
29990
29991 @@ -121,12 +215,17 @@ static inline void bpf_flush_icache(void *start, void *end)
29992 set_fs(old_fs);
29993 }
29994
29995 +struct bpf_jit_work {
29996 + struct work_struct work;
29997 + void *image;
29998 +};
29999 +
30000 #define CHOOSE_LOAD_FUNC(K, func) \
30001 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
30002
30003 void bpf_jit_compile(struct sk_filter *fp)
30004 {
30005 - u8 temp[64];
30006 + u8 temp[MAX_INSTR_CODE_SIZE];
30007 u8 *prog;
30008 unsigned int proglen, oldproglen = 0;
30009 int ilen, i;
30010 @@ -139,6 +238,9 @@ void bpf_jit_compile(struct sk_filter *fp)
30011 unsigned int *addrs;
30012 const struct sock_filter *filter = fp->insns;
30013 int flen = fp->len;
30014 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30015 + unsigned int randkey;
30016 +#endif
30017
30018 if (!bpf_jit_enable)
30019 return;
30020 @@ -147,11 +249,19 @@ void bpf_jit_compile(struct sk_filter *fp)
30021 if (addrs == NULL)
30022 return;
30023
30024 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
30025 + if (!fp->work)
30026 + goto out;
30027 +
30028 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30029 + randkey = get_random_int();
30030 +#endif
30031 +
30032 /* Before first pass, make a rough estimation of addrs[]
30033 - * each bpf instruction is translated to less than 64 bytes
30034 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
30035 */
30036 for (proglen = 0, i = 0; i < flen; i++) {
30037 - proglen += 64;
30038 + proglen += MAX_INSTR_CODE_SIZE;
30039 addrs[i] = proglen;
30040 }
30041 cleanup_addr = proglen; /* epilogue address */
30042 @@ -261,10 +371,8 @@ void bpf_jit_compile(struct sk_filter *fp)
30043 case BPF_S_ALU_MUL_K: /* A *= K */
30044 if (is_imm8(K))
30045 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
30046 - else {
30047 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
30048 - EMIT(K, 4);
30049 - }
30050 + else
30051 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
30052 break;
30053 case BPF_S_ALU_DIV_X: /* A /= X; */
30054 seen |= SEEN_XREG;
30055 @@ -304,13 +412,23 @@ void bpf_jit_compile(struct sk_filter *fp)
30056 break;
30057 case BPF_S_ALU_MOD_K: /* A %= K; */
30058 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
30059 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30060 + DILUTE_CONST_SEQUENCE(K, randkey);
30061 +#else
30062 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
30063 +#endif
30064 EMIT2(0xf7, 0xf1); /* div %ecx */
30065 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
30066 break;
30067 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
30068 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30069 + DILUTE_CONST_SEQUENCE(K, randkey);
30070 + // imul rax, rcx
30071 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
30072 +#else
30073 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
30074 EMIT(K, 4);
30075 +#endif
30076 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
30077 break;
30078 case BPF_S_ALU_AND_X:
30079 @@ -564,8 +682,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
30080 if (is_imm8(K)) {
30081 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
30082 } else {
30083 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
30084 - EMIT(K, 4);
30085 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
30086 }
30087 } else {
30088 EMIT2(0x89,0xde); /* mov %ebx,%esi */
30089 @@ -648,17 +765,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30090 break;
30091 default:
30092 /* hmm, too complex filter, give up with jit compiler */
30093 - goto out;
30094 + goto error;
30095 }
30096 ilen = prog - temp;
30097 if (image) {
30098 if (unlikely(proglen + ilen > oldproglen)) {
30099 pr_err("bpb_jit_compile fatal error\n");
30100 - kfree(addrs);
30101 - module_free(NULL, image);
30102 - return;
30103 + module_free_exec(NULL, image);
30104 + goto error;
30105 }
30106 + pax_open_kernel();
30107 memcpy(image + proglen, temp, ilen);
30108 + pax_close_kernel();
30109 }
30110 proglen += ilen;
30111 addrs[i] = proglen;
30112 @@ -679,11 +797,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30113 break;
30114 }
30115 if (proglen == oldproglen) {
30116 - image = module_alloc(max_t(unsigned int,
30117 - proglen,
30118 - sizeof(struct work_struct)));
30119 + image = module_alloc_exec(proglen);
30120 if (!image)
30121 - goto out;
30122 + goto error;
30123 }
30124 oldproglen = proglen;
30125 }
30126 @@ -699,7 +815,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30127 bpf_flush_icache(image, image + proglen);
30128
30129 fp->bpf_func = (void *)image;
30130 - }
30131 + } else
30132 +error:
30133 + kfree(fp->work);
30134 +
30135 out:
30136 kfree(addrs);
30137 return;
30138 @@ -707,18 +826,20 @@ out:
30139
30140 static void jit_free_defer(struct work_struct *arg)
30141 {
30142 - module_free(NULL, arg);
30143 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
30144 + kfree(arg);
30145 }
30146
30147 /* run from softirq, we must use a work_struct to call
30148 - * module_free() from process context
30149 + * module_free_exec() from process context
30150 */
30151 void bpf_jit_free(struct sk_filter *fp)
30152 {
30153 if (fp->bpf_func != sk_run_filter) {
30154 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
30155 + struct work_struct *work = &fp->work->work;
30156
30157 INIT_WORK(work, jit_free_defer);
30158 + fp->work->image = fp->bpf_func;
30159 schedule_work(work);
30160 }
30161 }
30162 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
30163 index d6aa6e8..266395a 100644
30164 --- a/arch/x86/oprofile/backtrace.c
30165 +++ b/arch/x86/oprofile/backtrace.c
30166 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
30167 struct stack_frame_ia32 *fp;
30168 unsigned long bytes;
30169
30170 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30171 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30172 if (bytes != sizeof(bufhead))
30173 return NULL;
30174
30175 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
30176 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
30177
30178 oprofile_add_trace(bufhead[0].return_address);
30179
30180 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
30181 struct stack_frame bufhead[2];
30182 unsigned long bytes;
30183
30184 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30185 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30186 if (bytes != sizeof(bufhead))
30187 return NULL;
30188
30189 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
30190 {
30191 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
30192
30193 - if (!user_mode_vm(regs)) {
30194 + if (!user_mode(regs)) {
30195 unsigned long stack = kernel_stack_pointer(regs);
30196 if (depth)
30197 dump_trace(NULL, regs, (unsigned long *)stack, 0,
30198 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
30199 index 48768df..ba9143c 100644
30200 --- a/arch/x86/oprofile/nmi_int.c
30201 +++ b/arch/x86/oprofile/nmi_int.c
30202 @@ -23,6 +23,7 @@
30203 #include <asm/nmi.h>
30204 #include <asm/msr.h>
30205 #include <asm/apic.h>
30206 +#include <asm/pgtable.h>
30207
30208 #include "op_counter.h"
30209 #include "op_x86_model.h"
30210 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
30211 if (ret)
30212 return ret;
30213
30214 - if (!model->num_virt_counters)
30215 - model->num_virt_counters = model->num_counters;
30216 + if (!model->num_virt_counters) {
30217 + pax_open_kernel();
30218 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
30219 + pax_close_kernel();
30220 + }
30221
30222 mux_init(ops);
30223
30224 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
30225 index b2b9443..be58856 100644
30226 --- a/arch/x86/oprofile/op_model_amd.c
30227 +++ b/arch/x86/oprofile/op_model_amd.c
30228 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
30229 num_counters = AMD64_NUM_COUNTERS;
30230 }
30231
30232 - op_amd_spec.num_counters = num_counters;
30233 - op_amd_spec.num_controls = num_counters;
30234 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30235 + pax_open_kernel();
30236 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
30237 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
30238 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30239 + pax_close_kernel();
30240
30241 return 0;
30242 }
30243 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
30244 index d90528e..0127e2b 100644
30245 --- a/arch/x86/oprofile/op_model_ppro.c
30246 +++ b/arch/x86/oprofile/op_model_ppro.c
30247 @@ -19,6 +19,7 @@
30248 #include <asm/msr.h>
30249 #include <asm/apic.h>
30250 #include <asm/nmi.h>
30251 +#include <asm/pgtable.h>
30252
30253 #include "op_x86_model.h"
30254 #include "op_counter.h"
30255 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
30256
30257 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
30258
30259 - op_arch_perfmon_spec.num_counters = num_counters;
30260 - op_arch_perfmon_spec.num_controls = num_counters;
30261 + pax_open_kernel();
30262 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30263 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30264 + pax_close_kernel();
30265 }
30266
30267 static int arch_perfmon_init(struct oprofile_operations *ignore)
30268 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30269 index 71e8a67..6a313bb 100644
30270 --- a/arch/x86/oprofile/op_x86_model.h
30271 +++ b/arch/x86/oprofile/op_x86_model.h
30272 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30273 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30274 struct op_msrs const * const msrs);
30275 #endif
30276 -};
30277 +} __do_const;
30278
30279 struct op_counter_config;
30280
30281 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30282 index e9e6ed5..e47ae67 100644
30283 --- a/arch/x86/pci/amd_bus.c
30284 +++ b/arch/x86/pci/amd_bus.c
30285 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30286 return NOTIFY_OK;
30287 }
30288
30289 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30290 +static struct notifier_block amd_cpu_notifier = {
30291 .notifier_call = amd_cpu_notify,
30292 };
30293
30294 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30295 index 372e9b8..e775a6c 100644
30296 --- a/arch/x86/pci/irq.c
30297 +++ b/arch/x86/pci/irq.c
30298 @@ -50,7 +50,7 @@ struct irq_router {
30299 struct irq_router_handler {
30300 u16 vendor;
30301 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30302 -};
30303 +} __do_const;
30304
30305 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30306 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30307 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30308 return 0;
30309 }
30310
30311 -static __initdata struct irq_router_handler pirq_routers[] = {
30312 +static __initconst const struct irq_router_handler pirq_routers[] = {
30313 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30314 { PCI_VENDOR_ID_AL, ali_router_probe },
30315 { PCI_VENDOR_ID_ITE, ite_router_probe },
30316 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30317 static void __init pirq_find_router(struct irq_router *r)
30318 {
30319 struct irq_routing_table *rt = pirq_table;
30320 - struct irq_router_handler *h;
30321 + const struct irq_router_handler *h;
30322
30323 #ifdef CONFIG_PCI_BIOS
30324 if (!rt->signature) {
30325 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30326 return 0;
30327 }
30328
30329 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30330 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30331 {
30332 .callback = fix_broken_hp_bios_irq9,
30333 .ident = "HP Pavilion N5400 Series Laptop",
30334 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30335 index 6eb18c4..20d83de 100644
30336 --- a/arch/x86/pci/mrst.c
30337 +++ b/arch/x86/pci/mrst.c
30338 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30339 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30340 pci_mmcfg_late_init();
30341 pcibios_enable_irq = mrst_pci_irq_enable;
30342 - pci_root_ops = pci_mrst_ops;
30343 + pax_open_kernel();
30344 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30345 + pax_close_kernel();
30346 pci_soc_mode = 1;
30347 /* Continue with standard init */
30348 return 1;
30349 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30350 index c77b24a..c979855 100644
30351 --- a/arch/x86/pci/pcbios.c
30352 +++ b/arch/x86/pci/pcbios.c
30353 @@ -79,7 +79,7 @@ union bios32 {
30354 static struct {
30355 unsigned long address;
30356 unsigned short segment;
30357 -} bios32_indirect = { 0, __KERNEL_CS };
30358 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30359
30360 /*
30361 * Returns the entry point for the given service, NULL on error
30362 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30363 unsigned long length; /* %ecx */
30364 unsigned long entry; /* %edx */
30365 unsigned long flags;
30366 + struct desc_struct d, *gdt;
30367
30368 local_irq_save(flags);
30369 - __asm__("lcall *(%%edi); cld"
30370 +
30371 + gdt = get_cpu_gdt_table(smp_processor_id());
30372 +
30373 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30374 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30375 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30376 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30377 +
30378 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30379 : "=a" (return_code),
30380 "=b" (address),
30381 "=c" (length),
30382 "=d" (entry)
30383 : "0" (service),
30384 "1" (0),
30385 - "D" (&bios32_indirect));
30386 + "D" (&bios32_indirect),
30387 + "r"(__PCIBIOS_DS)
30388 + : "memory");
30389 +
30390 + pax_open_kernel();
30391 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30392 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30393 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30394 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30395 + pax_close_kernel();
30396 +
30397 local_irq_restore(flags);
30398
30399 switch (return_code) {
30400 - case 0:
30401 - return address + entry;
30402 - case 0x80: /* Not present */
30403 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30404 - return 0;
30405 - default: /* Shouldn't happen */
30406 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30407 - service, return_code);
30408 + case 0: {
30409 + int cpu;
30410 + unsigned char flags;
30411 +
30412 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30413 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30414 + printk(KERN_WARNING "bios32_service: not valid\n");
30415 return 0;
30416 + }
30417 + address = address + PAGE_OFFSET;
30418 + length += 16UL; /* some BIOSs underreport this... */
30419 + flags = 4;
30420 + if (length >= 64*1024*1024) {
30421 + length >>= PAGE_SHIFT;
30422 + flags |= 8;
30423 + }
30424 +
30425 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30426 + gdt = get_cpu_gdt_table(cpu);
30427 + pack_descriptor(&d, address, length, 0x9b, flags);
30428 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30429 + pack_descriptor(&d, address, length, 0x93, flags);
30430 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30431 + }
30432 + return entry;
30433 + }
30434 + case 0x80: /* Not present */
30435 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30436 + return 0;
30437 + default: /* Shouldn't happen */
30438 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30439 + service, return_code);
30440 + return 0;
30441 }
30442 }
30443
30444 static struct {
30445 unsigned long address;
30446 unsigned short segment;
30447 -} pci_indirect = { 0, __KERNEL_CS };
30448 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30449
30450 -static int pci_bios_present;
30451 +static int pci_bios_present __read_only;
30452
30453 static int check_pcibios(void)
30454 {
30455 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30456 unsigned long flags, pcibios_entry;
30457
30458 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30459 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30460 + pci_indirect.address = pcibios_entry;
30461
30462 local_irq_save(flags);
30463 - __asm__(
30464 - "lcall *(%%edi); cld\n\t"
30465 + __asm__("movw %w6, %%ds\n\t"
30466 + "lcall *%%ss:(%%edi); cld\n\t"
30467 + "push %%ss\n\t"
30468 + "pop %%ds\n\t"
30469 "jc 1f\n\t"
30470 "xor %%ah, %%ah\n"
30471 "1:"
30472 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30473 "=b" (ebx),
30474 "=c" (ecx)
30475 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30476 - "D" (&pci_indirect)
30477 + "D" (&pci_indirect),
30478 + "r" (__PCIBIOS_DS)
30479 : "memory");
30480 local_irq_restore(flags);
30481
30482 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30483
30484 switch (len) {
30485 case 1:
30486 - __asm__("lcall *(%%esi); cld\n\t"
30487 + __asm__("movw %w6, %%ds\n\t"
30488 + "lcall *%%ss:(%%esi); cld\n\t"
30489 + "push %%ss\n\t"
30490 + "pop %%ds\n\t"
30491 "jc 1f\n\t"
30492 "xor %%ah, %%ah\n"
30493 "1:"
30494 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30495 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30496 "b" (bx),
30497 "D" ((long)reg),
30498 - "S" (&pci_indirect));
30499 + "S" (&pci_indirect),
30500 + "r" (__PCIBIOS_DS));
30501 /*
30502 * Zero-extend the result beyond 8 bits, do not trust the
30503 * BIOS having done it:
30504 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30505 *value &= 0xff;
30506 break;
30507 case 2:
30508 - __asm__("lcall *(%%esi); cld\n\t"
30509 + __asm__("movw %w6, %%ds\n\t"
30510 + "lcall *%%ss:(%%esi); cld\n\t"
30511 + "push %%ss\n\t"
30512 + "pop %%ds\n\t"
30513 "jc 1f\n\t"
30514 "xor %%ah, %%ah\n"
30515 "1:"
30516 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30517 : "1" (PCIBIOS_READ_CONFIG_WORD),
30518 "b" (bx),
30519 "D" ((long)reg),
30520 - "S" (&pci_indirect));
30521 + "S" (&pci_indirect),
30522 + "r" (__PCIBIOS_DS));
30523 /*
30524 * Zero-extend the result beyond 16 bits, do not trust the
30525 * BIOS having done it:
30526 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30527 *value &= 0xffff;
30528 break;
30529 case 4:
30530 - __asm__("lcall *(%%esi); cld\n\t"
30531 + __asm__("movw %w6, %%ds\n\t"
30532 + "lcall *%%ss:(%%esi); cld\n\t"
30533 + "push %%ss\n\t"
30534 + "pop %%ds\n\t"
30535 "jc 1f\n\t"
30536 "xor %%ah, %%ah\n"
30537 "1:"
30538 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30539 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30540 "b" (bx),
30541 "D" ((long)reg),
30542 - "S" (&pci_indirect));
30543 + "S" (&pci_indirect),
30544 + "r" (__PCIBIOS_DS));
30545 break;
30546 }
30547
30548 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30549
30550 switch (len) {
30551 case 1:
30552 - __asm__("lcall *(%%esi); cld\n\t"
30553 + __asm__("movw %w6, %%ds\n\t"
30554 + "lcall *%%ss:(%%esi); cld\n\t"
30555 + "push %%ss\n\t"
30556 + "pop %%ds\n\t"
30557 "jc 1f\n\t"
30558 "xor %%ah, %%ah\n"
30559 "1:"
30560 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30561 "c" (value),
30562 "b" (bx),
30563 "D" ((long)reg),
30564 - "S" (&pci_indirect));
30565 + "S" (&pci_indirect),
30566 + "r" (__PCIBIOS_DS));
30567 break;
30568 case 2:
30569 - __asm__("lcall *(%%esi); cld\n\t"
30570 + __asm__("movw %w6, %%ds\n\t"
30571 + "lcall *%%ss:(%%esi); cld\n\t"
30572 + "push %%ss\n\t"
30573 + "pop %%ds\n\t"
30574 "jc 1f\n\t"
30575 "xor %%ah, %%ah\n"
30576 "1:"
30577 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30578 "c" (value),
30579 "b" (bx),
30580 "D" ((long)reg),
30581 - "S" (&pci_indirect));
30582 + "S" (&pci_indirect),
30583 + "r" (__PCIBIOS_DS));
30584 break;
30585 case 4:
30586 - __asm__("lcall *(%%esi); cld\n\t"
30587 + __asm__("movw %w6, %%ds\n\t"
30588 + "lcall *%%ss:(%%esi); cld\n\t"
30589 + "push %%ss\n\t"
30590 + "pop %%ds\n\t"
30591 "jc 1f\n\t"
30592 "xor %%ah, %%ah\n"
30593 "1:"
30594 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30595 "c" (value),
30596 "b" (bx),
30597 "D" ((long)reg),
30598 - "S" (&pci_indirect));
30599 + "S" (&pci_indirect),
30600 + "r" (__PCIBIOS_DS));
30601 break;
30602 }
30603
30604 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30605
30606 DBG("PCI: Fetching IRQ routing table... ");
30607 __asm__("push %%es\n\t"
30608 + "movw %w8, %%ds\n\t"
30609 "push %%ds\n\t"
30610 "pop %%es\n\t"
30611 - "lcall *(%%esi); cld\n\t"
30612 + "lcall *%%ss:(%%esi); cld\n\t"
30613 "pop %%es\n\t"
30614 + "push %%ss\n\t"
30615 + "pop %%ds\n"
30616 "jc 1f\n\t"
30617 "xor %%ah, %%ah\n"
30618 "1:"
30619 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30620 "1" (0),
30621 "D" ((long) &opt),
30622 "S" (&pci_indirect),
30623 - "m" (opt)
30624 + "m" (opt),
30625 + "r" (__PCIBIOS_DS)
30626 : "memory");
30627 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30628 if (ret & 0xff00)
30629 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30630 {
30631 int ret;
30632
30633 - __asm__("lcall *(%%esi); cld\n\t"
30634 + __asm__("movw %w5, %%ds\n\t"
30635 + "lcall *%%ss:(%%esi); cld\n\t"
30636 + "push %%ss\n\t"
30637 + "pop %%ds\n"
30638 "jc 1f\n\t"
30639 "xor %%ah, %%ah\n"
30640 "1:"
30641 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30642 : "0" (PCIBIOS_SET_PCI_HW_INT),
30643 "b" ((dev->bus->number << 8) | dev->devfn),
30644 "c" ((irq << 8) | (pin + 10)),
30645 - "S" (&pci_indirect));
30646 + "S" (&pci_indirect),
30647 + "r" (__PCIBIOS_DS));
30648 return !(ret & 0xff00);
30649 }
30650 EXPORT_SYMBOL(pcibios_set_irq_routing);
30651 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30652 index 40e4469..1ab536e 100644
30653 --- a/arch/x86/platform/efi/efi_32.c
30654 +++ b/arch/x86/platform/efi/efi_32.c
30655 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30656 {
30657 struct desc_ptr gdt_descr;
30658
30659 +#ifdef CONFIG_PAX_KERNEXEC
30660 + struct desc_struct d;
30661 +#endif
30662 +
30663 local_irq_save(efi_rt_eflags);
30664
30665 load_cr3(initial_page_table);
30666 __flush_tlb_all();
30667
30668 +#ifdef CONFIG_PAX_KERNEXEC
30669 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30670 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30671 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30672 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30673 +#endif
30674 +
30675 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30676 gdt_descr.size = GDT_SIZE - 1;
30677 load_gdt(&gdt_descr);
30678 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30679 {
30680 struct desc_ptr gdt_descr;
30681
30682 +#ifdef CONFIG_PAX_KERNEXEC
30683 + struct desc_struct d;
30684 +
30685 + memset(&d, 0, sizeof d);
30686 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30687 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30688 +#endif
30689 +
30690 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30691 gdt_descr.size = GDT_SIZE - 1;
30692 load_gdt(&gdt_descr);
30693 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30694 index fbe66e6..eae5e38 100644
30695 --- a/arch/x86/platform/efi/efi_stub_32.S
30696 +++ b/arch/x86/platform/efi/efi_stub_32.S
30697 @@ -6,7 +6,9 @@
30698 */
30699
30700 #include <linux/linkage.h>
30701 +#include <linux/init.h>
30702 #include <asm/page_types.h>
30703 +#include <asm/segment.h>
30704
30705 /*
30706 * efi_call_phys(void *, ...) is a function with variable parameters.
30707 @@ -20,7 +22,7 @@
30708 * service functions will comply with gcc calling convention, too.
30709 */
30710
30711 -.text
30712 +__INIT
30713 ENTRY(efi_call_phys)
30714 /*
30715 * 0. The function can only be called in Linux kernel. So CS has been
30716 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30717 * The mapping of lower virtual memory has been created in prelog and
30718 * epilog.
30719 */
30720 - movl $1f, %edx
30721 - subl $__PAGE_OFFSET, %edx
30722 - jmp *%edx
30723 +#ifdef CONFIG_PAX_KERNEXEC
30724 + movl $(__KERNEXEC_EFI_DS), %edx
30725 + mov %edx, %ds
30726 + mov %edx, %es
30727 + mov %edx, %ss
30728 + addl $2f,(1f)
30729 + ljmp *(1f)
30730 +
30731 +__INITDATA
30732 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30733 +.previous
30734 +
30735 +2:
30736 + subl $2b,(1b)
30737 +#else
30738 + jmp 1f-__PAGE_OFFSET
30739 1:
30740 +#endif
30741
30742 /*
30743 * 2. Now on the top of stack is the return
30744 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30745 * parameter 2, ..., param n. To make things easy, we save the return
30746 * address of efi_call_phys in a global variable.
30747 */
30748 - popl %edx
30749 - movl %edx, saved_return_addr
30750 - /* get the function pointer into ECX*/
30751 - popl %ecx
30752 - movl %ecx, efi_rt_function_ptr
30753 - movl $2f, %edx
30754 - subl $__PAGE_OFFSET, %edx
30755 - pushl %edx
30756 + popl (saved_return_addr)
30757 + popl (efi_rt_function_ptr)
30758
30759 /*
30760 * 3. Clear PG bit in %CR0.
30761 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30762 /*
30763 * 5. Call the physical function.
30764 */
30765 - jmp *%ecx
30766 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30767
30768 -2:
30769 /*
30770 * 6. After EFI runtime service returns, control will return to
30771 * following instruction. We'd better readjust stack pointer first.
30772 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30773 movl %cr0, %edx
30774 orl $0x80000000, %edx
30775 movl %edx, %cr0
30776 - jmp 1f
30777 -1:
30778 +
30779 /*
30780 * 8. Now restore the virtual mode from flat mode by
30781 * adding EIP with PAGE_OFFSET.
30782 */
30783 - movl $1f, %edx
30784 - jmp *%edx
30785 +#ifdef CONFIG_PAX_KERNEXEC
30786 + movl $(__KERNEL_DS), %edx
30787 + mov %edx, %ds
30788 + mov %edx, %es
30789 + mov %edx, %ss
30790 + ljmp $(__KERNEL_CS),$1f
30791 +#else
30792 + jmp 1f+__PAGE_OFFSET
30793 +#endif
30794 1:
30795
30796 /*
30797 * 9. Balance the stack. And because EAX contain the return value,
30798 * we'd better not clobber it.
30799 */
30800 - leal efi_rt_function_ptr, %edx
30801 - movl (%edx), %ecx
30802 - pushl %ecx
30803 + pushl (efi_rt_function_ptr)
30804
30805 /*
30806 - * 10. Push the saved return address onto the stack and return.
30807 + * 10. Return to the saved return address.
30808 */
30809 - leal saved_return_addr, %edx
30810 - movl (%edx), %ecx
30811 - pushl %ecx
30812 - ret
30813 + jmpl *(saved_return_addr)
30814 ENDPROC(efi_call_phys)
30815 .previous
30816
30817 -.data
30818 +__INITDATA
30819 saved_return_addr:
30820 .long 0
30821 efi_rt_function_ptr:
30822 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30823 index 4c07cca..2c8427d 100644
30824 --- a/arch/x86/platform/efi/efi_stub_64.S
30825 +++ b/arch/x86/platform/efi/efi_stub_64.S
30826 @@ -7,6 +7,7 @@
30827 */
30828
30829 #include <linux/linkage.h>
30830 +#include <asm/alternative-asm.h>
30831
30832 #define SAVE_XMM \
30833 mov %rsp, %rax; \
30834 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30835 call *%rdi
30836 addq $32, %rsp
30837 RESTORE_XMM
30838 + pax_force_retaddr 0, 1
30839 ret
30840 ENDPROC(efi_call0)
30841
30842 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30843 call *%rdi
30844 addq $32, %rsp
30845 RESTORE_XMM
30846 + pax_force_retaddr 0, 1
30847 ret
30848 ENDPROC(efi_call1)
30849
30850 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30851 call *%rdi
30852 addq $32, %rsp
30853 RESTORE_XMM
30854 + pax_force_retaddr 0, 1
30855 ret
30856 ENDPROC(efi_call2)
30857
30858 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30859 call *%rdi
30860 addq $32, %rsp
30861 RESTORE_XMM
30862 + pax_force_retaddr 0, 1
30863 ret
30864 ENDPROC(efi_call3)
30865
30866 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30867 call *%rdi
30868 addq $32, %rsp
30869 RESTORE_XMM
30870 + pax_force_retaddr 0, 1
30871 ret
30872 ENDPROC(efi_call4)
30873
30874 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30875 call *%rdi
30876 addq $48, %rsp
30877 RESTORE_XMM
30878 + pax_force_retaddr 0, 1
30879 ret
30880 ENDPROC(efi_call5)
30881
30882 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30883 call *%rdi
30884 addq $48, %rsp
30885 RESTORE_XMM
30886 + pax_force_retaddr 0, 1
30887 ret
30888 ENDPROC(efi_call6)
30889 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30890 index e31bcd8..f12dc46 100644
30891 --- a/arch/x86/platform/mrst/mrst.c
30892 +++ b/arch/x86/platform/mrst/mrst.c
30893 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30894 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30895 int sfi_mrtc_num;
30896
30897 -static void mrst_power_off(void)
30898 +static __noreturn void mrst_power_off(void)
30899 {
30900 + BUG();
30901 }
30902
30903 -static void mrst_reboot(void)
30904 +static __noreturn void mrst_reboot(void)
30905 {
30906 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30907 + BUG();
30908 }
30909
30910 /* parse all the mtimer info to a static mtimer array */
30911 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30912 index d6ee929..3637cb5 100644
30913 --- a/arch/x86/platform/olpc/olpc_dt.c
30914 +++ b/arch/x86/platform/olpc/olpc_dt.c
30915 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30916 return res;
30917 }
30918
30919 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30920 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30921 .nextprop = olpc_dt_nextprop,
30922 .getproplen = olpc_dt_getproplen,
30923 .getproperty = olpc_dt_getproperty,
30924 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30925 index 3c68768..07e82b8 100644
30926 --- a/arch/x86/power/cpu.c
30927 +++ b/arch/x86/power/cpu.c
30928 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30929 static void fix_processor_context(void)
30930 {
30931 int cpu = smp_processor_id();
30932 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30933 + struct tss_struct *t = init_tss + cpu;
30934
30935 set_tss_desc(cpu, t); /*
30936 * This just modifies memory; should not be
30937 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30938 */
30939
30940 #ifdef CONFIG_X86_64
30941 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
30942 -
30943 syscall_init(); /* This sets MSR_*STAR and related */
30944 #endif
30945 load_TR_desc(); /* This does ltr */
30946 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30947 index cbca565..bae7133 100644
30948 --- a/arch/x86/realmode/init.c
30949 +++ b/arch/x86/realmode/init.c
30950 @@ -62,7 +62,13 @@ void __init setup_real_mode(void)
30951 __va(real_mode_header->trampoline_header);
30952
30953 #ifdef CONFIG_X86_32
30954 - trampoline_header->start = __pa(startup_32_smp);
30955 + trampoline_header->start = __pa(ktla_ktva(startup_32_smp));
30956 +
30957 +#ifdef CONFIG_PAX_KERNEXEC
30958 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30959 +#endif
30960 +
30961 + trampoline_header->boot_cs = __BOOT_CS;
30962 trampoline_header->gdt_limit = __BOOT_DS + 7;
30963 trampoline_header->gdt_base = __pa(boot_gdt);
30964 #else
30965 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30966 index 8869287..d577672 100644
30967 --- a/arch/x86/realmode/rm/Makefile
30968 +++ b/arch/x86/realmode/rm/Makefile
30969 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30970 $(call cc-option, -fno-unit-at-a-time)) \
30971 $(call cc-option, -fno-stack-protector) \
30972 $(call cc-option, -mpreferred-stack-boundary=2)
30973 +ifdef CONSTIFY_PLUGIN
30974 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30975 +endif
30976 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30977 GCOV_PROFILE := n
30978 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30979 index a28221d..93c40f1 100644
30980 --- a/arch/x86/realmode/rm/header.S
30981 +++ b/arch/x86/realmode/rm/header.S
30982 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30983 #endif
30984 /* APM/BIOS reboot */
30985 .long pa_machine_real_restart_asm
30986 -#ifdef CONFIG_X86_64
30987 +#ifdef CONFIG_X86_32
30988 + .long __KERNEL_CS
30989 +#else
30990 .long __KERNEL32_CS
30991 #endif
30992 END(real_mode_header)
30993 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30994 index c1b2791..f9e31c7 100644
30995 --- a/arch/x86/realmode/rm/trampoline_32.S
30996 +++ b/arch/x86/realmode/rm/trampoline_32.S
30997 @@ -25,6 +25,12 @@
30998 #include <asm/page_types.h>
30999 #include "realmode.h"
31000
31001 +#ifdef CONFIG_PAX_KERNEXEC
31002 +#define ta(X) (X)
31003 +#else
31004 +#define ta(X) (pa_ ## X)
31005 +#endif
31006 +
31007 .text
31008 .code16
31009
31010 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
31011
31012 cli # We should be safe anyway
31013
31014 - movl tr_start, %eax # where we need to go
31015 -
31016 movl $0xA5A5A5A5, trampoline_status
31017 # write marker for master knows we're running
31018
31019 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
31020 movw $1, %dx # protected mode (PE) bit
31021 lmsw %dx # into protected mode
31022
31023 - ljmpl $__BOOT_CS, $pa_startup_32
31024 + ljmpl *(trampoline_header)
31025
31026 .section ".text32","ax"
31027 .code32
31028 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
31029 .balign 8
31030 GLOBAL(trampoline_header)
31031 tr_start: .space 4
31032 - tr_gdt_pad: .space 2
31033 + tr_boot_cs: .space 2
31034 tr_gdt: .space 6
31035 END(trampoline_header)
31036
31037 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
31038 index bb360dc..3e5945f 100644
31039 --- a/arch/x86/realmode/rm/trampoline_64.S
31040 +++ b/arch/x86/realmode/rm/trampoline_64.S
31041 @@ -107,7 +107,7 @@ ENTRY(startup_32)
31042 wrmsr
31043
31044 # Enable paging and in turn activate Long Mode
31045 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
31046 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
31047 movl %eax, %cr0
31048
31049 /*
31050 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
31051 index 79d67bd..c7e1b90 100644
31052 --- a/arch/x86/tools/relocs.c
31053 +++ b/arch/x86/tools/relocs.c
31054 @@ -12,10 +12,13 @@
31055 #include <regex.h>
31056 #include <tools/le_byteshift.h>
31057
31058 +#include "../../../include/generated/autoconf.h"
31059 +
31060 static void die(char *fmt, ...);
31061
31062 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
31063 static Elf32_Ehdr ehdr;
31064 +static Elf32_Phdr *phdr;
31065 static unsigned long reloc_count, reloc_idx;
31066 static unsigned long *relocs;
31067 static unsigned long reloc16_count, reloc16_idx;
31068 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
31069 }
31070 }
31071
31072 +static void read_phdrs(FILE *fp)
31073 +{
31074 + unsigned int i;
31075 +
31076 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
31077 + if (!phdr) {
31078 + die("Unable to allocate %d program headers\n",
31079 + ehdr.e_phnum);
31080 + }
31081 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
31082 + die("Seek to %d failed: %s\n",
31083 + ehdr.e_phoff, strerror(errno));
31084 + }
31085 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
31086 + die("Cannot read ELF program headers: %s\n",
31087 + strerror(errno));
31088 + }
31089 + for(i = 0; i < ehdr.e_phnum; i++) {
31090 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
31091 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
31092 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
31093 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
31094 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
31095 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
31096 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
31097 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
31098 + }
31099 +
31100 +}
31101 +
31102 static void read_shdrs(FILE *fp)
31103 {
31104 - int i;
31105 + unsigned int i;
31106 Elf32_Shdr shdr;
31107
31108 secs = calloc(ehdr.e_shnum, sizeof(struct section));
31109 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
31110
31111 static void read_strtabs(FILE *fp)
31112 {
31113 - int i;
31114 + unsigned int i;
31115 for (i = 0; i < ehdr.e_shnum; i++) {
31116 struct section *sec = &secs[i];
31117 if (sec->shdr.sh_type != SHT_STRTAB) {
31118 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
31119
31120 static void read_symtabs(FILE *fp)
31121 {
31122 - int i,j;
31123 + unsigned int i,j;
31124 for (i = 0; i < ehdr.e_shnum; i++) {
31125 struct section *sec = &secs[i];
31126 if (sec->shdr.sh_type != SHT_SYMTAB) {
31127 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
31128 }
31129
31130
31131 -static void read_relocs(FILE *fp)
31132 +static void read_relocs(FILE *fp, int use_real_mode)
31133 {
31134 - int i,j;
31135 + unsigned int i,j;
31136 + uint32_t base;
31137 +
31138 for (i = 0; i < ehdr.e_shnum; i++) {
31139 struct section *sec = &secs[i];
31140 if (sec->shdr.sh_type != SHT_REL) {
31141 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
31142 die("Cannot read symbol table: %s\n",
31143 strerror(errno));
31144 }
31145 + base = 0;
31146 +
31147 +#ifdef CONFIG_X86_32
31148 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
31149 + if (phdr[j].p_type != PT_LOAD )
31150 + continue;
31151 + 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)
31152 + continue;
31153 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
31154 + break;
31155 + }
31156 +#endif
31157 +
31158 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
31159 Elf32_Rel *rel = &sec->reltab[j];
31160 - rel->r_offset = elf32_to_cpu(rel->r_offset);
31161 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
31162 rel->r_info = elf32_to_cpu(rel->r_info);
31163 }
31164 }
31165 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
31166
31167 static void print_absolute_symbols(void)
31168 {
31169 - int i;
31170 + unsigned int i;
31171 printf("Absolute symbols\n");
31172 printf(" Num: Value Size Type Bind Visibility Name\n");
31173 for (i = 0; i < ehdr.e_shnum; i++) {
31174 struct section *sec = &secs[i];
31175 char *sym_strtab;
31176 - int j;
31177 + unsigned int j;
31178
31179 if (sec->shdr.sh_type != SHT_SYMTAB) {
31180 continue;
31181 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
31182
31183 static void print_absolute_relocs(void)
31184 {
31185 - int i, printed = 0;
31186 + unsigned int i, printed = 0;
31187
31188 for (i = 0; i < ehdr.e_shnum; i++) {
31189 struct section *sec = &secs[i];
31190 struct section *sec_applies, *sec_symtab;
31191 char *sym_strtab;
31192 Elf32_Sym *sh_symtab;
31193 - int j;
31194 + unsigned int j;
31195 if (sec->shdr.sh_type != SHT_REL) {
31196 continue;
31197 }
31198 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
31199 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31200 int use_real_mode)
31201 {
31202 - int i;
31203 + unsigned int i;
31204 /* Walk through the relocations */
31205 for (i = 0; i < ehdr.e_shnum; i++) {
31206 char *sym_strtab;
31207 Elf32_Sym *sh_symtab;
31208 struct section *sec_applies, *sec_symtab;
31209 - int j;
31210 + unsigned int j;
31211 struct section *sec = &secs[i];
31212
31213 if (sec->shdr.sh_type != SHT_REL) {
31214 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31215 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
31216 r_type = ELF32_R_TYPE(rel->r_info);
31217
31218 + if (!use_real_mode) {
31219 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31220 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31221 + continue;
31222 +
31223 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
31224 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31225 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31226 + continue;
31227 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31228 + continue;
31229 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31230 + continue;
31231 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31232 + continue;
31233 +#endif
31234 + }
31235 +
31236 shn_abs = sym->st_shndx == SHN_ABS;
31237
31238 switch (r_type) {
31239 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
31240
31241 static void emit_relocs(int as_text, int use_real_mode)
31242 {
31243 - int i;
31244 + unsigned int i;
31245 /* Count how many relocations I have and allocate space for them. */
31246 reloc_count = 0;
31247 walk_relocs(count_reloc, use_real_mode);
31248 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
31249 fname, strerror(errno));
31250 }
31251 read_ehdr(fp);
31252 + read_phdrs(fp);
31253 read_shdrs(fp);
31254 read_strtabs(fp);
31255 read_symtabs(fp);
31256 - read_relocs(fp);
31257 + read_relocs(fp, use_real_mode);
31258 if (show_absolute_syms) {
31259 print_absolute_symbols();
31260 goto out;
31261 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31262 index fd14be1..e3c79c0 100644
31263 --- a/arch/x86/vdso/Makefile
31264 +++ b/arch/x86/vdso/Makefile
31265 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31266 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31267 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31268
31269 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31270 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31271 GCOV_PROFILE := n
31272
31273 #
31274 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31275 index 0faad64..39ef157 100644
31276 --- a/arch/x86/vdso/vdso32-setup.c
31277 +++ b/arch/x86/vdso/vdso32-setup.c
31278 @@ -25,6 +25,7 @@
31279 #include <asm/tlbflush.h>
31280 #include <asm/vdso.h>
31281 #include <asm/proto.h>
31282 +#include <asm/mman.h>
31283
31284 enum {
31285 VDSO_DISABLED = 0,
31286 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31287 void enable_sep_cpu(void)
31288 {
31289 int cpu = get_cpu();
31290 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31291 + struct tss_struct *tss = init_tss + cpu;
31292
31293 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31294 put_cpu();
31295 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31296 gate_vma.vm_start = FIXADDR_USER_START;
31297 gate_vma.vm_end = FIXADDR_USER_END;
31298 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31299 - gate_vma.vm_page_prot = __P101;
31300 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31301
31302 return 0;
31303 }
31304 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31305 if (compat)
31306 addr = VDSO_HIGH_BASE;
31307 else {
31308 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31309 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31310 if (IS_ERR_VALUE(addr)) {
31311 ret = addr;
31312 goto up_fail;
31313 }
31314 }
31315
31316 - current->mm->context.vdso = (void *)addr;
31317 + current->mm->context.vdso = addr;
31318
31319 if (compat_uses_vma || !compat) {
31320 /*
31321 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31322 }
31323
31324 current_thread_info()->sysenter_return =
31325 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31326 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31327
31328 up_fail:
31329 if (ret)
31330 - current->mm->context.vdso = NULL;
31331 + current->mm->context.vdso = 0;
31332
31333 up_write(&mm->mmap_sem);
31334
31335 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31336
31337 const char *arch_vma_name(struct vm_area_struct *vma)
31338 {
31339 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31340 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31341 return "[vdso]";
31342 +
31343 +#ifdef CONFIG_PAX_SEGMEXEC
31344 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31345 + return "[vdso]";
31346 +#endif
31347 +
31348 return NULL;
31349 }
31350
31351 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31352 * Check to see if the corresponding task was created in compat vdso
31353 * mode.
31354 */
31355 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31356 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31357 return &gate_vma;
31358 return NULL;
31359 }
31360 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31361 index 431e875..cbb23f3 100644
31362 --- a/arch/x86/vdso/vma.c
31363 +++ b/arch/x86/vdso/vma.c
31364 @@ -16,8 +16,6 @@
31365 #include <asm/vdso.h>
31366 #include <asm/page.h>
31367
31368 -unsigned int __read_mostly vdso_enabled = 1;
31369 -
31370 extern char vdso_start[], vdso_end[];
31371 extern unsigned short vdso_sync_cpuid;
31372
31373 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31374 * unaligned here as a result of stack start randomization.
31375 */
31376 addr = PAGE_ALIGN(addr);
31377 - addr = align_vdso_addr(addr);
31378
31379 return addr;
31380 }
31381 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31382 unsigned size)
31383 {
31384 struct mm_struct *mm = current->mm;
31385 - unsigned long addr;
31386 + unsigned long addr = 0;
31387 int ret;
31388
31389 - if (!vdso_enabled)
31390 - return 0;
31391 -
31392 down_write(&mm->mmap_sem);
31393 +
31394 +#ifdef CONFIG_PAX_RANDMMAP
31395 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31396 +#endif
31397 +
31398 addr = vdso_addr(mm->start_stack, size);
31399 + addr = align_vdso_addr(addr);
31400 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31401 if (IS_ERR_VALUE(addr)) {
31402 ret = addr;
31403 goto up_fail;
31404 }
31405
31406 - current->mm->context.vdso = (void *)addr;
31407 + mm->context.vdso = addr;
31408
31409 ret = install_special_mapping(mm, addr, size,
31410 VM_READ|VM_EXEC|
31411 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31412 pages);
31413 - if (ret) {
31414 - current->mm->context.vdso = NULL;
31415 - goto up_fail;
31416 - }
31417 + if (ret)
31418 + mm->context.vdso = 0;
31419
31420 up_fail:
31421 up_write(&mm->mmap_sem);
31422 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31423 vdsox32_size);
31424 }
31425 #endif
31426 -
31427 -static __init int vdso_setup(char *s)
31428 -{
31429 - vdso_enabled = simple_strtoul(s, NULL, 0);
31430 - return 0;
31431 -}
31432 -__setup("vdso=", vdso_setup);
31433 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31434 index 2262003..3ee61cf 100644
31435 --- a/arch/x86/xen/enlighten.c
31436 +++ b/arch/x86/xen/enlighten.c
31437 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31438
31439 struct shared_info xen_dummy_shared_info;
31440
31441 -void *xen_initial_gdt;
31442 -
31443 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31444 __read_mostly int xen_have_vector_callback;
31445 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31446 @@ -496,8 +494,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31447 {
31448 unsigned long va = dtr->address;
31449 unsigned int size = dtr->size + 1;
31450 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31451 - unsigned long frames[pages];
31452 + unsigned long frames[65536 / PAGE_SIZE];
31453 int f;
31454
31455 /*
31456 @@ -545,8 +542,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31457 {
31458 unsigned long va = dtr->address;
31459 unsigned int size = dtr->size + 1;
31460 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31461 - unsigned long frames[pages];
31462 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31463 int f;
31464
31465 /*
31466 @@ -554,7 +550,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31467 * 8-byte entries, or 16 4k pages..
31468 */
31469
31470 - BUG_ON(size > 65536);
31471 + BUG_ON(size > GDT_SIZE);
31472 BUG_ON(va & ~PAGE_MASK);
31473
31474 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31475 @@ -939,7 +935,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31476 return 0;
31477 }
31478
31479 -static void set_xen_basic_apic_ops(void)
31480 +static void __init set_xen_basic_apic_ops(void)
31481 {
31482 apic->read = xen_apic_read;
31483 apic->write = xen_apic_write;
31484 @@ -1245,30 +1241,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31485 #endif
31486 };
31487
31488 -static void xen_reboot(int reason)
31489 +static __noreturn void xen_reboot(int reason)
31490 {
31491 struct sched_shutdown r = { .reason = reason };
31492
31493 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31494 - BUG();
31495 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31496 + BUG();
31497 }
31498
31499 -static void xen_restart(char *msg)
31500 +static __noreturn void xen_restart(char *msg)
31501 {
31502 xen_reboot(SHUTDOWN_reboot);
31503 }
31504
31505 -static void xen_emergency_restart(void)
31506 +static __noreturn void xen_emergency_restart(void)
31507 {
31508 xen_reboot(SHUTDOWN_reboot);
31509 }
31510
31511 -static void xen_machine_halt(void)
31512 +static __noreturn void xen_machine_halt(void)
31513 {
31514 xen_reboot(SHUTDOWN_poweroff);
31515 }
31516
31517 -static void xen_machine_power_off(void)
31518 +static __noreturn void xen_machine_power_off(void)
31519 {
31520 if (pm_power_off)
31521 pm_power_off();
31522 @@ -1370,7 +1366,17 @@ asmlinkage void __init xen_start_kernel(void)
31523 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31524
31525 /* Work out if we support NX */
31526 - x86_configure_nx();
31527 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31528 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31529 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31530 + unsigned l, h;
31531 +
31532 + __supported_pte_mask |= _PAGE_NX;
31533 + rdmsr(MSR_EFER, l, h);
31534 + l |= EFER_NX;
31535 + wrmsr(MSR_EFER, l, h);
31536 + }
31537 +#endif
31538
31539 xen_setup_features();
31540
31541 @@ -1401,13 +1407,6 @@ asmlinkage void __init xen_start_kernel(void)
31542
31543 machine_ops = xen_machine_ops;
31544
31545 - /*
31546 - * The only reliable way to retain the initial address of the
31547 - * percpu gdt_page is to remember it here, so we can go and
31548 - * mark it RW later, when the initial percpu area is freed.
31549 - */
31550 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31551 -
31552 xen_smp_init();
31553
31554 #ifdef CONFIG_ACPI_NUMA
31555 @@ -1598,7 +1597,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31556 return NOTIFY_OK;
31557 }
31558
31559 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31560 +static struct notifier_block xen_hvm_cpu_notifier = {
31561 .notifier_call = xen_hvm_cpu_notify,
31562 };
31563
31564 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31565 index 01de35c..692023f 100644
31566 --- a/arch/x86/xen/mmu.c
31567 +++ b/arch/x86/xen/mmu.c
31568 @@ -1739,14 +1739,18 @@ static void *m2v(phys_addr_t maddr)
31569 }
31570
31571 /* Set the page permissions on an identity-mapped pages */
31572 -static void set_page_prot(void *addr, pgprot_t prot)
31573 +static void set_page_prot_flags(void *addr, pgprot_t prot, unsigned long flags)
31574 {
31575 unsigned long pfn = __pa(addr) >> PAGE_SHIFT;
31576 pte_t pte = pfn_pte(pfn, prot);
31577
31578 - if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, 0))
31579 + if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, flags))
31580 BUG();
31581 }
31582 +static void set_page_prot(void *addr, pgprot_t prot)
31583 +{
31584 + return set_page_prot_flags(addr, prot, UVMF_NONE);
31585 +}
31586 #ifdef CONFIG_X86_32
31587 static void __init xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
31588 {
31589 @@ -1830,12 +1834,12 @@ static void __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
31590 unsigned long addr)
31591 {
31592 if (*pt_base == PFN_DOWN(__pa(addr))) {
31593 - set_page_prot((void *)addr, PAGE_KERNEL);
31594 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
31595 clear_page((void *)addr);
31596 (*pt_base)++;
31597 }
31598 if (*pt_end == PFN_DOWN(__pa(addr))) {
31599 - set_page_prot((void *)addr, PAGE_KERNEL);
31600 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
31601 clear_page((void *)addr);
31602 (*pt_end)--;
31603 }
31604 @@ -1881,6 +1885,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31605 /* L3_k[510] -> level2_kernel_pgt
31606 * L3_i[511] -> level2_fixmap_pgt */
31607 convert_pfn_mfn(level3_kernel_pgt);
31608 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31609 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31610 + convert_pfn_mfn(level3_vmemmap_pgt);
31611
31612 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31613 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31614 @@ -1910,8 +1917,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31615 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31616 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31617 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31618 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31619 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31620 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31621 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31622 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31623 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31624 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31625 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31626
31627 @@ -2097,6 +2108,7 @@ static void __init xen_post_allocator_init(void)
31628 pv_mmu_ops.set_pud = xen_set_pud;
31629 #if PAGETABLE_LEVELS == 4
31630 pv_mmu_ops.set_pgd = xen_set_pgd;
31631 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31632 #endif
31633
31634 /* This will work as long as patching hasn't happened yet
31635 @@ -2178,6 +2190,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31636 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31637 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31638 .set_pgd = xen_set_pgd_hyper,
31639 + .set_pgd_batched = xen_set_pgd_hyper,
31640
31641 .alloc_pud = xen_alloc_pmd_init,
31642 .release_pud = xen_release_pmd_init,
31643 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31644 index 34bc4ce..c34aa24 100644
31645 --- a/arch/x86/xen/smp.c
31646 +++ b/arch/x86/xen/smp.c
31647 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31648 {
31649 BUG_ON(smp_processor_id() != 0);
31650 native_smp_prepare_boot_cpu();
31651 -
31652 - /* We've switched to the "real" per-cpu gdt, so make sure the
31653 - old memory can be recycled */
31654 - make_lowmem_page_readwrite(xen_initial_gdt);
31655 -
31656 xen_filter_cpu_maps();
31657 xen_setup_vcpu_info_placement();
31658 }
31659 @@ -300,12 +295,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31660 gdt = get_cpu_gdt_table(cpu);
31661
31662 ctxt->flags = VGCF_IN_KERNEL;
31663 - ctxt->user_regs.ds = __USER_DS;
31664 - ctxt->user_regs.es = __USER_DS;
31665 + ctxt->user_regs.ds = __KERNEL_DS;
31666 + ctxt->user_regs.es = __KERNEL_DS;
31667 ctxt->user_regs.ss = __KERNEL_DS;
31668 #ifdef CONFIG_X86_32
31669 ctxt->user_regs.fs = __KERNEL_PERCPU;
31670 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31671 + savesegment(gs, ctxt->user_regs.gs);
31672 #else
31673 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31674 #endif
31675 @@ -355,13 +350,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31676 int rc;
31677
31678 per_cpu(current_task, cpu) = idle;
31679 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31680 #ifdef CONFIG_X86_32
31681 irq_ctx_init(cpu);
31682 #else
31683 clear_tsk_thread_flag(idle, TIF_FORK);
31684 - per_cpu(kernel_stack, cpu) =
31685 - (unsigned long)task_stack_page(idle) -
31686 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31687 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31688 #endif
31689 xen_setup_runstate_info(cpu);
31690 xen_setup_timer(cpu);
31691 @@ -630,7 +624,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31692
31693 void __init xen_smp_init(void)
31694 {
31695 - smp_ops = xen_smp_ops;
31696 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31697 xen_fill_possible_map();
31698 xen_init_spinlocks();
31699 }
31700 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31701 index 33ca6e4..0ded929 100644
31702 --- a/arch/x86/xen/xen-asm_32.S
31703 +++ b/arch/x86/xen/xen-asm_32.S
31704 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31705 ESP_OFFSET=4 # bytes pushed onto stack
31706
31707 /*
31708 - * Store vcpu_info pointer for easy access. Do it this way to
31709 - * avoid having to reload %fs
31710 + * Store vcpu_info pointer for easy access.
31711 */
31712 #ifdef CONFIG_SMP
31713 - GET_THREAD_INFO(%eax)
31714 - movl %ss:TI_cpu(%eax), %eax
31715 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31716 - mov %ss:xen_vcpu(%eax), %eax
31717 + push %fs
31718 + mov $(__KERNEL_PERCPU), %eax
31719 + mov %eax, %fs
31720 + mov PER_CPU_VAR(xen_vcpu), %eax
31721 + pop %fs
31722 #else
31723 movl %ss:xen_vcpu, %eax
31724 #endif
31725 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31726 index 7faed58..ba4427c 100644
31727 --- a/arch/x86/xen/xen-head.S
31728 +++ b/arch/x86/xen/xen-head.S
31729 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31730 #ifdef CONFIG_X86_32
31731 mov %esi,xen_start_info
31732 mov $init_thread_union+THREAD_SIZE,%esp
31733 +#ifdef CONFIG_SMP
31734 + movl $cpu_gdt_table,%edi
31735 + movl $__per_cpu_load,%eax
31736 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31737 + rorl $16,%eax
31738 + movb %al,__KERNEL_PERCPU + 4(%edi)
31739 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31740 + movl $__per_cpu_end - 1,%eax
31741 + subl $__per_cpu_start,%eax
31742 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31743 +#endif
31744 #else
31745 mov %rsi,xen_start_info
31746 mov $init_thread_union+THREAD_SIZE,%rsp
31747 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31748 index a95b417..b6dbd0b 100644
31749 --- a/arch/x86/xen/xen-ops.h
31750 +++ b/arch/x86/xen/xen-ops.h
31751 @@ -10,8 +10,6 @@
31752 extern const char xen_hypervisor_callback[];
31753 extern const char xen_failsafe_callback[];
31754
31755 -extern void *xen_initial_gdt;
31756 -
31757 struct trap_info;
31758 void xen_copy_trap_info(struct trap_info *traps);
31759
31760 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31761 index 525bd3d..ef888b1 100644
31762 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31763 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31764 @@ -119,9 +119,9 @@
31765 ----------------------------------------------------------------------*/
31766
31767 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31768 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31769 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31770 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31771 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31772
31773 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31774 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31775 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31776 index 2f33760..835e50a 100644
31777 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31778 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31779 @@ -11,6 +11,7 @@
31780 #ifndef _XTENSA_CORE_H
31781 #define _XTENSA_CORE_H
31782
31783 +#include <linux/const.h>
31784
31785 /****************************************************************************
31786 Parameters Useful for Any Code, USER or PRIVILEGED
31787 @@ -112,9 +113,9 @@
31788 ----------------------------------------------------------------------*/
31789
31790 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31791 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31792 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31793 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31794 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31795
31796 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31797 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31798 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31799 index af00795..2bb8105 100644
31800 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31801 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31802 @@ -11,6 +11,7 @@
31803 #ifndef _XTENSA_CORE_CONFIGURATION_H
31804 #define _XTENSA_CORE_CONFIGURATION_H
31805
31806 +#include <linux/const.h>
31807
31808 /****************************************************************************
31809 Parameters Useful for Any Code, USER or PRIVILEGED
31810 @@ -118,9 +119,9 @@
31811 ----------------------------------------------------------------------*/
31812
31813 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31814 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31815 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31816 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31817 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31818
31819 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31820 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31821 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31822 index 58916af..eb9dbcf6 100644
31823 --- a/block/blk-iopoll.c
31824 +++ b/block/blk-iopoll.c
31825 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31826 }
31827 EXPORT_SYMBOL(blk_iopoll_complete);
31828
31829 -static void blk_iopoll_softirq(struct softirq_action *h)
31830 +static void blk_iopoll_softirq(void)
31831 {
31832 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31833 int rearm = 0, budget = blk_iopoll_budget;
31834 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31835 return NOTIFY_OK;
31836 }
31837
31838 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31839 +static struct notifier_block blk_iopoll_cpu_notifier = {
31840 .notifier_call = blk_iopoll_cpu_notify,
31841 };
31842
31843 diff --git a/block/blk-map.c b/block/blk-map.c
31844 index 623e1cd..ca1e109 100644
31845 --- a/block/blk-map.c
31846 +++ b/block/blk-map.c
31847 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31848 if (!len || !kbuf)
31849 return -EINVAL;
31850
31851 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31852 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31853 if (do_copy)
31854 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31855 else
31856 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31857 index 467c8de..f3628c5 100644
31858 --- a/block/blk-softirq.c
31859 +++ b/block/blk-softirq.c
31860 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31861 * Softirq action handler - move entries to local list and loop over them
31862 * while passing them to the queue registered handler.
31863 */
31864 -static void blk_done_softirq(struct softirq_action *h)
31865 +static void blk_done_softirq(void)
31866 {
31867 struct list_head *cpu_list, local_list;
31868
31869 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31870 return NOTIFY_OK;
31871 }
31872
31873 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31874 +static struct notifier_block blk_cpu_notifier = {
31875 .notifier_call = blk_cpu_notify,
31876 };
31877
31878 diff --git a/block/bsg.c b/block/bsg.c
31879 index ff64ae3..593560c 100644
31880 --- a/block/bsg.c
31881 +++ b/block/bsg.c
31882 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31883 struct sg_io_v4 *hdr, struct bsg_device *bd,
31884 fmode_t has_write_perm)
31885 {
31886 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31887 + unsigned char *cmdptr;
31888 +
31889 if (hdr->request_len > BLK_MAX_CDB) {
31890 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31891 if (!rq->cmd)
31892 return -ENOMEM;
31893 - }
31894 + cmdptr = rq->cmd;
31895 + } else
31896 + cmdptr = tmpcmd;
31897
31898 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31899 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31900 hdr->request_len))
31901 return -EFAULT;
31902
31903 + if (cmdptr != rq->cmd)
31904 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31905 +
31906 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31907 if (blk_verify_command(rq->cmd, has_write_perm))
31908 return -EPERM;
31909 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31910 index 7c668c8..db3521c 100644
31911 --- a/block/compat_ioctl.c
31912 +++ b/block/compat_ioctl.c
31913 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31914 err |= __get_user(f->spec1, &uf->spec1);
31915 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31916 err |= __get_user(name, &uf->name);
31917 - f->name = compat_ptr(name);
31918 + f->name = (void __force_kernel *)compat_ptr(name);
31919 if (err) {
31920 err = -EFAULT;
31921 goto out;
31922 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31923 index b62fb88..bdab4c4 100644
31924 --- a/block/partitions/efi.c
31925 +++ b/block/partitions/efi.c
31926 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31927 if (!gpt)
31928 return NULL;
31929
31930 + if (!le32_to_cpu(gpt->num_partition_entries))
31931 + return NULL;
31932 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31933 + if (!pte)
31934 + return NULL;
31935 +
31936 count = le32_to_cpu(gpt->num_partition_entries) *
31937 le32_to_cpu(gpt->sizeof_partition_entry);
31938 - if (!count)
31939 - return NULL;
31940 - pte = kzalloc(count, GFP_KERNEL);
31941 - if (!pte)
31942 - return NULL;
31943 -
31944 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31945 (u8 *) pte,
31946 count) < count) {
31947 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31948 index 9a87daa..fb17486 100644
31949 --- a/block/scsi_ioctl.c
31950 +++ b/block/scsi_ioctl.c
31951 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
31952 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31953 struct sg_io_hdr *hdr, fmode_t mode)
31954 {
31955 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31956 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31957 + unsigned char *cmdptr;
31958 +
31959 + if (rq->cmd != rq->__cmd)
31960 + cmdptr = rq->cmd;
31961 + else
31962 + cmdptr = tmpcmd;
31963 +
31964 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31965 return -EFAULT;
31966 +
31967 + if (cmdptr != rq->cmd)
31968 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31969 +
31970 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31971 return -EPERM;
31972
31973 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31974 int err;
31975 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31976 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31977 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31978 + unsigned char *cmdptr;
31979
31980 if (!sic)
31981 return -EINVAL;
31982 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31983 */
31984 err = -EFAULT;
31985 rq->cmd_len = cmdlen;
31986 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31987 +
31988 + if (rq->cmd != rq->__cmd)
31989 + cmdptr = rq->cmd;
31990 + else
31991 + cmdptr = tmpcmd;
31992 +
31993 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31994 goto error;
31995
31996 + if (rq->cmd != cmdptr)
31997 + memcpy(rq->cmd, cmdptr, cmdlen);
31998 +
31999 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
32000 goto error;
32001
32002 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
32003 index 7bdd61b..afec999 100644
32004 --- a/crypto/cryptd.c
32005 +++ b/crypto/cryptd.c
32006 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
32007
32008 struct cryptd_blkcipher_request_ctx {
32009 crypto_completion_t complete;
32010 -};
32011 +} __no_const;
32012
32013 struct cryptd_hash_ctx {
32014 struct crypto_shash *child;
32015 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
32016
32017 struct cryptd_aead_request_ctx {
32018 crypto_completion_t complete;
32019 -};
32020 +} __no_const;
32021
32022 static void cryptd_queue_worker(struct work_struct *work);
32023
32024 diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
32025 index f6d9baf..dfd511f 100644
32026 --- a/crypto/crypto_user.c
32027 +++ b/crypto/crypto_user.c
32028 @@ -30,6 +30,8 @@
32029
32030 #include "internal.h"
32031
32032 +#define null_terminated(x) (strnlen(x, sizeof(x)) < sizeof(x))
32033 +
32034 static DEFINE_MUTEX(crypto_cfg_mutex);
32035
32036 /* The crypto netlink socket */
32037 @@ -196,7 +198,10 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
32038 struct crypto_dump_info info;
32039 int err;
32040
32041 - if (!p->cru_driver_name)
32042 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32043 + return -EINVAL;
32044 +
32045 + if (!p->cru_driver_name[0])
32046 return -EINVAL;
32047
32048 alg = crypto_alg_match(p, 1);
32049 @@ -260,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32050 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32051 LIST_HEAD(list);
32052
32053 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32054 + return -EINVAL;
32055 +
32056 if (priority && !strlen(p->cru_driver_name))
32057 return -EINVAL;
32058
32059 @@ -287,6 +295,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32060 struct crypto_alg *alg;
32061 struct crypto_user_alg *p = nlmsg_data(nlh);
32062
32063 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32064 + return -EINVAL;
32065 +
32066 alg = crypto_alg_match(p, 1);
32067 if (!alg)
32068 return -ENOENT;
32069 @@ -368,6 +379,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32070 struct crypto_user_alg *p = nlmsg_data(nlh);
32071 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32072
32073 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32074 + return -EINVAL;
32075 +
32076 if (strlen(p->cru_driver_name))
32077 exact = 1;
32078
32079 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
32080 index f220d64..d359ad6 100644
32081 --- a/drivers/acpi/apei/apei-internal.h
32082 +++ b/drivers/acpi/apei/apei-internal.h
32083 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
32084 struct apei_exec_ins_type {
32085 u32 flags;
32086 apei_exec_ins_func_t run;
32087 -};
32088 +} __do_const;
32089
32090 struct apei_exec_context {
32091 u32 ip;
32092 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
32093 index e6defd8..c26a225 100644
32094 --- a/drivers/acpi/apei/cper.c
32095 +++ b/drivers/acpi/apei/cper.c
32096 @@ -38,12 +38,12 @@
32097 */
32098 u64 cper_next_record_id(void)
32099 {
32100 - static atomic64_t seq;
32101 + static atomic64_unchecked_t seq;
32102
32103 - if (!atomic64_read(&seq))
32104 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
32105 + if (!atomic64_read_unchecked(&seq))
32106 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
32107
32108 - return atomic64_inc_return(&seq);
32109 + return atomic64_inc_return_unchecked(&seq);
32110 }
32111 EXPORT_SYMBOL_GPL(cper_next_record_id);
32112
32113 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
32114 index be60399..778b33e8 100644
32115 --- a/drivers/acpi/bgrt.c
32116 +++ b/drivers/acpi/bgrt.c
32117 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
32118 return -ENODEV;
32119
32120 sysfs_bin_attr_init(&image_attr);
32121 - image_attr.private = bgrt_image;
32122 - image_attr.size = bgrt_image_size;
32123 + pax_open_kernel();
32124 + *(void **)&image_attr.private = bgrt_image;
32125 + *(size_t *)&image_attr.size = bgrt_image_size;
32126 + pax_close_kernel();
32127
32128 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
32129 if (!bgrt_kobj)
32130 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
32131 index cb96296..b81293b 100644
32132 --- a/drivers/acpi/blacklist.c
32133 +++ b/drivers/acpi/blacklist.c
32134 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
32135 u32 is_critical_error;
32136 };
32137
32138 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
32139 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
32140
32141 /*
32142 * POLICY: If *anything* doesn't work, put it on the blacklist.
32143 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
32144 return 0;
32145 }
32146
32147 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
32148 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
32149 {
32150 .callback = dmi_disable_osi_vista,
32151 .ident = "Fujitsu Siemens",
32152 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
32153 index 7586544..636a2f0 100644
32154 --- a/drivers/acpi/ec_sys.c
32155 +++ b/drivers/acpi/ec_sys.c
32156 @@ -12,6 +12,7 @@
32157 #include <linux/acpi.h>
32158 #include <linux/debugfs.h>
32159 #include <linux/module.h>
32160 +#include <linux/uaccess.h>
32161 #include "internal.h"
32162
32163 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
32164 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32165 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
32166 */
32167 unsigned int size = EC_SPACE_SIZE;
32168 - u8 *data = (u8 *) buf;
32169 + u8 data;
32170 loff_t init_off = *off;
32171 int err = 0;
32172
32173 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32174 size = count;
32175
32176 while (size) {
32177 - err = ec_read(*off, &data[*off - init_off]);
32178 + err = ec_read(*off, &data);
32179 if (err)
32180 return err;
32181 + if (put_user(data, &buf[*off - init_off]))
32182 + return -EFAULT;
32183 *off += 1;
32184 size--;
32185 }
32186 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32187
32188 unsigned int size = count;
32189 loff_t init_off = *off;
32190 - u8 *data = (u8 *) buf;
32191 int err = 0;
32192
32193 if (*off >= EC_SPACE_SIZE)
32194 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32195 }
32196
32197 while (size) {
32198 - u8 byte_write = data[*off - init_off];
32199 + u8 byte_write;
32200 + if (get_user(byte_write, &buf[*off - init_off]))
32201 + return -EFAULT;
32202 err = ec_write(*off, byte_write);
32203 if (err)
32204 return err;
32205 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
32206 index e83311b..142b5cc 100644
32207 --- a/drivers/acpi/processor_driver.c
32208 +++ b/drivers/acpi/processor_driver.c
32209 @@ -558,7 +558,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
32210 return 0;
32211 #endif
32212
32213 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
32214 + BUG_ON(pr->id >= nr_cpu_ids);
32215
32216 /*
32217 * Buggy BIOS check
32218 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
32219 index ed9a1cc..f4a354c 100644
32220 --- a/drivers/acpi/processor_idle.c
32221 +++ b/drivers/acpi/processor_idle.c
32222 @@ -1005,7 +1005,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32223 {
32224 int i, count = CPUIDLE_DRIVER_STATE_START;
32225 struct acpi_processor_cx *cx;
32226 - struct cpuidle_state *state;
32227 + cpuidle_state_no_const *state;
32228 struct cpuidle_driver *drv = &acpi_idle_driver;
32229
32230 if (!pr->flags.power_setup_done)
32231 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32232 index ea61ca9..3fdd70d 100644
32233 --- a/drivers/acpi/sysfs.c
32234 +++ b/drivers/acpi/sysfs.c
32235 @@ -420,11 +420,11 @@ static u32 num_counters;
32236 static struct attribute **all_attrs;
32237 static u32 acpi_gpe_count;
32238
32239 -static struct attribute_group interrupt_stats_attr_group = {
32240 +static attribute_group_no_const interrupt_stats_attr_group = {
32241 .name = "interrupts",
32242 };
32243
32244 -static struct kobj_attribute *counter_attrs;
32245 +static kobj_attribute_no_const *counter_attrs;
32246
32247 static void delete_gpe_attr_array(void)
32248 {
32249 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32250 index 6cd7805..07facb3 100644
32251 --- a/drivers/ata/libahci.c
32252 +++ b/drivers/ata/libahci.c
32253 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32254 }
32255 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32256
32257 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32258 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32259 struct ata_taskfile *tf, int is_cmd, u16 flags,
32260 unsigned long timeout_msec)
32261 {
32262 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32263 index 501c209..5f28b4d 100644
32264 --- a/drivers/ata/libata-core.c
32265 +++ b/drivers/ata/libata-core.c
32266 @@ -4784,7 +4784,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32267 struct ata_port *ap;
32268 unsigned int tag;
32269
32270 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32271 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32272 ap = qc->ap;
32273
32274 qc->flags = 0;
32275 @@ -4800,7 +4800,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32276 struct ata_port *ap;
32277 struct ata_link *link;
32278
32279 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32280 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32281 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32282 ap = qc->ap;
32283 link = qc->dev->link;
32284 @@ -5896,6 +5896,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32285 return;
32286
32287 spin_lock(&lock);
32288 + pax_open_kernel();
32289
32290 for (cur = ops->inherits; cur; cur = cur->inherits) {
32291 void **inherit = (void **)cur;
32292 @@ -5909,8 +5910,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32293 if (IS_ERR(*pp))
32294 *pp = NULL;
32295
32296 - ops->inherits = NULL;
32297 + *(struct ata_port_operations **)&ops->inherits = NULL;
32298
32299 + pax_close_kernel();
32300 spin_unlock(&lock);
32301 }
32302
32303 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32304 index 405022d..fb70e53 100644
32305 --- a/drivers/ata/pata_arasan_cf.c
32306 +++ b/drivers/ata/pata_arasan_cf.c
32307 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32308 /* Handle platform specific quirks */
32309 if (pdata->quirk) {
32310 if (pdata->quirk & CF_BROKEN_PIO) {
32311 - ap->ops->set_piomode = NULL;
32312 + pax_open_kernel();
32313 + *(void **)&ap->ops->set_piomode = NULL;
32314 + pax_close_kernel();
32315 ap->pio_mask = 0;
32316 }
32317 if (pdata->quirk & CF_BROKEN_MWDMA)
32318 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32319 index f9b983a..887b9d8 100644
32320 --- a/drivers/atm/adummy.c
32321 +++ b/drivers/atm/adummy.c
32322 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32323 vcc->pop(vcc, skb);
32324 else
32325 dev_kfree_skb_any(skb);
32326 - atomic_inc(&vcc->stats->tx);
32327 + atomic_inc_unchecked(&vcc->stats->tx);
32328
32329 return 0;
32330 }
32331 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32332 index 77a7480..05cde58 100644
32333 --- a/drivers/atm/ambassador.c
32334 +++ b/drivers/atm/ambassador.c
32335 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32336 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32337
32338 // VC layer stats
32339 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32340 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32341
32342 // free the descriptor
32343 kfree (tx_descr);
32344 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32345 dump_skb ("<<<", vc, skb);
32346
32347 // VC layer stats
32348 - atomic_inc(&atm_vcc->stats->rx);
32349 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32350 __net_timestamp(skb);
32351 // end of our responsibility
32352 atm_vcc->push (atm_vcc, skb);
32353 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32354 } else {
32355 PRINTK (KERN_INFO, "dropped over-size frame");
32356 // should we count this?
32357 - atomic_inc(&atm_vcc->stats->rx_drop);
32358 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32359 }
32360
32361 } else {
32362 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32363 }
32364
32365 if (check_area (skb->data, skb->len)) {
32366 - atomic_inc(&atm_vcc->stats->tx_err);
32367 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32368 return -ENOMEM; // ?
32369 }
32370
32371 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32372 index b22d71c..d6e1049 100644
32373 --- a/drivers/atm/atmtcp.c
32374 +++ b/drivers/atm/atmtcp.c
32375 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32376 if (vcc->pop) vcc->pop(vcc,skb);
32377 else dev_kfree_skb(skb);
32378 if (dev_data) return 0;
32379 - atomic_inc(&vcc->stats->tx_err);
32380 + atomic_inc_unchecked(&vcc->stats->tx_err);
32381 return -ENOLINK;
32382 }
32383 size = skb->len+sizeof(struct atmtcp_hdr);
32384 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32385 if (!new_skb) {
32386 if (vcc->pop) vcc->pop(vcc,skb);
32387 else dev_kfree_skb(skb);
32388 - atomic_inc(&vcc->stats->tx_err);
32389 + atomic_inc_unchecked(&vcc->stats->tx_err);
32390 return -ENOBUFS;
32391 }
32392 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32393 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32394 if (vcc->pop) vcc->pop(vcc,skb);
32395 else dev_kfree_skb(skb);
32396 out_vcc->push(out_vcc,new_skb);
32397 - atomic_inc(&vcc->stats->tx);
32398 - atomic_inc(&out_vcc->stats->rx);
32399 + atomic_inc_unchecked(&vcc->stats->tx);
32400 + atomic_inc_unchecked(&out_vcc->stats->rx);
32401 return 0;
32402 }
32403
32404 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32405 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32406 read_unlock(&vcc_sklist_lock);
32407 if (!out_vcc) {
32408 - atomic_inc(&vcc->stats->tx_err);
32409 + atomic_inc_unchecked(&vcc->stats->tx_err);
32410 goto done;
32411 }
32412 skb_pull(skb,sizeof(struct atmtcp_hdr));
32413 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32414 __net_timestamp(new_skb);
32415 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32416 out_vcc->push(out_vcc,new_skb);
32417 - atomic_inc(&vcc->stats->tx);
32418 - atomic_inc(&out_vcc->stats->rx);
32419 + atomic_inc_unchecked(&vcc->stats->tx);
32420 + atomic_inc_unchecked(&out_vcc->stats->rx);
32421 done:
32422 if (vcc->pop) vcc->pop(vcc,skb);
32423 else dev_kfree_skb(skb);
32424 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32425 index c1eb6fa..4c71be9 100644
32426 --- a/drivers/atm/eni.c
32427 +++ b/drivers/atm/eni.c
32428 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32429 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32430 vcc->dev->number);
32431 length = 0;
32432 - atomic_inc(&vcc->stats->rx_err);
32433 + atomic_inc_unchecked(&vcc->stats->rx_err);
32434 }
32435 else {
32436 length = ATM_CELL_SIZE-1; /* no HEC */
32437 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32438 size);
32439 }
32440 eff = length = 0;
32441 - atomic_inc(&vcc->stats->rx_err);
32442 + atomic_inc_unchecked(&vcc->stats->rx_err);
32443 }
32444 else {
32445 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32446 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32447 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32448 vcc->dev->number,vcc->vci,length,size << 2,descr);
32449 length = eff = 0;
32450 - atomic_inc(&vcc->stats->rx_err);
32451 + atomic_inc_unchecked(&vcc->stats->rx_err);
32452 }
32453 }
32454 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32455 @@ -767,7 +767,7 @@ rx_dequeued++;
32456 vcc->push(vcc,skb);
32457 pushed++;
32458 }
32459 - atomic_inc(&vcc->stats->rx);
32460 + atomic_inc_unchecked(&vcc->stats->rx);
32461 }
32462 wake_up(&eni_dev->rx_wait);
32463 }
32464 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32465 PCI_DMA_TODEVICE);
32466 if (vcc->pop) vcc->pop(vcc,skb);
32467 else dev_kfree_skb_irq(skb);
32468 - atomic_inc(&vcc->stats->tx);
32469 + atomic_inc_unchecked(&vcc->stats->tx);
32470 wake_up(&eni_dev->tx_wait);
32471 dma_complete++;
32472 }
32473 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32474 index b41c948..a002b17 100644
32475 --- a/drivers/atm/firestream.c
32476 +++ b/drivers/atm/firestream.c
32477 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32478 }
32479 }
32480
32481 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32482 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32483
32484 fs_dprintk (FS_DEBUG_TXMEM, "i");
32485 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32486 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32487 #endif
32488 skb_put (skb, qe->p1 & 0xffff);
32489 ATM_SKB(skb)->vcc = atm_vcc;
32490 - atomic_inc(&atm_vcc->stats->rx);
32491 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32492 __net_timestamp(skb);
32493 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32494 atm_vcc->push (atm_vcc, skb);
32495 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32496 kfree (pe);
32497 }
32498 if (atm_vcc)
32499 - atomic_inc(&atm_vcc->stats->rx_drop);
32500 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32501 break;
32502 case 0x1f: /* Reassembly abort: no buffers. */
32503 /* Silently increment error counter. */
32504 if (atm_vcc)
32505 - atomic_inc(&atm_vcc->stats->rx_drop);
32506 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32507 break;
32508 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32509 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32510 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32511 index 204814e..cede831 100644
32512 --- a/drivers/atm/fore200e.c
32513 +++ b/drivers/atm/fore200e.c
32514 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32515 #endif
32516 /* check error condition */
32517 if (*entry->status & STATUS_ERROR)
32518 - atomic_inc(&vcc->stats->tx_err);
32519 + atomic_inc_unchecked(&vcc->stats->tx_err);
32520 else
32521 - atomic_inc(&vcc->stats->tx);
32522 + atomic_inc_unchecked(&vcc->stats->tx);
32523 }
32524 }
32525
32526 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32527 if (skb == NULL) {
32528 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32529
32530 - atomic_inc(&vcc->stats->rx_drop);
32531 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32532 return -ENOMEM;
32533 }
32534
32535 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32536
32537 dev_kfree_skb_any(skb);
32538
32539 - atomic_inc(&vcc->stats->rx_drop);
32540 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32541 return -ENOMEM;
32542 }
32543
32544 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32545
32546 vcc->push(vcc, skb);
32547 - atomic_inc(&vcc->stats->rx);
32548 + atomic_inc_unchecked(&vcc->stats->rx);
32549
32550 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32551
32552 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32553 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32554 fore200e->atm_dev->number,
32555 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32556 - atomic_inc(&vcc->stats->rx_err);
32557 + atomic_inc_unchecked(&vcc->stats->rx_err);
32558 }
32559 }
32560
32561 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32562 goto retry_here;
32563 }
32564
32565 - atomic_inc(&vcc->stats->tx_err);
32566 + atomic_inc_unchecked(&vcc->stats->tx_err);
32567
32568 fore200e->tx_sat++;
32569 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32570 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32571 index 72b6960..cf9167a 100644
32572 --- a/drivers/atm/he.c
32573 +++ b/drivers/atm/he.c
32574 @@ -1699,7 +1699,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32575
32576 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32577 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32578 - atomic_inc(&vcc->stats->rx_drop);
32579 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32580 goto return_host_buffers;
32581 }
32582
32583 @@ -1726,7 +1726,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32584 RBRQ_LEN_ERR(he_dev->rbrq_head)
32585 ? "LEN_ERR" : "",
32586 vcc->vpi, vcc->vci);
32587 - atomic_inc(&vcc->stats->rx_err);
32588 + atomic_inc_unchecked(&vcc->stats->rx_err);
32589 goto return_host_buffers;
32590 }
32591
32592 @@ -1778,7 +1778,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32593 vcc->push(vcc, skb);
32594 spin_lock(&he_dev->global_lock);
32595
32596 - atomic_inc(&vcc->stats->rx);
32597 + atomic_inc_unchecked(&vcc->stats->rx);
32598
32599 return_host_buffers:
32600 ++pdus_assembled;
32601 @@ -2104,7 +2104,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32602 tpd->vcc->pop(tpd->vcc, tpd->skb);
32603 else
32604 dev_kfree_skb_any(tpd->skb);
32605 - atomic_inc(&tpd->vcc->stats->tx_err);
32606 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32607 }
32608 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32609 return;
32610 @@ -2516,7 +2516,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32611 vcc->pop(vcc, skb);
32612 else
32613 dev_kfree_skb_any(skb);
32614 - atomic_inc(&vcc->stats->tx_err);
32615 + atomic_inc_unchecked(&vcc->stats->tx_err);
32616 return -EINVAL;
32617 }
32618
32619 @@ -2527,7 +2527,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32620 vcc->pop(vcc, skb);
32621 else
32622 dev_kfree_skb_any(skb);
32623 - atomic_inc(&vcc->stats->tx_err);
32624 + atomic_inc_unchecked(&vcc->stats->tx_err);
32625 return -EINVAL;
32626 }
32627 #endif
32628 @@ -2539,7 +2539,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32629 vcc->pop(vcc, skb);
32630 else
32631 dev_kfree_skb_any(skb);
32632 - atomic_inc(&vcc->stats->tx_err);
32633 + atomic_inc_unchecked(&vcc->stats->tx_err);
32634 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32635 return -ENOMEM;
32636 }
32637 @@ -2581,7 +2581,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32638 vcc->pop(vcc, skb);
32639 else
32640 dev_kfree_skb_any(skb);
32641 - atomic_inc(&vcc->stats->tx_err);
32642 + atomic_inc_unchecked(&vcc->stats->tx_err);
32643 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32644 return -ENOMEM;
32645 }
32646 @@ -2612,7 +2612,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32647 __enqueue_tpd(he_dev, tpd, cid);
32648 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32649
32650 - atomic_inc(&vcc->stats->tx);
32651 + atomic_inc_unchecked(&vcc->stats->tx);
32652
32653 return 0;
32654 }
32655 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32656 index 1dc0519..1aadaf7 100644
32657 --- a/drivers/atm/horizon.c
32658 +++ b/drivers/atm/horizon.c
32659 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32660 {
32661 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32662 // VC layer stats
32663 - atomic_inc(&vcc->stats->rx);
32664 + atomic_inc_unchecked(&vcc->stats->rx);
32665 __net_timestamp(skb);
32666 // end of our responsibility
32667 vcc->push (vcc, skb);
32668 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32669 dev->tx_iovec = NULL;
32670
32671 // VC layer stats
32672 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32673 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32674
32675 // free the skb
32676 hrz_kfree_skb (skb);
32677 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32678 index 272f009..a18ba55 100644
32679 --- a/drivers/atm/idt77252.c
32680 +++ b/drivers/atm/idt77252.c
32681 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32682 else
32683 dev_kfree_skb(skb);
32684
32685 - atomic_inc(&vcc->stats->tx);
32686 + atomic_inc_unchecked(&vcc->stats->tx);
32687 }
32688
32689 atomic_dec(&scq->used);
32690 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32691 if ((sb = dev_alloc_skb(64)) == NULL) {
32692 printk("%s: Can't allocate buffers for aal0.\n",
32693 card->name);
32694 - atomic_add(i, &vcc->stats->rx_drop);
32695 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32696 break;
32697 }
32698 if (!atm_charge(vcc, sb->truesize)) {
32699 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32700 card->name);
32701 - atomic_add(i - 1, &vcc->stats->rx_drop);
32702 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32703 dev_kfree_skb(sb);
32704 break;
32705 }
32706 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32707 ATM_SKB(sb)->vcc = vcc;
32708 __net_timestamp(sb);
32709 vcc->push(vcc, sb);
32710 - atomic_inc(&vcc->stats->rx);
32711 + atomic_inc_unchecked(&vcc->stats->rx);
32712
32713 cell += ATM_CELL_PAYLOAD;
32714 }
32715 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32716 "(CDC: %08x)\n",
32717 card->name, len, rpp->len, readl(SAR_REG_CDC));
32718 recycle_rx_pool_skb(card, rpp);
32719 - atomic_inc(&vcc->stats->rx_err);
32720 + atomic_inc_unchecked(&vcc->stats->rx_err);
32721 return;
32722 }
32723 if (stat & SAR_RSQE_CRC) {
32724 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32725 recycle_rx_pool_skb(card, rpp);
32726 - atomic_inc(&vcc->stats->rx_err);
32727 + atomic_inc_unchecked(&vcc->stats->rx_err);
32728 return;
32729 }
32730 if (skb_queue_len(&rpp->queue) > 1) {
32731 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32732 RXPRINTK("%s: Can't alloc RX skb.\n",
32733 card->name);
32734 recycle_rx_pool_skb(card, rpp);
32735 - atomic_inc(&vcc->stats->rx_err);
32736 + atomic_inc_unchecked(&vcc->stats->rx_err);
32737 return;
32738 }
32739 if (!atm_charge(vcc, skb->truesize)) {
32740 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32741 __net_timestamp(skb);
32742
32743 vcc->push(vcc, skb);
32744 - atomic_inc(&vcc->stats->rx);
32745 + atomic_inc_unchecked(&vcc->stats->rx);
32746
32747 return;
32748 }
32749 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32750 __net_timestamp(skb);
32751
32752 vcc->push(vcc, skb);
32753 - atomic_inc(&vcc->stats->rx);
32754 + atomic_inc_unchecked(&vcc->stats->rx);
32755
32756 if (skb->truesize > SAR_FB_SIZE_3)
32757 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32758 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32759 if (vcc->qos.aal != ATM_AAL0) {
32760 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32761 card->name, vpi, vci);
32762 - atomic_inc(&vcc->stats->rx_drop);
32763 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32764 goto drop;
32765 }
32766
32767 if ((sb = dev_alloc_skb(64)) == NULL) {
32768 printk("%s: Can't allocate buffers for AAL0.\n",
32769 card->name);
32770 - atomic_inc(&vcc->stats->rx_err);
32771 + atomic_inc_unchecked(&vcc->stats->rx_err);
32772 goto drop;
32773 }
32774
32775 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32776 ATM_SKB(sb)->vcc = vcc;
32777 __net_timestamp(sb);
32778 vcc->push(vcc, sb);
32779 - atomic_inc(&vcc->stats->rx);
32780 + atomic_inc_unchecked(&vcc->stats->rx);
32781
32782 drop:
32783 skb_pull(queue, 64);
32784 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32785
32786 if (vc == NULL) {
32787 printk("%s: NULL connection in send().\n", card->name);
32788 - atomic_inc(&vcc->stats->tx_err);
32789 + atomic_inc_unchecked(&vcc->stats->tx_err);
32790 dev_kfree_skb(skb);
32791 return -EINVAL;
32792 }
32793 if (!test_bit(VCF_TX, &vc->flags)) {
32794 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32795 - atomic_inc(&vcc->stats->tx_err);
32796 + atomic_inc_unchecked(&vcc->stats->tx_err);
32797 dev_kfree_skb(skb);
32798 return -EINVAL;
32799 }
32800 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32801 break;
32802 default:
32803 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32804 - atomic_inc(&vcc->stats->tx_err);
32805 + atomic_inc_unchecked(&vcc->stats->tx_err);
32806 dev_kfree_skb(skb);
32807 return -EINVAL;
32808 }
32809
32810 if (skb_shinfo(skb)->nr_frags != 0) {
32811 printk("%s: No scatter-gather yet.\n", card->name);
32812 - atomic_inc(&vcc->stats->tx_err);
32813 + atomic_inc_unchecked(&vcc->stats->tx_err);
32814 dev_kfree_skb(skb);
32815 return -EINVAL;
32816 }
32817 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32818
32819 err = queue_skb(card, vc, skb, oam);
32820 if (err) {
32821 - atomic_inc(&vcc->stats->tx_err);
32822 + atomic_inc_unchecked(&vcc->stats->tx_err);
32823 dev_kfree_skb(skb);
32824 return err;
32825 }
32826 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32827 skb = dev_alloc_skb(64);
32828 if (!skb) {
32829 printk("%s: Out of memory in send_oam().\n", card->name);
32830 - atomic_inc(&vcc->stats->tx_err);
32831 + atomic_inc_unchecked(&vcc->stats->tx_err);
32832 return -ENOMEM;
32833 }
32834 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32835 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32836 index 4217f29..88f547a 100644
32837 --- a/drivers/atm/iphase.c
32838 +++ b/drivers/atm/iphase.c
32839 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32840 status = (u_short) (buf_desc_ptr->desc_mode);
32841 if (status & (RX_CER | RX_PTE | RX_OFL))
32842 {
32843 - atomic_inc(&vcc->stats->rx_err);
32844 + atomic_inc_unchecked(&vcc->stats->rx_err);
32845 IF_ERR(printk("IA: bad packet, dropping it");)
32846 if (status & RX_CER) {
32847 IF_ERR(printk(" cause: packet CRC error\n");)
32848 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32849 len = dma_addr - buf_addr;
32850 if (len > iadev->rx_buf_sz) {
32851 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32852 - atomic_inc(&vcc->stats->rx_err);
32853 + atomic_inc_unchecked(&vcc->stats->rx_err);
32854 goto out_free_desc;
32855 }
32856
32857 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32858 ia_vcc = INPH_IA_VCC(vcc);
32859 if (ia_vcc == NULL)
32860 {
32861 - atomic_inc(&vcc->stats->rx_err);
32862 + atomic_inc_unchecked(&vcc->stats->rx_err);
32863 atm_return(vcc, skb->truesize);
32864 dev_kfree_skb_any(skb);
32865 goto INCR_DLE;
32866 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32867 if ((length > iadev->rx_buf_sz) || (length >
32868 (skb->len - sizeof(struct cpcs_trailer))))
32869 {
32870 - atomic_inc(&vcc->stats->rx_err);
32871 + atomic_inc_unchecked(&vcc->stats->rx_err);
32872 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32873 length, skb->len);)
32874 atm_return(vcc, skb->truesize);
32875 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32876
32877 IF_RX(printk("rx_dle_intr: skb push");)
32878 vcc->push(vcc,skb);
32879 - atomic_inc(&vcc->stats->rx);
32880 + atomic_inc_unchecked(&vcc->stats->rx);
32881 iadev->rx_pkt_cnt++;
32882 }
32883 INCR_DLE:
32884 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32885 {
32886 struct k_sonet_stats *stats;
32887 stats = &PRIV(_ia_dev[board])->sonet_stats;
32888 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32889 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32890 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32891 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32892 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32893 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32894 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32895 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32896 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32897 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32898 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32899 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32900 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32901 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32902 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32903 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32904 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32905 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32906 }
32907 ia_cmds.status = 0;
32908 break;
32909 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32910 if ((desc == 0) || (desc > iadev->num_tx_desc))
32911 {
32912 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32913 - atomic_inc(&vcc->stats->tx);
32914 + atomic_inc_unchecked(&vcc->stats->tx);
32915 if (vcc->pop)
32916 vcc->pop(vcc, skb);
32917 else
32918 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32919 ATM_DESC(skb) = vcc->vci;
32920 skb_queue_tail(&iadev->tx_dma_q, skb);
32921
32922 - atomic_inc(&vcc->stats->tx);
32923 + atomic_inc_unchecked(&vcc->stats->tx);
32924 iadev->tx_pkt_cnt++;
32925 /* Increment transaction counter */
32926 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32927
32928 #if 0
32929 /* add flow control logic */
32930 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32931 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32932 if (iavcc->vc_desc_cnt > 10) {
32933 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32934 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32935 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32936 index fa7d701..1e404c7 100644
32937 --- a/drivers/atm/lanai.c
32938 +++ b/drivers/atm/lanai.c
32939 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32940 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32941 lanai_endtx(lanai, lvcc);
32942 lanai_free_skb(lvcc->tx.atmvcc, skb);
32943 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32944 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32945 }
32946
32947 /* Try to fill the buffer - don't call unless there is backlog */
32948 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32949 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32950 __net_timestamp(skb);
32951 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32952 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32953 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32954 out:
32955 lvcc->rx.buf.ptr = end;
32956 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32957 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32958 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32959 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32960 lanai->stats.service_rxnotaal5++;
32961 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32962 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32963 return 0;
32964 }
32965 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32966 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32967 int bytes;
32968 read_unlock(&vcc_sklist_lock);
32969 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32970 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32971 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32972 lvcc->stats.x.aal5.service_trash++;
32973 bytes = (SERVICE_GET_END(s) * 16) -
32974 (((unsigned long) lvcc->rx.buf.ptr) -
32975 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32976 }
32977 if (s & SERVICE_STREAM) {
32978 read_unlock(&vcc_sklist_lock);
32979 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32980 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32981 lvcc->stats.x.aal5.service_stream++;
32982 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32983 "PDU on VCI %d!\n", lanai->number, vci);
32984 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32985 return 0;
32986 }
32987 DPRINTK("got rx crc error on vci %d\n", vci);
32988 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32989 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32990 lvcc->stats.x.aal5.service_rxcrc++;
32991 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32992 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32993 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32994 index ed1d2b7..8cffc1f 100644
32995 --- a/drivers/atm/nicstar.c
32996 +++ b/drivers/atm/nicstar.c
32997 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32998 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32999 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
33000 card->index);
33001 - atomic_inc(&vcc->stats->tx_err);
33002 + atomic_inc_unchecked(&vcc->stats->tx_err);
33003 dev_kfree_skb_any(skb);
33004 return -EINVAL;
33005 }
33006 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33007 if (!vc->tx) {
33008 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
33009 card->index);
33010 - atomic_inc(&vcc->stats->tx_err);
33011 + atomic_inc_unchecked(&vcc->stats->tx_err);
33012 dev_kfree_skb_any(skb);
33013 return -EINVAL;
33014 }
33015 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33016 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
33017 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
33018 card->index);
33019 - atomic_inc(&vcc->stats->tx_err);
33020 + atomic_inc_unchecked(&vcc->stats->tx_err);
33021 dev_kfree_skb_any(skb);
33022 return -EINVAL;
33023 }
33024
33025 if (skb_shinfo(skb)->nr_frags != 0) {
33026 printk("nicstar%d: No scatter-gather yet.\n", card->index);
33027 - atomic_inc(&vcc->stats->tx_err);
33028 + atomic_inc_unchecked(&vcc->stats->tx_err);
33029 dev_kfree_skb_any(skb);
33030 return -EINVAL;
33031 }
33032 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33033 }
33034
33035 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
33036 - atomic_inc(&vcc->stats->tx_err);
33037 + atomic_inc_unchecked(&vcc->stats->tx_err);
33038 dev_kfree_skb_any(skb);
33039 return -EIO;
33040 }
33041 - atomic_inc(&vcc->stats->tx);
33042 + atomic_inc_unchecked(&vcc->stats->tx);
33043
33044 return 0;
33045 }
33046 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33047 printk
33048 ("nicstar%d: Can't allocate buffers for aal0.\n",
33049 card->index);
33050 - atomic_add(i, &vcc->stats->rx_drop);
33051 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
33052 break;
33053 }
33054 if (!atm_charge(vcc, sb->truesize)) {
33055 RXPRINTK
33056 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
33057 card->index);
33058 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33059 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33060 dev_kfree_skb_any(sb);
33061 break;
33062 }
33063 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33064 ATM_SKB(sb)->vcc = vcc;
33065 __net_timestamp(sb);
33066 vcc->push(vcc, sb);
33067 - atomic_inc(&vcc->stats->rx);
33068 + atomic_inc_unchecked(&vcc->stats->rx);
33069 cell += ATM_CELL_PAYLOAD;
33070 }
33071
33072 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33073 if (iovb == NULL) {
33074 printk("nicstar%d: Out of iovec buffers.\n",
33075 card->index);
33076 - atomic_inc(&vcc->stats->rx_drop);
33077 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33078 recycle_rx_buf(card, skb);
33079 return;
33080 }
33081 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33082 small or large buffer itself. */
33083 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
33084 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
33085 - atomic_inc(&vcc->stats->rx_err);
33086 + atomic_inc_unchecked(&vcc->stats->rx_err);
33087 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33088 NS_MAX_IOVECS);
33089 NS_PRV_IOVCNT(iovb) = 0;
33090 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33091 ("nicstar%d: Expected a small buffer, and this is not one.\n",
33092 card->index);
33093 which_list(card, skb);
33094 - atomic_inc(&vcc->stats->rx_err);
33095 + atomic_inc_unchecked(&vcc->stats->rx_err);
33096 recycle_rx_buf(card, skb);
33097 vc->rx_iov = NULL;
33098 recycle_iov_buf(card, iovb);
33099 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33100 ("nicstar%d: Expected a large buffer, and this is not one.\n",
33101 card->index);
33102 which_list(card, skb);
33103 - atomic_inc(&vcc->stats->rx_err);
33104 + atomic_inc_unchecked(&vcc->stats->rx_err);
33105 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33106 NS_PRV_IOVCNT(iovb));
33107 vc->rx_iov = NULL;
33108 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33109 printk(" - PDU size mismatch.\n");
33110 else
33111 printk(".\n");
33112 - atomic_inc(&vcc->stats->rx_err);
33113 + atomic_inc_unchecked(&vcc->stats->rx_err);
33114 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33115 NS_PRV_IOVCNT(iovb));
33116 vc->rx_iov = NULL;
33117 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33118 /* skb points to a small buffer */
33119 if (!atm_charge(vcc, skb->truesize)) {
33120 push_rxbufs(card, skb);
33121 - atomic_inc(&vcc->stats->rx_drop);
33122 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33123 } else {
33124 skb_put(skb, len);
33125 dequeue_sm_buf(card, skb);
33126 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33127 ATM_SKB(skb)->vcc = vcc;
33128 __net_timestamp(skb);
33129 vcc->push(vcc, skb);
33130 - atomic_inc(&vcc->stats->rx);
33131 + atomic_inc_unchecked(&vcc->stats->rx);
33132 }
33133 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
33134 struct sk_buff *sb;
33135 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33136 if (len <= NS_SMBUFSIZE) {
33137 if (!atm_charge(vcc, sb->truesize)) {
33138 push_rxbufs(card, sb);
33139 - atomic_inc(&vcc->stats->rx_drop);
33140 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33141 } else {
33142 skb_put(sb, len);
33143 dequeue_sm_buf(card, sb);
33144 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33145 ATM_SKB(sb)->vcc = vcc;
33146 __net_timestamp(sb);
33147 vcc->push(vcc, sb);
33148 - atomic_inc(&vcc->stats->rx);
33149 + atomic_inc_unchecked(&vcc->stats->rx);
33150 }
33151
33152 push_rxbufs(card, skb);
33153 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33154
33155 if (!atm_charge(vcc, skb->truesize)) {
33156 push_rxbufs(card, skb);
33157 - atomic_inc(&vcc->stats->rx_drop);
33158 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33159 } else {
33160 dequeue_lg_buf(card, skb);
33161 #ifdef NS_USE_DESTRUCTORS
33162 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33163 ATM_SKB(skb)->vcc = vcc;
33164 __net_timestamp(skb);
33165 vcc->push(vcc, skb);
33166 - atomic_inc(&vcc->stats->rx);
33167 + atomic_inc_unchecked(&vcc->stats->rx);
33168 }
33169
33170 push_rxbufs(card, sb);
33171 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33172 printk
33173 ("nicstar%d: Out of huge buffers.\n",
33174 card->index);
33175 - atomic_inc(&vcc->stats->rx_drop);
33176 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33177 recycle_iovec_rx_bufs(card,
33178 (struct iovec *)
33179 iovb->data,
33180 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33181 card->hbpool.count++;
33182 } else
33183 dev_kfree_skb_any(hb);
33184 - atomic_inc(&vcc->stats->rx_drop);
33185 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33186 } else {
33187 /* Copy the small buffer to the huge buffer */
33188 sb = (struct sk_buff *)iov->iov_base;
33189 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33190 #endif /* NS_USE_DESTRUCTORS */
33191 __net_timestamp(hb);
33192 vcc->push(vcc, hb);
33193 - atomic_inc(&vcc->stats->rx);
33194 + atomic_inc_unchecked(&vcc->stats->rx);
33195 }
33196 }
33197
33198 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
33199 index 0474a89..06ea4a1 100644
33200 --- a/drivers/atm/solos-pci.c
33201 +++ b/drivers/atm/solos-pci.c
33202 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
33203 }
33204 atm_charge(vcc, skb->truesize);
33205 vcc->push(vcc, skb);
33206 - atomic_inc(&vcc->stats->rx);
33207 + atomic_inc_unchecked(&vcc->stats->rx);
33208 break;
33209
33210 case PKT_STATUS:
33211 @@ -1117,7 +1117,7 @@ static uint32_t fpga_tx(struct solos_card *card)
33212 vcc = SKB_CB(oldskb)->vcc;
33213
33214 if (vcc) {
33215 - atomic_inc(&vcc->stats->tx);
33216 + atomic_inc_unchecked(&vcc->stats->tx);
33217 solos_pop(vcc, oldskb);
33218 } else {
33219 dev_kfree_skb_irq(oldskb);
33220 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33221 index 0215934..ce9f5b1 100644
33222 --- a/drivers/atm/suni.c
33223 +++ b/drivers/atm/suni.c
33224 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33225
33226
33227 #define ADD_LIMITED(s,v) \
33228 - atomic_add((v),&stats->s); \
33229 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33230 + atomic_add_unchecked((v),&stats->s); \
33231 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33232
33233
33234 static void suni_hz(unsigned long from_timer)
33235 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33236 index 5120a96..e2572bd 100644
33237 --- a/drivers/atm/uPD98402.c
33238 +++ b/drivers/atm/uPD98402.c
33239 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33240 struct sonet_stats tmp;
33241 int error = 0;
33242
33243 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33244 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33245 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33246 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33247 if (zero && !error) {
33248 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33249
33250
33251 #define ADD_LIMITED(s,v) \
33252 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33253 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33254 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33255 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33256 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33257 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33258
33259
33260 static void stat_event(struct atm_dev *dev)
33261 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33262 if (reason & uPD98402_INT_PFM) stat_event(dev);
33263 if (reason & uPD98402_INT_PCO) {
33264 (void) GET(PCOCR); /* clear interrupt cause */
33265 - atomic_add(GET(HECCT),
33266 + atomic_add_unchecked(GET(HECCT),
33267 &PRIV(dev)->sonet_stats.uncorr_hcs);
33268 }
33269 if ((reason & uPD98402_INT_RFO) &&
33270 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33271 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33272 uPD98402_INT_LOS),PIMR); /* enable them */
33273 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33274 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33275 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33276 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33277 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33278 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33279 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33280 return 0;
33281 }
33282
33283 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33284 index 969c3c2..9b72956 100644
33285 --- a/drivers/atm/zatm.c
33286 +++ b/drivers/atm/zatm.c
33287 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33288 }
33289 if (!size) {
33290 dev_kfree_skb_irq(skb);
33291 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33292 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33293 continue;
33294 }
33295 if (!atm_charge(vcc,skb->truesize)) {
33296 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33297 skb->len = size;
33298 ATM_SKB(skb)->vcc = vcc;
33299 vcc->push(vcc,skb);
33300 - atomic_inc(&vcc->stats->rx);
33301 + atomic_inc_unchecked(&vcc->stats->rx);
33302 }
33303 zout(pos & 0xffff,MTA(mbx));
33304 #if 0 /* probably a stupid idea */
33305 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33306 skb_queue_head(&zatm_vcc->backlog,skb);
33307 break;
33308 }
33309 - atomic_inc(&vcc->stats->tx);
33310 + atomic_inc_unchecked(&vcc->stats->tx);
33311 wake_up(&zatm_vcc->tx_wait);
33312 }
33313
33314 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33315 index 6856303..0602d70 100644
33316 --- a/drivers/base/bus.c
33317 +++ b/drivers/base/bus.c
33318 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33319 return -EINVAL;
33320
33321 mutex_lock(&subsys->p->mutex);
33322 - list_add_tail(&sif->node, &subsys->p->interfaces);
33323 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33324 if (sif->add_dev) {
33325 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33326 while ((dev = subsys_dev_iter_next(&iter)))
33327 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33328 subsys = sif->subsys;
33329
33330 mutex_lock(&subsys->p->mutex);
33331 - list_del_init(&sif->node);
33332 + pax_list_del_init((struct list_head *)&sif->node);
33333 if (sif->remove_dev) {
33334 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33335 while ((dev = subsys_dev_iter_next(&iter)))
33336 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33337 index 17cf7ca..7e553e1 100644
33338 --- a/drivers/base/devtmpfs.c
33339 +++ b/drivers/base/devtmpfs.c
33340 @@ -347,7 +347,7 @@ int devtmpfs_mount(const char *mntdir)
33341 if (!thread)
33342 return 0;
33343
33344 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33345 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33346 if (err)
33347 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33348 else
33349 diff --git a/drivers/base/node.c b/drivers/base/node.c
33350 index fac124a..66bd4ab 100644
33351 --- a/drivers/base/node.c
33352 +++ b/drivers/base/node.c
33353 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33354 struct node_attr {
33355 struct device_attribute attr;
33356 enum node_states state;
33357 -};
33358 +} __do_const;
33359
33360 static ssize_t show_node_state(struct device *dev,
33361 struct device_attribute *attr, char *buf)
33362 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33363 index acc3a8d..981c236 100644
33364 --- a/drivers/base/power/domain.c
33365 +++ b/drivers/base/power/domain.c
33366 @@ -1851,7 +1851,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33367 {
33368 struct cpuidle_driver *cpuidle_drv;
33369 struct gpd_cpu_data *cpu_data;
33370 - struct cpuidle_state *idle_state;
33371 + cpuidle_state_no_const *idle_state;
33372 int ret = 0;
33373
33374 if (IS_ERR_OR_NULL(genpd) || state < 0)
33375 @@ -1919,7 +1919,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33376 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33377 {
33378 struct gpd_cpu_data *cpu_data;
33379 - struct cpuidle_state *idle_state;
33380 + cpuidle_state_no_const *idle_state;
33381 int ret = 0;
33382
33383 if (IS_ERR_OR_NULL(genpd))
33384 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33385 index e6ee5e8..98ad7fc 100644
33386 --- a/drivers/base/power/wakeup.c
33387 +++ b/drivers/base/power/wakeup.c
33388 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33389 * They need to be modified together atomically, so it's better to use one
33390 * atomic variable to hold them both.
33391 */
33392 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33393 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33394
33395 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33396 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33397
33398 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33399 {
33400 - unsigned int comb = atomic_read(&combined_event_count);
33401 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33402
33403 *cnt = (comb >> IN_PROGRESS_BITS);
33404 *inpr = comb & MAX_IN_PROGRESS;
33405 @@ -389,7 +389,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33406 ws->start_prevent_time = ws->last_time;
33407
33408 /* Increment the counter of events in progress. */
33409 - cec = atomic_inc_return(&combined_event_count);
33410 + cec = atomic_inc_return_unchecked(&combined_event_count);
33411
33412 trace_wakeup_source_activate(ws->name, cec);
33413 }
33414 @@ -515,7 +515,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33415 * Increment the counter of registered wakeup events and decrement the
33416 * couter of wakeup events in progress simultaneously.
33417 */
33418 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33419 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33420 trace_wakeup_source_deactivate(ws->name, cec);
33421
33422 split_counters(&cnt, &inpr);
33423 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33424 index e8d11b6..7b1b36f 100644
33425 --- a/drivers/base/syscore.c
33426 +++ b/drivers/base/syscore.c
33427 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33428 void register_syscore_ops(struct syscore_ops *ops)
33429 {
33430 mutex_lock(&syscore_ops_lock);
33431 - list_add_tail(&ops->node, &syscore_ops_list);
33432 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33433 mutex_unlock(&syscore_ops_lock);
33434 }
33435 EXPORT_SYMBOL_GPL(register_syscore_ops);
33436 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33437 void unregister_syscore_ops(struct syscore_ops *ops)
33438 {
33439 mutex_lock(&syscore_ops_lock);
33440 - list_del(&ops->node);
33441 + pax_list_del((struct list_head *)&ops->node);
33442 mutex_unlock(&syscore_ops_lock);
33443 }
33444 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33445 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33446 index ade58bc..867143d 100644
33447 --- a/drivers/block/cciss.c
33448 +++ b/drivers/block/cciss.c
33449 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33450 int err;
33451 u32 cp;
33452
33453 + memset(&arg64, 0, sizeof(arg64));
33454 +
33455 err = 0;
33456 err |=
33457 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33458 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33459 while (!list_empty(&h->reqQ)) {
33460 c = list_entry(h->reqQ.next, CommandList_struct, list);
33461 /* can't do anything if fifo is full */
33462 - if ((h->access.fifo_full(h))) {
33463 + if ((h->access->fifo_full(h))) {
33464 dev_warn(&h->pdev->dev, "fifo full\n");
33465 break;
33466 }
33467 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33468 h->Qdepth--;
33469
33470 /* Tell the controller execute command */
33471 - h->access.submit_command(h, c);
33472 + h->access->submit_command(h, c);
33473
33474 /* Put job onto the completed Q */
33475 addQ(&h->cmpQ, c);
33476 @@ -3441,17 +3443,17 @@ startio:
33477
33478 static inline unsigned long get_next_completion(ctlr_info_t *h)
33479 {
33480 - return h->access.command_completed(h);
33481 + return h->access->command_completed(h);
33482 }
33483
33484 static inline int interrupt_pending(ctlr_info_t *h)
33485 {
33486 - return h->access.intr_pending(h);
33487 + return h->access->intr_pending(h);
33488 }
33489
33490 static inline long interrupt_not_for_us(ctlr_info_t *h)
33491 {
33492 - return ((h->access.intr_pending(h) == 0) ||
33493 + return ((h->access->intr_pending(h) == 0) ||
33494 (h->interrupts_enabled == 0));
33495 }
33496
33497 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33498 u32 a;
33499
33500 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33501 - return h->access.command_completed(h);
33502 + return h->access->command_completed(h);
33503
33504 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33505 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33506 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33507 trans_support & CFGTBL_Trans_use_short_tags);
33508
33509 /* Change the access methods to the performant access methods */
33510 - h->access = SA5_performant_access;
33511 + h->access = &SA5_performant_access;
33512 h->transMethod = CFGTBL_Trans_Performant;
33513
33514 return;
33515 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33516 if (prod_index < 0)
33517 return -ENODEV;
33518 h->product_name = products[prod_index].product_name;
33519 - h->access = *(products[prod_index].access);
33520 + h->access = products[prod_index].access;
33521
33522 if (cciss_board_disabled(h)) {
33523 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33524 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33525 }
33526
33527 /* make sure the board interrupts are off */
33528 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33529 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33530 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33531 if (rc)
33532 goto clean2;
33533 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33534 * fake ones to scoop up any residual completions.
33535 */
33536 spin_lock_irqsave(&h->lock, flags);
33537 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33538 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33539 spin_unlock_irqrestore(&h->lock, flags);
33540 free_irq(h->intr[h->intr_mode], h);
33541 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33542 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33543 dev_info(&h->pdev->dev, "Board READY.\n");
33544 dev_info(&h->pdev->dev,
33545 "Waiting for stale completions to drain.\n");
33546 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33547 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33548 msleep(10000);
33549 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33550 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33551
33552 rc = controller_reset_failed(h->cfgtable);
33553 if (rc)
33554 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33555 cciss_scsi_setup(h);
33556
33557 /* Turn the interrupts on so we can service requests */
33558 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33559 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33560
33561 /* Get the firmware version */
33562 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33563 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33564 kfree(flush_buf);
33565 if (return_code != IO_OK)
33566 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33567 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33568 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33569 free_irq(h->intr[h->intr_mode], h);
33570 }
33571
33572 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33573 index 7fda30e..eb5dfe0 100644
33574 --- a/drivers/block/cciss.h
33575 +++ b/drivers/block/cciss.h
33576 @@ -101,7 +101,7 @@ struct ctlr_info
33577 /* information about each logical volume */
33578 drive_info_struct *drv[CISS_MAX_LUN];
33579
33580 - struct access_method access;
33581 + struct access_method *access;
33582
33583 /* queue and queue Info */
33584 struct list_head reqQ;
33585 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33586 index 3f08713..56a586a 100644
33587 --- a/drivers/block/cpqarray.c
33588 +++ b/drivers/block/cpqarray.c
33589 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33590 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33591 goto Enomem4;
33592 }
33593 - hba[i]->access.set_intr_mask(hba[i], 0);
33594 + hba[i]->access->set_intr_mask(hba[i], 0);
33595 if (request_irq(hba[i]->intr, do_ida_intr,
33596 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33597 {
33598 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33599 add_timer(&hba[i]->timer);
33600
33601 /* Enable IRQ now that spinlock and rate limit timer are set up */
33602 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33603 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33604
33605 for(j=0; j<NWD; j++) {
33606 struct gendisk *disk = ida_gendisk[i][j];
33607 @@ -694,7 +694,7 @@ DBGINFO(
33608 for(i=0; i<NR_PRODUCTS; i++) {
33609 if (board_id == products[i].board_id) {
33610 c->product_name = products[i].product_name;
33611 - c->access = *(products[i].access);
33612 + c->access = products[i].access;
33613 break;
33614 }
33615 }
33616 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33617 hba[ctlr]->intr = intr;
33618 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33619 hba[ctlr]->product_name = products[j].product_name;
33620 - hba[ctlr]->access = *(products[j].access);
33621 + hba[ctlr]->access = products[j].access;
33622 hba[ctlr]->ctlr = ctlr;
33623 hba[ctlr]->board_id = board_id;
33624 hba[ctlr]->pci_dev = NULL; /* not PCI */
33625 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33626
33627 while((c = h->reqQ) != NULL) {
33628 /* Can't do anything if we're busy */
33629 - if (h->access.fifo_full(h) == 0)
33630 + if (h->access->fifo_full(h) == 0)
33631 return;
33632
33633 /* Get the first entry from the request Q */
33634 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33635 h->Qdepth--;
33636
33637 /* Tell the controller to do our bidding */
33638 - h->access.submit_command(h, c);
33639 + h->access->submit_command(h, c);
33640
33641 /* Get onto the completion Q */
33642 addQ(&h->cmpQ, c);
33643 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33644 unsigned long flags;
33645 __u32 a,a1;
33646
33647 - istat = h->access.intr_pending(h);
33648 + istat = h->access->intr_pending(h);
33649 /* Is this interrupt for us? */
33650 if (istat == 0)
33651 return IRQ_NONE;
33652 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33653 */
33654 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33655 if (istat & FIFO_NOT_EMPTY) {
33656 - while((a = h->access.command_completed(h))) {
33657 + while((a = h->access->command_completed(h))) {
33658 a1 = a; a &= ~3;
33659 if ((c = h->cmpQ) == NULL)
33660 {
33661 @@ -1449,11 +1449,11 @@ static int sendcmd(
33662 /*
33663 * Disable interrupt
33664 */
33665 - info_p->access.set_intr_mask(info_p, 0);
33666 + info_p->access->set_intr_mask(info_p, 0);
33667 /* Make sure there is room in the command FIFO */
33668 /* Actually it should be completely empty at this time. */
33669 for (i = 200000; i > 0; i--) {
33670 - temp = info_p->access.fifo_full(info_p);
33671 + temp = info_p->access->fifo_full(info_p);
33672 if (temp != 0) {
33673 break;
33674 }
33675 @@ -1466,7 +1466,7 @@ DBG(
33676 /*
33677 * Send the cmd
33678 */
33679 - info_p->access.submit_command(info_p, c);
33680 + info_p->access->submit_command(info_p, c);
33681 complete = pollcomplete(ctlr);
33682
33683 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33684 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33685 * we check the new geometry. Then turn interrupts back on when
33686 * we're done.
33687 */
33688 - host->access.set_intr_mask(host, 0);
33689 + host->access->set_intr_mask(host, 0);
33690 getgeometry(ctlr);
33691 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33692 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33693
33694 for(i=0; i<NWD; i++) {
33695 struct gendisk *disk = ida_gendisk[ctlr][i];
33696 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33697 /* Wait (up to 2 seconds) for a command to complete */
33698
33699 for (i = 200000; i > 0; i--) {
33700 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33701 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33702 if (done == 0) {
33703 udelay(10); /* a short fixed delay */
33704 } else
33705 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33706 index be73e9d..7fbf140 100644
33707 --- a/drivers/block/cpqarray.h
33708 +++ b/drivers/block/cpqarray.h
33709 @@ -99,7 +99,7 @@ struct ctlr_info {
33710 drv_info_t drv[NWD];
33711 struct proc_dir_entry *proc;
33712
33713 - struct access_method access;
33714 + struct access_method *access;
33715
33716 cmdlist_t *reqQ;
33717 cmdlist_t *cmpQ;
33718 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33719 index 6b51afa..17e1191 100644
33720 --- a/drivers/block/drbd/drbd_int.h
33721 +++ b/drivers/block/drbd/drbd_int.h
33722 @@ -582,7 +582,7 @@ struct drbd_epoch {
33723 struct drbd_tconn *tconn;
33724 struct list_head list;
33725 unsigned int barrier_nr;
33726 - atomic_t epoch_size; /* increased on every request added. */
33727 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33728 atomic_t active; /* increased on every req. added, and dec on every finished. */
33729 unsigned long flags;
33730 };
33731 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33732 int al_tr_cycle;
33733 int al_tr_pos; /* position of the next transaction in the journal */
33734 wait_queue_head_t seq_wait;
33735 - atomic_t packet_seq;
33736 + atomic_unchecked_t packet_seq;
33737 unsigned int peer_seq;
33738 spinlock_t peer_seq_lock;
33739 unsigned int minor;
33740 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33741 char __user *uoptval;
33742 int err;
33743
33744 - uoptval = (char __user __force *)optval;
33745 + uoptval = (char __force_user *)optval;
33746
33747 set_fs(KERNEL_DS);
33748 if (level == SOL_SOCKET)
33749 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33750 index 8c13eeb..217adee 100644
33751 --- a/drivers/block/drbd/drbd_main.c
33752 +++ b/drivers/block/drbd/drbd_main.c
33753 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33754 p->sector = sector;
33755 p->block_id = block_id;
33756 p->blksize = blksize;
33757 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33758 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33759 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33760 }
33761
33762 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33763 return -EIO;
33764 p->sector = cpu_to_be64(req->i.sector);
33765 p->block_id = (unsigned long)req;
33766 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33767 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33768 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33769 if (mdev->state.conn >= C_SYNC_SOURCE &&
33770 mdev->state.conn <= C_PAUSED_SYNC_T)
33771 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33772 {
33773 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33774
33775 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33776 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33777 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33778 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33779 kfree(tconn->current_epoch);
33780
33781 idr_destroy(&tconn->volumes);
33782 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33783 index a9eccfc..f5efe87 100644
33784 --- a/drivers/block/drbd/drbd_receiver.c
33785 +++ b/drivers/block/drbd/drbd_receiver.c
33786 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33787 {
33788 int err;
33789
33790 - atomic_set(&mdev->packet_seq, 0);
33791 + atomic_set_unchecked(&mdev->packet_seq, 0);
33792 mdev->peer_seq = 0;
33793
33794 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33795 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33796 do {
33797 next_epoch = NULL;
33798
33799 - epoch_size = atomic_read(&epoch->epoch_size);
33800 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33801
33802 switch (ev & ~EV_CLEANUP) {
33803 case EV_PUT:
33804 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33805 rv = FE_DESTROYED;
33806 } else {
33807 epoch->flags = 0;
33808 - atomic_set(&epoch->epoch_size, 0);
33809 + atomic_set_unchecked(&epoch->epoch_size, 0);
33810 /* atomic_set(&epoch->active, 0); is already zero */
33811 if (rv == FE_STILL_LIVE)
33812 rv = FE_RECYCLED;
33813 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33814 conn_wait_active_ee_empty(tconn);
33815 drbd_flush(tconn);
33816
33817 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33818 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33819 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33820 if (epoch)
33821 break;
33822 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33823 }
33824
33825 epoch->flags = 0;
33826 - atomic_set(&epoch->epoch_size, 0);
33827 + atomic_set_unchecked(&epoch->epoch_size, 0);
33828 atomic_set(&epoch->active, 0);
33829
33830 spin_lock(&tconn->epoch_lock);
33831 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33832 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33833 list_add(&epoch->list, &tconn->current_epoch->list);
33834 tconn->current_epoch = epoch;
33835 tconn->epochs++;
33836 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33837
33838 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33839 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33840 - atomic_inc(&tconn->current_epoch->epoch_size);
33841 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33842 err2 = drbd_drain_block(mdev, pi->size);
33843 if (!err)
33844 err = err2;
33845 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33846
33847 spin_lock(&tconn->epoch_lock);
33848 peer_req->epoch = tconn->current_epoch;
33849 - atomic_inc(&peer_req->epoch->epoch_size);
33850 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33851 atomic_inc(&peer_req->epoch->active);
33852 spin_unlock(&tconn->epoch_lock);
33853
33854 @@ -4346,7 +4346,7 @@ struct data_cmd {
33855 int expect_payload;
33856 size_t pkt_size;
33857 int (*fn)(struct drbd_tconn *, struct packet_info *);
33858 -};
33859 +} __do_const;
33860
33861 static struct data_cmd drbd_cmd_handler[] = {
33862 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33863 @@ -4466,7 +4466,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33864 if (!list_empty(&tconn->current_epoch->list))
33865 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33866 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33867 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33868 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33869 tconn->send.seen_any_write_yet = false;
33870
33871 conn_info(tconn, "Connection closed\n");
33872 @@ -5222,7 +5222,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33873 struct asender_cmd {
33874 size_t pkt_size;
33875 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33876 -};
33877 +} __do_const;
33878
33879 static struct asender_cmd asender_tbl[] = {
33880 [P_PING] = { 0, got_Ping },
33881 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33882 index f74f2c0..bb668af 100644
33883 --- a/drivers/block/loop.c
33884 +++ b/drivers/block/loop.c
33885 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
33886 mm_segment_t old_fs = get_fs();
33887
33888 set_fs(get_ds());
33889 - bw = file->f_op->write(file, buf, len, &pos);
33890 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33891 set_fs(old_fs);
33892 if (likely(bw == len))
33893 return 0;
33894 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33895 index d620b44..587561e 100644
33896 --- a/drivers/cdrom/cdrom.c
33897 +++ b/drivers/cdrom/cdrom.c
33898 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33899 ENSURE(reset, CDC_RESET);
33900 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33901 cdi->mc_flags = 0;
33902 - cdo->n_minors = 0;
33903 cdi->options = CDO_USE_FFLAGS;
33904
33905 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33906 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33907 else
33908 cdi->cdda_method = CDDA_OLD;
33909
33910 - if (!cdo->generic_packet)
33911 - cdo->generic_packet = cdrom_dummy_generic_packet;
33912 + if (!cdo->generic_packet) {
33913 + pax_open_kernel();
33914 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33915 + pax_close_kernel();
33916 + }
33917
33918 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33919 mutex_lock(&cdrom_mutex);
33920 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33921 if (cdi->exit)
33922 cdi->exit(cdi);
33923
33924 - cdi->ops->n_minors--;
33925 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33926 }
33927
33928 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33929 index d59cdcb..11afddf 100644
33930 --- a/drivers/cdrom/gdrom.c
33931 +++ b/drivers/cdrom/gdrom.c
33932 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33933 .audio_ioctl = gdrom_audio_ioctl,
33934 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33935 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33936 - .n_minors = 1,
33937 };
33938
33939 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33940 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33941 index 72bedad..8181ce1 100644
33942 --- a/drivers/char/Kconfig
33943 +++ b/drivers/char/Kconfig
33944 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33945
33946 config DEVKMEM
33947 bool "/dev/kmem virtual device support"
33948 - default y
33949 + default n
33950 + depends on !GRKERNSEC_KMEM
33951 help
33952 Say Y here if you want to support the /dev/kmem device. The
33953 /dev/kmem device is rarely used, but can be used for certain
33954 @@ -581,6 +582,7 @@ config DEVPORT
33955 bool
33956 depends on !M68K
33957 depends on ISA || PCI
33958 + depends on !GRKERNSEC_KMEM
33959 default y
33960
33961 source "drivers/s390/char/Kconfig"
33962 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33963 index 2e04433..22afc64 100644
33964 --- a/drivers/char/agp/frontend.c
33965 +++ b/drivers/char/agp/frontend.c
33966 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33967 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33968 return -EFAULT;
33969
33970 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33971 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33972 return -EFAULT;
33973
33974 client = agp_find_client_by_pid(reserve.pid);
33975 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33976 index 21cb980..f15107c 100644
33977 --- a/drivers/char/genrtc.c
33978 +++ b/drivers/char/genrtc.c
33979 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
33980 switch (cmd) {
33981
33982 case RTC_PLL_GET:
33983 + memset(&pll, 0, sizeof(pll));
33984 if (get_rtc_pll(&pll))
33985 return -EINVAL;
33986 else
33987 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33988 index fe6d4be..89f32100 100644
33989 --- a/drivers/char/hpet.c
33990 +++ b/drivers/char/hpet.c
33991 @@ -571,7 +571,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33992 }
33993
33994 static int
33995 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33996 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33997 struct hpet_info *info)
33998 {
33999 struct hpet_timer __iomem *timer;
34000 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
34001 index 053201b0..8335cce 100644
34002 --- a/drivers/char/ipmi/ipmi_msghandler.c
34003 +++ b/drivers/char/ipmi/ipmi_msghandler.c
34004 @@ -420,7 +420,7 @@ struct ipmi_smi {
34005 struct proc_dir_entry *proc_dir;
34006 char proc_dir_name[10];
34007
34008 - atomic_t stats[IPMI_NUM_STATS];
34009 + atomic_unchecked_t stats[IPMI_NUM_STATS];
34010
34011 /*
34012 * run_to_completion duplicate of smb_info, smi_info
34013 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
34014
34015
34016 #define ipmi_inc_stat(intf, stat) \
34017 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
34018 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
34019 #define ipmi_get_stat(intf, stat) \
34020 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
34021 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
34022
34023 static int is_lan_addr(struct ipmi_addr *addr)
34024 {
34025 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
34026 INIT_LIST_HEAD(&intf->cmd_rcvrs);
34027 init_waitqueue_head(&intf->waitq);
34028 for (i = 0; i < IPMI_NUM_STATS; i++)
34029 - atomic_set(&intf->stats[i], 0);
34030 + atomic_set_unchecked(&intf->stats[i], 0);
34031
34032 intf->proc_dir = NULL;
34033
34034 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
34035 index 1c7fdcd..4899100 100644
34036 --- a/drivers/char/ipmi/ipmi_si_intf.c
34037 +++ b/drivers/char/ipmi/ipmi_si_intf.c
34038 @@ -275,7 +275,7 @@ struct smi_info {
34039 unsigned char slave_addr;
34040
34041 /* Counters and things for the proc filesystem. */
34042 - atomic_t stats[SI_NUM_STATS];
34043 + atomic_unchecked_t stats[SI_NUM_STATS];
34044
34045 struct task_struct *thread;
34046
34047 @@ -284,9 +284,9 @@ struct smi_info {
34048 };
34049
34050 #define smi_inc_stat(smi, stat) \
34051 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
34052 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
34053 #define smi_get_stat(smi, stat) \
34054 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
34055 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
34056
34057 #define SI_MAX_PARMS 4
34058
34059 @@ -3225,7 +3225,7 @@ static int try_smi_init(struct smi_info *new_smi)
34060 atomic_set(&new_smi->req_events, 0);
34061 new_smi->run_to_completion = 0;
34062 for (i = 0; i < SI_NUM_STATS; i++)
34063 - atomic_set(&new_smi->stats[i], 0);
34064 + atomic_set_unchecked(&new_smi->stats[i], 0);
34065
34066 new_smi->interrupt_disabled = 1;
34067 atomic_set(&new_smi->stop_operation, 0);
34068 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
34069 index c6fa3bc..4ca3e42 100644
34070 --- a/drivers/char/mem.c
34071 +++ b/drivers/char/mem.c
34072 @@ -18,6 +18,7 @@
34073 #include <linux/raw.h>
34074 #include <linux/tty.h>
34075 #include <linux/capability.h>
34076 +#include <linux/security.h>
34077 #include <linux/ptrace.h>
34078 #include <linux/device.h>
34079 #include <linux/highmem.h>
34080 @@ -37,6 +38,10 @@
34081
34082 #define DEVPORT_MINOR 4
34083
34084 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34085 +extern const struct file_operations grsec_fops;
34086 +#endif
34087 +
34088 static inline unsigned long size_inside_page(unsigned long start,
34089 unsigned long size)
34090 {
34091 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34092
34093 while (cursor < to) {
34094 if (!devmem_is_allowed(pfn)) {
34095 +#ifdef CONFIG_GRKERNSEC_KMEM
34096 + gr_handle_mem_readwrite(from, to);
34097 +#else
34098 printk(KERN_INFO
34099 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34100 current->comm, from, to);
34101 +#endif
34102 return 0;
34103 }
34104 cursor += PAGE_SIZE;
34105 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34106 }
34107 return 1;
34108 }
34109 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34110 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34111 +{
34112 + return 0;
34113 +}
34114 #else
34115 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34116 {
34117 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34118
34119 while (count > 0) {
34120 unsigned long remaining;
34121 + char *temp;
34122
34123 sz = size_inside_page(p, count);
34124
34125 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34126 if (!ptr)
34127 return -EFAULT;
34128
34129 - remaining = copy_to_user(buf, ptr, sz);
34130 +#ifdef CONFIG_PAX_USERCOPY
34131 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34132 + if (!temp) {
34133 + unxlate_dev_mem_ptr(p, ptr);
34134 + return -ENOMEM;
34135 + }
34136 + memcpy(temp, ptr, sz);
34137 +#else
34138 + temp = ptr;
34139 +#endif
34140 +
34141 + remaining = copy_to_user(buf, temp, sz);
34142 +
34143 +#ifdef CONFIG_PAX_USERCOPY
34144 + kfree(temp);
34145 +#endif
34146 +
34147 unxlate_dev_mem_ptr(p, ptr);
34148 if (remaining)
34149 return -EFAULT;
34150 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34151 size_t count, loff_t *ppos)
34152 {
34153 unsigned long p = *ppos;
34154 - ssize_t low_count, read, sz;
34155 + ssize_t low_count, read, sz, err = 0;
34156 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34157 - int err = 0;
34158
34159 read = 0;
34160 if (p < (unsigned long) high_memory) {
34161 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34162 }
34163 #endif
34164 while (low_count > 0) {
34165 + char *temp;
34166 +
34167 sz = size_inside_page(p, low_count);
34168
34169 /*
34170 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34171 */
34172 kbuf = xlate_dev_kmem_ptr((char *)p);
34173
34174 - if (copy_to_user(buf, kbuf, sz))
34175 +#ifdef CONFIG_PAX_USERCOPY
34176 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34177 + if (!temp)
34178 + return -ENOMEM;
34179 + memcpy(temp, kbuf, sz);
34180 +#else
34181 + temp = kbuf;
34182 +#endif
34183 +
34184 + err = copy_to_user(buf, temp, sz);
34185 +
34186 +#ifdef CONFIG_PAX_USERCOPY
34187 + kfree(temp);
34188 +#endif
34189 +
34190 + if (err)
34191 return -EFAULT;
34192 buf += sz;
34193 p += sz;
34194 @@ -833,6 +880,9 @@ static const struct memdev {
34195 #ifdef CONFIG_CRASH_DUMP
34196 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34197 #endif
34198 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34199 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34200 +#endif
34201 };
34202
34203 static int memory_open(struct inode *inode, struct file *filp)
34204 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34205 index 9df78e2..01ba9ae 100644
34206 --- a/drivers/char/nvram.c
34207 +++ b/drivers/char/nvram.c
34208 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34209
34210 spin_unlock_irq(&rtc_lock);
34211
34212 - if (copy_to_user(buf, contents, tmp - contents))
34213 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34214 return -EFAULT;
34215
34216 *ppos = i;
34217 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34218 index b66eaa0..2619d1b 100644
34219 --- a/drivers/char/pcmcia/synclink_cs.c
34220 +++ b/drivers/char/pcmcia/synclink_cs.c
34221 @@ -2348,9 +2348,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34222
34223 if (debug_level >= DEBUG_LEVEL_INFO)
34224 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34225 - __FILE__,__LINE__, info->device_name, port->count);
34226 + __FILE__,__LINE__, info->device_name, atomic_read(&port->count));
34227
34228 - WARN_ON(!port->count);
34229 + WARN_ON(!atomic_read(&port->count));
34230
34231 if (tty_port_close_start(port, tty, filp) == 0)
34232 goto cleanup;
34233 @@ -2368,7 +2368,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34234 cleanup:
34235 if (debug_level >= DEBUG_LEVEL_INFO)
34236 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
34237 - tty->driver->name, port->count);
34238 + tty->driver->name, atomic_read(&port->count));
34239 }
34240
34241 /* Wait until the transmitter is empty.
34242 @@ -2510,7 +2510,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34243
34244 if (debug_level >= DEBUG_LEVEL_INFO)
34245 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34246 - __FILE__,__LINE__,tty->driver->name, port->count);
34247 + __FILE__,__LINE__,tty->driver->name, atomic_read(&port->count));
34248
34249 /* If port is closing, signal caller to try again */
34250 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34251 @@ -2530,11 +2530,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34252 goto cleanup;
34253 }
34254 spin_lock(&port->lock);
34255 - port->count++;
34256 + atomic_inc(&port->count);
34257 spin_unlock(&port->lock);
34258 spin_unlock_irqrestore(&info->netlock, flags);
34259
34260 - if (port->count == 1) {
34261 + if (atomic_read(&port->count) == 1) {
34262 /* 1st open on this device, init hardware */
34263 retval = startup(info, tty);
34264 if (retval < 0)
34265 @@ -3889,7 +3889,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34266 unsigned short new_crctype;
34267
34268 /* return error if TTY interface open */
34269 - if (info->port.count)
34270 + if (atomic_read(&info->port.count))
34271 return -EBUSY;
34272
34273 switch (encoding)
34274 @@ -3992,7 +3992,7 @@ static int hdlcdev_open(struct net_device *dev)
34275
34276 /* arbitrate between network and tty opens */
34277 spin_lock_irqsave(&info->netlock, flags);
34278 - if (info->port.count != 0 || info->netcount != 0) {
34279 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34280 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34281 spin_unlock_irqrestore(&info->netlock, flags);
34282 return -EBUSY;
34283 @@ -4081,7 +4081,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34284 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
34285
34286 /* return error if TTY interface open */
34287 - if (info->port.count)
34288 + if (atomic_read(&info->port.count))
34289 return -EBUSY;
34290
34291 if (cmd != SIOCWANDEV)
34292 diff --git a/drivers/char/random.c b/drivers/char/random.c
34293 index 57d4b15..253207b 100644
34294 --- a/drivers/char/random.c
34295 +++ b/drivers/char/random.c
34296 @@ -272,8 +272,13 @@
34297 /*
34298 * Configuration information
34299 */
34300 +#ifdef CONFIG_GRKERNSEC_RANDNET
34301 +#define INPUT_POOL_WORDS 512
34302 +#define OUTPUT_POOL_WORDS 128
34303 +#else
34304 #define INPUT_POOL_WORDS 128
34305 #define OUTPUT_POOL_WORDS 32
34306 +#endif
34307 #define SEC_XFER_SIZE 512
34308 #define EXTRACT_SIZE 10
34309
34310 @@ -313,10 +318,17 @@ static struct poolinfo {
34311 int poolwords;
34312 int tap1, tap2, tap3, tap4, tap5;
34313 } poolinfo_table[] = {
34314 +#ifdef CONFIG_GRKERNSEC_RANDNET
34315 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34316 + { 512, 411, 308, 208, 104, 1 },
34317 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34318 + { 128, 103, 76, 51, 25, 1 },
34319 +#else
34320 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34321 { 128, 103, 76, 51, 25, 1 },
34322 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34323 { 32, 26, 20, 14, 7, 1 },
34324 +#endif
34325 #if 0
34326 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34327 { 2048, 1638, 1231, 819, 411, 1 },
34328 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34329 input_rotate += i ? 7 : 14;
34330 }
34331
34332 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34333 - ACCESS_ONCE(r->add_ptr) = i;
34334 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34335 + ACCESS_ONCE_RW(r->add_ptr) = i;
34336 smp_wmb();
34337
34338 if (out)
34339 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34340
34341 extract_buf(r, tmp);
34342 i = min_t(int, nbytes, EXTRACT_SIZE);
34343 - if (copy_to_user(buf, tmp, i)) {
34344 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34345 ret = -EFAULT;
34346 break;
34347 }
34348 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34349 #include <linux/sysctl.h>
34350
34351 static int min_read_thresh = 8, min_write_thresh;
34352 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34353 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34354 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34355 static char sysctl_bootid[16];
34356
34357 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
34358 static int proc_do_uuid(ctl_table *table, int write,
34359 void __user *buffer, size_t *lenp, loff_t *ppos)
34360 {
34361 - ctl_table fake_table;
34362 + ctl_table_no_const fake_table;
34363 unsigned char buf[64], tmp_uuid[16], *uuid;
34364
34365 uuid = table->data;
34366 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34367 index d780295..b29f3a8 100644
34368 --- a/drivers/char/sonypi.c
34369 +++ b/drivers/char/sonypi.c
34370 @@ -54,6 +54,7 @@
34371
34372 #include <asm/uaccess.h>
34373 #include <asm/io.h>
34374 +#include <asm/local.h>
34375
34376 #include <linux/sonypi.h>
34377
34378 @@ -490,7 +491,7 @@ static struct sonypi_device {
34379 spinlock_t fifo_lock;
34380 wait_queue_head_t fifo_proc_list;
34381 struct fasync_struct *fifo_async;
34382 - int open_count;
34383 + local_t open_count;
34384 int model;
34385 struct input_dev *input_jog_dev;
34386 struct input_dev *input_key_dev;
34387 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34388 static int sonypi_misc_release(struct inode *inode, struct file *file)
34389 {
34390 mutex_lock(&sonypi_device.lock);
34391 - sonypi_device.open_count--;
34392 + local_dec(&sonypi_device.open_count);
34393 mutex_unlock(&sonypi_device.lock);
34394 return 0;
34395 }
34396 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34397 {
34398 mutex_lock(&sonypi_device.lock);
34399 /* Flush input queue on first open */
34400 - if (!sonypi_device.open_count)
34401 + if (!local_read(&sonypi_device.open_count))
34402 kfifo_reset(&sonypi_device.fifo);
34403 - sonypi_device.open_count++;
34404 + local_inc(&sonypi_device.open_count);
34405 mutex_unlock(&sonypi_device.lock);
34406
34407 return 0;
34408 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
34409 index 93211df..c7805f7 100644
34410 --- a/drivers/char/tpm/tpm.c
34411 +++ b/drivers/char/tpm/tpm.c
34412 @@ -410,7 +410,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
34413 chip->vendor.req_complete_val)
34414 goto out_recv;
34415
34416 - if ((status == chip->vendor.req_canceled)) {
34417 + if (status == chip->vendor.req_canceled) {
34418 dev_err(chip->dev, "Operation Canceled\n");
34419 rc = -ECANCELED;
34420 goto out;
34421 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34422 index 56051d0..11cf3b7 100644
34423 --- a/drivers/char/tpm/tpm_acpi.c
34424 +++ b/drivers/char/tpm/tpm_acpi.c
34425 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34426 virt = acpi_os_map_memory(start, len);
34427 if (!virt) {
34428 kfree(log->bios_event_log);
34429 + log->bios_event_log = NULL;
34430 printk("%s: ERROR - Unable to map memory\n", __func__);
34431 return -EIO;
34432 }
34433
34434 - memcpy_fromio(log->bios_event_log, virt, len);
34435 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34436
34437 acpi_os_unmap_memory(virt, len);
34438 return 0;
34439 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34440 index 84ddc55..1d32f1e 100644
34441 --- a/drivers/char/tpm/tpm_eventlog.c
34442 +++ b/drivers/char/tpm/tpm_eventlog.c
34443 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34444 event = addr;
34445
34446 if ((event->event_type == 0 && event->event_size == 0) ||
34447 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34448 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34449 return NULL;
34450
34451 return addr;
34452 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34453 return NULL;
34454
34455 if ((event->event_type == 0 && event->event_size == 0) ||
34456 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34457 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34458 return NULL;
34459
34460 (*pos)++;
34461 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34462 int i;
34463
34464 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34465 - seq_putc(m, data[i]);
34466 + if (!seq_putc(m, data[i]))
34467 + return -EFAULT;
34468
34469 return 0;
34470 }
34471 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34472 index a4b7aa0..2faa0bc 100644
34473 --- a/drivers/char/virtio_console.c
34474 +++ b/drivers/char/virtio_console.c
34475 @@ -685,7 +685,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34476 if (to_user) {
34477 ssize_t ret;
34478
34479 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34480 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34481 if (ret)
34482 return -EFAULT;
34483 } else {
34484 @@ -784,7 +784,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34485 if (!port_has_data(port) && !port->host_connected)
34486 return 0;
34487
34488 - return fill_readbuf(port, ubuf, count, true);
34489 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34490 }
34491
34492 static int wait_port_writable(struct port *port, bool nonblock)
34493 diff --git a/drivers/clocksource/arm_generic.c b/drivers/clocksource/arm_generic.c
34494 index 8ae1a61..9c00613 100644
34495 --- a/drivers/clocksource/arm_generic.c
34496 +++ b/drivers/clocksource/arm_generic.c
34497 @@ -181,7 +181,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34498 return NOTIFY_OK;
34499 }
34500
34501 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34502 +static struct notifier_block arch_timer_cpu_nb = {
34503 .notifier_call = arch_timer_cpu_notify,
34504 };
34505
34506 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34507 index 7b0d49d..134fac9 100644
34508 --- a/drivers/cpufreq/acpi-cpufreq.c
34509 +++ b/drivers/cpufreq/acpi-cpufreq.c
34510 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34511 return sprintf(buf, "%u\n", boost_enabled);
34512 }
34513
34514 -static struct global_attr global_boost = __ATTR(boost, 0644,
34515 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34516 show_global_boost,
34517 store_global_boost);
34518
34519 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34520 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34521 per_cpu(acfreq_data, cpu) = data;
34522
34523 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34524 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34525 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34526 + pax_open_kernel();
34527 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34528 + pax_close_kernel();
34529 + }
34530
34531 result = acpi_processor_register_performance(data->acpi_data, cpu);
34532 if (result)
34533 @@ -835,7 +838,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34534 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34535 break;
34536 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34537 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34538 + pax_open_kernel();
34539 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34540 + pax_close_kernel();
34541 policy->cur = get_cur_freq_on_cpu(cpu);
34542 break;
34543 default:
34544 @@ -846,8 +851,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34545 acpi_processor_notify_smm(THIS_MODULE);
34546
34547 /* Check for APERF/MPERF support in hardware */
34548 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34549 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34550 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34551 + pax_open_kernel();
34552 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34553 + pax_close_kernel();
34554 + }
34555
34556 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34557 for (i = 0; i < perf->state_count; i++)
34558 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34559 index 1f93dbd..305cef1 100644
34560 --- a/drivers/cpufreq/cpufreq.c
34561 +++ b/drivers/cpufreq/cpufreq.c
34562 @@ -1843,7 +1843,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34563 return NOTIFY_OK;
34564 }
34565
34566 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34567 +static struct notifier_block cpufreq_cpu_notifier = {
34568 .notifier_call = cpufreq_cpu_callback,
34569 };
34570
34571 @@ -1875,8 +1875,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34572
34573 pr_debug("trying to register driver %s\n", driver_data->name);
34574
34575 - if (driver_data->setpolicy)
34576 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34577 + if (driver_data->setpolicy) {
34578 + pax_open_kernel();
34579 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34580 + pax_close_kernel();
34581 + }
34582
34583 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34584 if (cpufreq_driver) {
34585 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34586 index 6c5f1d3..c7e2f35e 100644
34587 --- a/drivers/cpufreq/cpufreq_governor.c
34588 +++ b/drivers/cpufreq/cpufreq_governor.c
34589 @@ -243,7 +243,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34590 * governor, thus we are bound to jiffes/HZ
34591 */
34592 if (dbs_data->governor == GOV_CONSERVATIVE) {
34593 - struct cs_ops *ops = dbs_data->gov_ops;
34594 + const struct cs_ops *ops = dbs_data->gov_ops;
34595
34596 cpufreq_register_notifier(ops->notifier_block,
34597 CPUFREQ_TRANSITION_NOTIFIER);
34598 @@ -251,7 +251,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34599 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
34600 jiffies_to_usecs(10);
34601 } else {
34602 - struct od_ops *ops = dbs_data->gov_ops;
34603 + const struct od_ops *ops = dbs_data->gov_ops;
34604
34605 od_tuners->io_is_busy = ops->io_busy();
34606 }
34607 @@ -268,7 +268,7 @@ second_time:
34608 cs_dbs_info->enable = 1;
34609 cs_dbs_info->requested_freq = policy->cur;
34610 } else {
34611 - struct od_ops *ops = dbs_data->gov_ops;
34612 + const struct od_ops *ops = dbs_data->gov_ops;
34613 od_dbs_info->rate_mult = 1;
34614 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
34615 ops->powersave_bias_init_cpu(cpu);
34616 @@ -289,7 +289,7 @@ second_time:
34617 mutex_destroy(&cpu_cdbs->timer_mutex);
34618 dbs_data->enable--;
34619 if (!dbs_data->enable) {
34620 - struct cs_ops *ops = dbs_data->gov_ops;
34621 + const struct cs_ops *ops = dbs_data->gov_ops;
34622
34623 sysfs_remove_group(cpufreq_global_kobject,
34624 dbs_data->attr_group);
34625 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34626 index f661654..6c8e638 100644
34627 --- a/drivers/cpufreq/cpufreq_governor.h
34628 +++ b/drivers/cpufreq/cpufreq_governor.h
34629 @@ -142,7 +142,7 @@ struct dbs_data {
34630 void (*gov_check_cpu)(int cpu, unsigned int load);
34631
34632 /* Governor specific ops, see below */
34633 - void *gov_ops;
34634 + const void *gov_ops;
34635 };
34636
34637 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34638 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34639 index 9d7732b..0b1a793 100644
34640 --- a/drivers/cpufreq/cpufreq_stats.c
34641 +++ b/drivers/cpufreq/cpufreq_stats.c
34642 @@ -340,7 +340,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34643 }
34644
34645 /* priority=1 so this will get called before cpufreq_remove_dev */
34646 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34647 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34648 .notifier_call = cpufreq_stat_cpu_callback,
34649 .priority = 1,
34650 };
34651 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34652 index 827629c9..0bc6a03 100644
34653 --- a/drivers/cpufreq/p4-clockmod.c
34654 +++ b/drivers/cpufreq/p4-clockmod.c
34655 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34656 case 0x0F: /* Core Duo */
34657 case 0x16: /* Celeron Core */
34658 case 0x1C: /* Atom */
34659 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34660 + pax_open_kernel();
34661 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34662 + pax_close_kernel();
34663 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34664 case 0x0D: /* Pentium M (Dothan) */
34665 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34666 + pax_open_kernel();
34667 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34668 + pax_close_kernel();
34669 /* fall through */
34670 case 0x09: /* Pentium M (Banias) */
34671 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34672 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34673
34674 /* on P-4s, the TSC runs with constant frequency independent whether
34675 * throttling is active or not. */
34676 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34677 + pax_open_kernel();
34678 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34679 + pax_close_kernel();
34680
34681 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34682 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34683 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34684 index 3a953d5..f5993f6 100644
34685 --- a/drivers/cpufreq/speedstep-centrino.c
34686 +++ b/drivers/cpufreq/speedstep-centrino.c
34687 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34688 !cpu_has(cpu, X86_FEATURE_EST))
34689 return -ENODEV;
34690
34691 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34692 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34693 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34694 + pax_open_kernel();
34695 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34696 + pax_close_kernel();
34697 + }
34698
34699 if (policy->cpu != 0)
34700 return -ENODEV;
34701 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34702 index e1f6860..f8de20b 100644
34703 --- a/drivers/cpuidle/cpuidle.c
34704 +++ b/drivers/cpuidle/cpuidle.c
34705 @@ -279,7 +279,7 @@ static int poll_idle(struct cpuidle_device *dev,
34706
34707 static void poll_idle_init(struct cpuidle_driver *drv)
34708 {
34709 - struct cpuidle_state *state = &drv->states[0];
34710 + cpuidle_state_no_const *state = &drv->states[0];
34711
34712 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34713 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34714 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34715 index ea2f8e7..70ac501 100644
34716 --- a/drivers/cpuidle/governor.c
34717 +++ b/drivers/cpuidle/governor.c
34718 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34719 mutex_lock(&cpuidle_lock);
34720 if (__cpuidle_find_governor(gov->name) == NULL) {
34721 ret = 0;
34722 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34723 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34724 if (!cpuidle_curr_governor ||
34725 cpuidle_curr_governor->rating < gov->rating)
34726 cpuidle_switch_governor(gov);
34727 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34728 new_gov = cpuidle_replace_governor(gov->rating);
34729 cpuidle_switch_governor(new_gov);
34730 }
34731 - list_del(&gov->governor_list);
34732 + pax_list_del((struct list_head *)&gov->governor_list);
34733 mutex_unlock(&cpuidle_lock);
34734 }
34735
34736 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34737 index 428754a..8bdf9cc 100644
34738 --- a/drivers/cpuidle/sysfs.c
34739 +++ b/drivers/cpuidle/sysfs.c
34740 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34741 NULL
34742 };
34743
34744 -static struct attribute_group cpuidle_attr_group = {
34745 +static attribute_group_no_const cpuidle_attr_group = {
34746 .attrs = cpuidle_default_attrs,
34747 .name = "cpuidle",
34748 };
34749 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34750 index 3b36797..289c16a 100644
34751 --- a/drivers/devfreq/devfreq.c
34752 +++ b/drivers/devfreq/devfreq.c
34753 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34754 goto err_out;
34755 }
34756
34757 - list_add(&governor->node, &devfreq_governor_list);
34758 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34759
34760 list_for_each_entry(devfreq, &devfreq_list, node) {
34761 int ret = 0;
34762 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34763 }
34764 }
34765
34766 - list_del(&governor->node);
34767 + pax_list_del((struct list_head *)&governor->node);
34768 err_out:
34769 mutex_unlock(&devfreq_list_lock);
34770
34771 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34772 index b70709b..1d8d02a 100644
34773 --- a/drivers/dma/sh/shdma.c
34774 +++ b/drivers/dma/sh/shdma.c
34775 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34776 return ret;
34777 }
34778
34779 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34780 +static struct notifier_block sh_dmae_nmi_notifier = {
34781 .notifier_call = sh_dmae_nmi_handler,
34782
34783 /* Run before NMI debug handler and KGDB */
34784 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34785 index 0ca1ca7..6e6f454 100644
34786 --- a/drivers/edac/edac_mc_sysfs.c
34787 +++ b/drivers/edac/edac_mc_sysfs.c
34788 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34789 struct dev_ch_attribute {
34790 struct device_attribute attr;
34791 int channel;
34792 -};
34793 +} __do_const;
34794
34795 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34796 struct dev_ch_attribute dev_attr_legacy_##_name = \
34797 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34798 index 0056c4d..23b54d9 100644
34799 --- a/drivers/edac/edac_pci_sysfs.c
34800 +++ b/drivers/edac/edac_pci_sysfs.c
34801 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34802 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34803 static int edac_pci_poll_msec = 1000; /* one second workq period */
34804
34805 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34806 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34807 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34808 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34809
34810 static struct kobject *edac_pci_top_main_kobj;
34811 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34812 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34813 void *value;
34814 ssize_t(*show) (void *, char *);
34815 ssize_t(*store) (void *, const char *, size_t);
34816 -};
34817 +} __do_const;
34818
34819 /* Set of show/store abstract level functions for PCI Parity object */
34820 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34821 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34822 edac_printk(KERN_CRIT, EDAC_PCI,
34823 "Signaled System Error on %s\n",
34824 pci_name(dev));
34825 - atomic_inc(&pci_nonparity_count);
34826 + atomic_inc_unchecked(&pci_nonparity_count);
34827 }
34828
34829 if (status & (PCI_STATUS_PARITY)) {
34830 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34831 "Master Data Parity Error on %s\n",
34832 pci_name(dev));
34833
34834 - atomic_inc(&pci_parity_count);
34835 + atomic_inc_unchecked(&pci_parity_count);
34836 }
34837
34838 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34839 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34840 "Detected Parity Error on %s\n",
34841 pci_name(dev));
34842
34843 - atomic_inc(&pci_parity_count);
34844 + atomic_inc_unchecked(&pci_parity_count);
34845 }
34846 }
34847
34848 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34849 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34850 "Signaled System Error on %s\n",
34851 pci_name(dev));
34852 - atomic_inc(&pci_nonparity_count);
34853 + atomic_inc_unchecked(&pci_nonparity_count);
34854 }
34855
34856 if (status & (PCI_STATUS_PARITY)) {
34857 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34858 "Master Data Parity Error on "
34859 "%s\n", pci_name(dev));
34860
34861 - atomic_inc(&pci_parity_count);
34862 + atomic_inc_unchecked(&pci_parity_count);
34863 }
34864
34865 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34866 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34867 "Detected Parity Error on %s\n",
34868 pci_name(dev));
34869
34870 - atomic_inc(&pci_parity_count);
34871 + atomic_inc_unchecked(&pci_parity_count);
34872 }
34873 }
34874 }
34875 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34876 if (!check_pci_errors)
34877 return;
34878
34879 - before_count = atomic_read(&pci_parity_count);
34880 + before_count = atomic_read_unchecked(&pci_parity_count);
34881
34882 /* scan all PCI devices looking for a Parity Error on devices and
34883 * bridges.
34884 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34885 /* Only if operator has selected panic on PCI Error */
34886 if (edac_pci_get_panic_on_pe()) {
34887 /* If the count is different 'after' from 'before' */
34888 - if (before_count != atomic_read(&pci_parity_count))
34889 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34890 panic("EDAC: PCI Parity Error");
34891 }
34892 }
34893 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34894 index 6796799..99e8377 100644
34895 --- a/drivers/edac/mce_amd.h
34896 +++ b/drivers/edac/mce_amd.h
34897 @@ -78,7 +78,7 @@ extern const char * const ii_msgs[];
34898 struct amd_decoder_ops {
34899 bool (*mc0_mce)(u16, u8);
34900 bool (*mc1_mce)(u16, u8);
34901 -};
34902 +} __no_const;
34903
34904 void amd_report_gart_errors(bool);
34905 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34906 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34907 index 57ea7f4..789e3c3 100644
34908 --- a/drivers/firewire/core-card.c
34909 +++ b/drivers/firewire/core-card.c
34910 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34911
34912 void fw_core_remove_card(struct fw_card *card)
34913 {
34914 - struct fw_card_driver dummy_driver = dummy_driver_template;
34915 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34916
34917 card->driver->update_phy_reg(card, 4,
34918 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34919 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34920 index f8d2287..5aaf4db 100644
34921 --- a/drivers/firewire/core-cdev.c
34922 +++ b/drivers/firewire/core-cdev.c
34923 @@ -1365,8 +1365,7 @@ static int init_iso_resource(struct client *client,
34924 int ret;
34925
34926 if ((request->channels == 0 && request->bandwidth == 0) ||
34927 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34928 - request->bandwidth < 0)
34929 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34930 return -EINVAL;
34931
34932 r = kmalloc(sizeof(*r), GFP_KERNEL);
34933 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34934 index af3e8aa..eb2f227 100644
34935 --- a/drivers/firewire/core-device.c
34936 +++ b/drivers/firewire/core-device.c
34937 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34938 struct config_rom_attribute {
34939 struct device_attribute attr;
34940 u32 key;
34941 -};
34942 +} __do_const;
34943
34944 static ssize_t show_immediate(struct device *dev,
34945 struct device_attribute *dattr, char *buf)
34946 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
34947 index 28a94c7..58da63a 100644
34948 --- a/drivers/firewire/core-transaction.c
34949 +++ b/drivers/firewire/core-transaction.c
34950 @@ -38,6 +38,7 @@
34951 #include <linux/timer.h>
34952 #include <linux/types.h>
34953 #include <linux/workqueue.h>
34954 +#include <linux/sched.h>
34955
34956 #include <asm/byteorder.h>
34957
34958 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
34959 index 515a42c..5ecf3ba 100644
34960 --- a/drivers/firewire/core.h
34961 +++ b/drivers/firewire/core.h
34962 @@ -111,6 +111,7 @@ struct fw_card_driver {
34963
34964 int (*stop_iso)(struct fw_iso_context *ctx);
34965 };
34966 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
34967
34968 void fw_card_initialize(struct fw_card *card,
34969 const struct fw_card_driver *driver, struct device *device);
34970 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
34971 index 94a58a0..f5eba42 100644
34972 --- a/drivers/firmware/dmi-id.c
34973 +++ b/drivers/firmware/dmi-id.c
34974 @@ -16,7 +16,7 @@
34975 struct dmi_device_attribute{
34976 struct device_attribute dev_attr;
34977 int field;
34978 -};
34979 +} __do_const;
34980 #define to_dmi_dev_attr(_dev_attr) \
34981 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
34982
34983 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
34984 index 4cd392d..4b629e1 100644
34985 --- a/drivers/firmware/dmi_scan.c
34986 +++ b/drivers/firmware/dmi_scan.c
34987 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
34988 }
34989 }
34990 else {
34991 - /*
34992 - * no iounmap() for that ioremap(); it would be a no-op, but
34993 - * it's so early in setup that sucker gets confused into doing
34994 - * what it shouldn't if we actually call it.
34995 - */
34996 p = dmi_ioremap(0xF0000, 0x10000);
34997 if (p == NULL)
34998 goto error;
34999 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
35000 if (buf == NULL)
35001 return -1;
35002
35003 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
35004 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
35005
35006 iounmap(buf);
35007 return 0;
35008 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
35009 index b07cb37..2a51037 100644
35010 --- a/drivers/firmware/efivars.c
35011 +++ b/drivers/firmware/efivars.c
35012 @@ -138,7 +138,7 @@ struct efivar_attribute {
35013 };
35014
35015 static struct efivars __efivars;
35016 -static struct efivar_operations ops;
35017 +static efivar_operations_no_const ops __read_only;
35018
35019 #define PSTORE_EFI_ATTRIBUTES \
35020 (EFI_VARIABLE_NON_VOLATILE | \
35021 @@ -1834,7 +1834,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
35022 static int
35023 create_efivars_bin_attributes(struct efivars *efivars)
35024 {
35025 - struct bin_attribute *attr;
35026 + bin_attribute_no_const *attr;
35027 int error;
35028
35029 /* new_var */
35030 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
35031 index 2a90ba6..07f3733 100644
35032 --- a/drivers/firmware/google/memconsole.c
35033 +++ b/drivers/firmware/google/memconsole.c
35034 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
35035 if (!found_memconsole())
35036 return -ENODEV;
35037
35038 - memconsole_bin_attr.size = memconsole_length;
35039 + pax_open_kernel();
35040 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
35041 + pax_close_kernel();
35042
35043 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
35044
35045 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
35046 index 6f2306d..af9476a 100644
35047 --- a/drivers/gpio/gpio-ich.c
35048 +++ b/drivers/gpio/gpio-ich.c
35049 @@ -69,7 +69,7 @@ struct ichx_desc {
35050 /* Some chipsets have quirks, let these use their own request/get */
35051 int (*request)(struct gpio_chip *chip, unsigned offset);
35052 int (*get)(struct gpio_chip *chip, unsigned offset);
35053 -};
35054 +} __do_const;
35055
35056 static struct {
35057 spinlock_t lock;
35058 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35059 index 9902732..64b62dd 100644
35060 --- a/drivers/gpio/gpio-vr41xx.c
35061 +++ b/drivers/gpio/gpio-vr41xx.c
35062 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35063 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35064 maskl, pendl, maskh, pendh);
35065
35066 - atomic_inc(&irq_err_count);
35067 + atomic_inc_unchecked(&irq_err_count);
35068
35069 return -EINVAL;
35070 }
35071 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35072 index 7b2d378..cc947ea 100644
35073 --- a/drivers/gpu/drm/drm_crtc_helper.c
35074 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35075 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35076 struct drm_crtc *tmp;
35077 int crtc_mask = 1;
35078
35079 - WARN(!crtc, "checking null crtc?\n");
35080 + BUG_ON(!crtc);
35081
35082 dev = crtc->dev;
35083
35084 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35085 index be174ca..7f38143 100644
35086 --- a/drivers/gpu/drm/drm_drv.c
35087 +++ b/drivers/gpu/drm/drm_drv.c
35088 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
35089 /**
35090 * Copy and IOCTL return string to user space
35091 */
35092 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35093 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35094 {
35095 int len;
35096
35097 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
35098 struct drm_file *file_priv = filp->private_data;
35099 struct drm_device *dev;
35100 struct drm_ioctl_desc *ioctl;
35101 - drm_ioctl_t *func;
35102 + drm_ioctl_no_const_t func;
35103 unsigned int nr = DRM_IOCTL_NR(cmd);
35104 int retcode = -EINVAL;
35105 char stack_kdata[128];
35106 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
35107 return -ENODEV;
35108
35109 atomic_inc(&dev->ioctl_count);
35110 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35111 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35112 ++file_priv->ioctl_count;
35113
35114 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
35115 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35116 index 32d7775..c8be5e1 100644
35117 --- a/drivers/gpu/drm/drm_fops.c
35118 +++ b/drivers/gpu/drm/drm_fops.c
35119 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35120 }
35121
35122 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35123 - atomic_set(&dev->counts[i], 0);
35124 + atomic_set_unchecked(&dev->counts[i], 0);
35125
35126 dev->sigdata.lock = NULL;
35127
35128 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35129 if (drm_device_is_unplugged(dev))
35130 return -ENODEV;
35131
35132 - if (!dev->open_count++)
35133 + if (local_inc_return(&dev->open_count) == 1)
35134 need_setup = 1;
35135 mutex_lock(&dev->struct_mutex);
35136 old_imapping = inode->i_mapping;
35137 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35138 retcode = drm_open_helper(inode, filp, dev);
35139 if (retcode)
35140 goto err_undo;
35141 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35142 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35143 if (need_setup) {
35144 retcode = drm_setup(dev);
35145 if (retcode)
35146 @@ -166,7 +166,7 @@ err_undo:
35147 iput(container_of(dev->dev_mapping, struct inode, i_data));
35148 dev->dev_mapping = old_mapping;
35149 mutex_unlock(&dev->struct_mutex);
35150 - dev->open_count--;
35151 + local_dec(&dev->open_count);
35152 return retcode;
35153 }
35154 EXPORT_SYMBOL(drm_open);
35155 @@ -440,7 +440,7 @@ int drm_release(struct inode *inode, struct file *filp)
35156
35157 mutex_lock(&drm_global_mutex);
35158
35159 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35160 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35161
35162 if (dev->driver->preclose)
35163 dev->driver->preclose(dev, file_priv);
35164 @@ -449,10 +449,10 @@ int drm_release(struct inode *inode, struct file *filp)
35165 * Begin inline drm_release
35166 */
35167
35168 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35169 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35170 task_pid_nr(current),
35171 (long)old_encode_dev(file_priv->minor->device),
35172 - dev->open_count);
35173 + local_read(&dev->open_count));
35174
35175 /* Release any auth tokens that might point to this file_priv,
35176 (do that under the drm_global_mutex) */
35177 @@ -549,8 +549,8 @@ int drm_release(struct inode *inode, struct file *filp)
35178 * End inline drm_release
35179 */
35180
35181 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35182 - if (!--dev->open_count) {
35183 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35184 + if (local_dec_and_test(&dev->open_count)) {
35185 if (atomic_read(&dev->ioctl_count)) {
35186 DRM_ERROR("Device busy: %d\n",
35187 atomic_read(&dev->ioctl_count));
35188 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35189 index f731116..629842c 100644
35190 --- a/drivers/gpu/drm/drm_global.c
35191 +++ b/drivers/gpu/drm/drm_global.c
35192 @@ -36,7 +36,7 @@
35193 struct drm_global_item {
35194 struct mutex mutex;
35195 void *object;
35196 - int refcount;
35197 + atomic_t refcount;
35198 };
35199
35200 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35201 @@ -49,7 +49,7 @@ void drm_global_init(void)
35202 struct drm_global_item *item = &glob[i];
35203 mutex_init(&item->mutex);
35204 item->object = NULL;
35205 - item->refcount = 0;
35206 + atomic_set(&item->refcount, 0);
35207 }
35208 }
35209
35210 @@ -59,7 +59,7 @@ void drm_global_release(void)
35211 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35212 struct drm_global_item *item = &glob[i];
35213 BUG_ON(item->object != NULL);
35214 - BUG_ON(item->refcount != 0);
35215 + BUG_ON(atomic_read(&item->refcount) != 0);
35216 }
35217 }
35218
35219 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35220 void *object;
35221
35222 mutex_lock(&item->mutex);
35223 - if (item->refcount == 0) {
35224 + if (atomic_read(&item->refcount) == 0) {
35225 item->object = kzalloc(ref->size, GFP_KERNEL);
35226 if (unlikely(item->object == NULL)) {
35227 ret = -ENOMEM;
35228 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35229 goto out_err;
35230
35231 }
35232 - ++item->refcount;
35233 + atomic_inc(&item->refcount);
35234 ref->object = item->object;
35235 object = item->object;
35236 mutex_unlock(&item->mutex);
35237 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35238 struct drm_global_item *item = &glob[ref->global_type];
35239
35240 mutex_lock(&item->mutex);
35241 - BUG_ON(item->refcount == 0);
35242 + BUG_ON(atomic_read(&item->refcount) == 0);
35243 BUG_ON(ref->object != item->object);
35244 - if (--item->refcount == 0) {
35245 + if (atomic_dec_and_test(&item->refcount)) {
35246 ref->release(ref);
35247 item->object = NULL;
35248 }
35249 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35250 index d4b20ce..77a8d41 100644
35251 --- a/drivers/gpu/drm/drm_info.c
35252 +++ b/drivers/gpu/drm/drm_info.c
35253 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35254 struct drm_local_map *map;
35255 struct drm_map_list *r_list;
35256
35257 - /* Hardcoded from _DRM_FRAME_BUFFER,
35258 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35259 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35260 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35261 + static const char * const types[] = {
35262 + [_DRM_FRAME_BUFFER] = "FB",
35263 + [_DRM_REGISTERS] = "REG",
35264 + [_DRM_SHM] = "SHM",
35265 + [_DRM_AGP] = "AGP",
35266 + [_DRM_SCATTER_GATHER] = "SG",
35267 + [_DRM_CONSISTENT] = "PCI",
35268 + [_DRM_GEM] = "GEM" };
35269 const char *type;
35270 int i;
35271
35272 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35273 map = r_list->map;
35274 if (!map)
35275 continue;
35276 - if (map->type < 0 || map->type > 5)
35277 + if (map->type >= ARRAY_SIZE(types))
35278 type = "??";
35279 else
35280 type = types[map->type];
35281 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35282 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35283 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35284 vma->vm_flags & VM_IO ? 'i' : '-',
35285 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35286 + 0);
35287 +#else
35288 vma->vm_pgoff);
35289 +#endif
35290
35291 #if defined(__i386__)
35292 pgprot = pgprot_val(vma->vm_page_prot);
35293 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35294 index 2f4c434..dd12cd2 100644
35295 --- a/drivers/gpu/drm/drm_ioc32.c
35296 +++ b/drivers/gpu/drm/drm_ioc32.c
35297 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35298 request = compat_alloc_user_space(nbytes);
35299 if (!access_ok(VERIFY_WRITE, request, nbytes))
35300 return -EFAULT;
35301 - list = (struct drm_buf_desc *) (request + 1);
35302 + list = (struct drm_buf_desc __user *) (request + 1);
35303
35304 if (__put_user(count, &request->count)
35305 || __put_user(list, &request->list))
35306 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35307 request = compat_alloc_user_space(nbytes);
35308 if (!access_ok(VERIFY_WRITE, request, nbytes))
35309 return -EFAULT;
35310 - list = (struct drm_buf_pub *) (request + 1);
35311 + list = (struct drm_buf_pub __user *) (request + 1);
35312
35313 if (__put_user(count, &request->count)
35314 || __put_user(list, &request->list))
35315 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35316 return 0;
35317 }
35318
35319 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35320 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35321 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35322 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35323 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35324 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35325 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35326 {
35327 unsigned int nr = DRM_IOCTL_NR(cmd);
35328 - drm_ioctl_compat_t *fn;
35329 int ret;
35330
35331 /* Assume that ioctls without an explicit compat routine will just
35332 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35333 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35334 return drm_ioctl(filp, cmd, arg);
35335
35336 - fn = drm_compat_ioctls[nr];
35337 -
35338 - if (fn != NULL)
35339 - ret = (*fn) (filp, cmd, arg);
35340 + if (drm_compat_ioctls[nr] != NULL)
35341 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35342 else
35343 ret = drm_ioctl(filp, cmd, arg);
35344
35345 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35346 index e77bd8b..1571b85 100644
35347 --- a/drivers/gpu/drm/drm_ioctl.c
35348 +++ b/drivers/gpu/drm/drm_ioctl.c
35349 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35350 stats->data[i].value =
35351 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35352 else
35353 - stats->data[i].value = atomic_read(&dev->counts[i]);
35354 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35355 stats->data[i].type = dev->types[i];
35356 }
35357
35358 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35359 index d752c96..fe08455 100644
35360 --- a/drivers/gpu/drm/drm_lock.c
35361 +++ b/drivers/gpu/drm/drm_lock.c
35362 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35363 if (drm_lock_take(&master->lock, lock->context)) {
35364 master->lock.file_priv = file_priv;
35365 master->lock.lock_time = jiffies;
35366 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35367 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35368 break; /* Got lock */
35369 }
35370
35371 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35372 return -EINVAL;
35373 }
35374
35375 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35376 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35377
35378 if (drm_lock_free(&master->lock, lock->context)) {
35379 /* FIXME: Should really bail out here. */
35380 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35381 index 200e104..59facda 100644
35382 --- a/drivers/gpu/drm/drm_stub.c
35383 +++ b/drivers/gpu/drm/drm_stub.c
35384 @@ -516,7 +516,7 @@ void drm_unplug_dev(struct drm_device *dev)
35385
35386 drm_device_set_unplugged(dev);
35387
35388 - if (dev->open_count == 0) {
35389 + if (local_read(&dev->open_count) == 0) {
35390 drm_put_dev(dev);
35391 }
35392 mutex_unlock(&drm_global_mutex);
35393 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35394 index 004ecdf..db1f6e0 100644
35395 --- a/drivers/gpu/drm/i810/i810_dma.c
35396 +++ b/drivers/gpu/drm/i810/i810_dma.c
35397 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35398 dma->buflist[vertex->idx],
35399 vertex->discard, vertex->used);
35400
35401 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35402 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35403 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35404 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35405 sarea_priv->last_enqueue = dev_priv->counter - 1;
35406 sarea_priv->last_dispatch = (int)hw_status[5];
35407
35408 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35409 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35410 mc->last_render);
35411
35412 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35413 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35414 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35415 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35416 sarea_priv->last_enqueue = dev_priv->counter - 1;
35417 sarea_priv->last_dispatch = (int)hw_status[5];
35418
35419 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35420 index 6e0acad..93c8289 100644
35421 --- a/drivers/gpu/drm/i810/i810_drv.h
35422 +++ b/drivers/gpu/drm/i810/i810_drv.h
35423 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35424 int page_flipping;
35425
35426 wait_queue_head_t irq_queue;
35427 - atomic_t irq_received;
35428 - atomic_t irq_emitted;
35429 + atomic_unchecked_t irq_received;
35430 + atomic_unchecked_t irq_emitted;
35431
35432 int front_offset;
35433 } drm_i810_private_t;
35434 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35435 index 261efc8e..27af8a5 100644
35436 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35437 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35438 @@ -496,7 +496,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35439 I915_READ(GTIMR));
35440 }
35441 seq_printf(m, "Interrupts received: %d\n",
35442 - atomic_read(&dev_priv->irq_received));
35443 + atomic_read_unchecked(&dev_priv->irq_received));
35444 for_each_ring(ring, dev_priv, i) {
35445 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35446 seq_printf(m,
35447 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35448 index 99daa89..84ebd44 100644
35449 --- a/drivers/gpu/drm/i915/i915_dma.c
35450 +++ b/drivers/gpu/drm/i915/i915_dma.c
35451 @@ -1253,7 +1253,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35452 bool can_switch;
35453
35454 spin_lock(&dev->count_lock);
35455 - can_switch = (dev->open_count == 0);
35456 + can_switch = (local_read(&dev->open_count) == 0);
35457 spin_unlock(&dev->count_lock);
35458 return can_switch;
35459 }
35460 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35461 index 7339a4b..445aaba 100644
35462 --- a/drivers/gpu/drm/i915/i915_drv.h
35463 +++ b/drivers/gpu/drm/i915/i915_drv.h
35464 @@ -656,7 +656,7 @@ typedef struct drm_i915_private {
35465 drm_dma_handle_t *status_page_dmah;
35466 struct resource mch_res;
35467
35468 - atomic_t irq_received;
35469 + atomic_unchecked_t irq_received;
35470
35471 /* protects the irq masks */
35472 spinlock_t irq_lock;
35473 @@ -1102,7 +1102,7 @@ struct drm_i915_gem_object {
35474 * will be page flipped away on the next vblank. When it
35475 * reaches 0, dev_priv->pending_flip_queue will be woken up.
35476 */
35477 - atomic_t pending_flip;
35478 + atomic_unchecked_t pending_flip;
35479 };
35480 #define to_gem_object(obj) (&((struct drm_i915_gem_object *)(obj))->base)
35481
35482 @@ -1633,7 +1633,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35483 struct drm_i915_private *dev_priv, unsigned port);
35484 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35485 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35486 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35487 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35488 {
35489 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35490 }
35491 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35492 index ba8805a..39d5330 100644
35493 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35494 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35495 @@ -672,7 +672,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
35496 i915_gem_clflush_object(obj);
35497
35498 if (obj->base.pending_write_domain)
35499 - flips |= atomic_read(&obj->pending_flip);
35500 + flips |= atomic_read_unchecked(&obj->pending_flip);
35501
35502 flush_domains |= obj->base.write_domain;
35503 }
35504 @@ -703,9 +703,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35505
35506 static int
35507 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35508 - int count)
35509 + unsigned int count)
35510 {
35511 - int i;
35512 + unsigned int i;
35513 int relocs_total = 0;
35514 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35515
35516 @@ -1202,7 +1202,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35517 return -ENOMEM;
35518 }
35519 ret = copy_from_user(exec2_list,
35520 - (struct drm_i915_relocation_entry __user *)
35521 + (struct drm_i915_gem_exec_object2 __user *)
35522 (uintptr_t) args->buffers_ptr,
35523 sizeof(*exec2_list) * args->buffer_count);
35524 if (ret != 0) {
35525 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35526 index 3c59584..500f2e9 100644
35527 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35528 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35529 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35530 (unsigned long)request);
35531 }
35532
35533 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35534 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35535 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35536 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35537 [DRM_I915_GETPARAM] = compat_i915_getparam,
35538 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35539 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35540 {
35541 unsigned int nr = DRM_IOCTL_NR(cmd);
35542 - drm_ioctl_compat_t *fn = NULL;
35543 int ret;
35544
35545 if (nr < DRM_COMMAND_BASE)
35546 return drm_compat_ioctl(filp, cmd, arg);
35547
35548 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35549 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35550 -
35551 - if (fn != NULL)
35552 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35553 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35554 ret = (*fn) (filp, cmd, arg);
35555 - else
35556 + } else
35557 ret = drm_ioctl(filp, cmd, arg);
35558
35559 return ret;
35560 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35561 index fe84338..a863190 100644
35562 --- a/drivers/gpu/drm/i915/i915_irq.c
35563 +++ b/drivers/gpu/drm/i915/i915_irq.c
35564 @@ -535,7 +535,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35565 u32 pipe_stats[I915_MAX_PIPES];
35566 bool blc_event;
35567
35568 - atomic_inc(&dev_priv->irq_received);
35569 + atomic_inc_unchecked(&dev_priv->irq_received);
35570
35571 while (true) {
35572 iir = I915_READ(VLV_IIR);
35573 @@ -688,7 +688,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35574 irqreturn_t ret = IRQ_NONE;
35575 int i;
35576
35577 - atomic_inc(&dev_priv->irq_received);
35578 + atomic_inc_unchecked(&dev_priv->irq_received);
35579
35580 /* disable master interrupt before clearing iir */
35581 de_ier = I915_READ(DEIER);
35582 @@ -760,7 +760,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35583 int ret = IRQ_NONE;
35584 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
35585
35586 - atomic_inc(&dev_priv->irq_received);
35587 + atomic_inc_unchecked(&dev_priv->irq_received);
35588
35589 /* disable master interrupt before clearing iir */
35590 de_ier = I915_READ(DEIER);
35591 @@ -1787,7 +1787,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35592 {
35593 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35594
35595 - atomic_set(&dev_priv->irq_received, 0);
35596 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35597
35598 I915_WRITE(HWSTAM, 0xeffe);
35599
35600 @@ -1813,7 +1813,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35601 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35602 int pipe;
35603
35604 - atomic_set(&dev_priv->irq_received, 0);
35605 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35606
35607 /* VLV magic */
35608 I915_WRITE(VLV_IMR, 0);
35609 @@ -2108,7 +2108,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35610 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35611 int pipe;
35612
35613 - atomic_set(&dev_priv->irq_received, 0);
35614 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35615
35616 for_each_pipe(pipe)
35617 I915_WRITE(PIPESTAT(pipe), 0);
35618 @@ -2159,7 +2159,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35619 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35620 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35621
35622 - atomic_inc(&dev_priv->irq_received);
35623 + atomic_inc_unchecked(&dev_priv->irq_received);
35624
35625 iir = I915_READ16(IIR);
35626 if (iir == 0)
35627 @@ -2244,7 +2244,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35628 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35629 int pipe;
35630
35631 - atomic_set(&dev_priv->irq_received, 0);
35632 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35633
35634 if (I915_HAS_HOTPLUG(dev)) {
35635 I915_WRITE(PORT_HOTPLUG_EN, 0);
35636 @@ -2339,7 +2339,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35637 };
35638 int pipe, ret = IRQ_NONE;
35639
35640 - atomic_inc(&dev_priv->irq_received);
35641 + atomic_inc_unchecked(&dev_priv->irq_received);
35642
35643 iir = I915_READ(IIR);
35644 do {
35645 @@ -2465,7 +2465,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35646 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35647 int pipe;
35648
35649 - atomic_set(&dev_priv->irq_received, 0);
35650 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35651
35652 I915_WRITE(PORT_HOTPLUG_EN, 0);
35653 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35654 @@ -2572,7 +2572,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35655 int irq_received;
35656 int ret = IRQ_NONE, pipe;
35657
35658 - atomic_inc(&dev_priv->irq_received);
35659 + atomic_inc_unchecked(&dev_priv->irq_received);
35660
35661 iir = I915_READ(IIR);
35662
35663 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35664 index d3f834a..0ad1b37 100644
35665 --- a/drivers/gpu/drm/i915/intel_display.c
35666 +++ b/drivers/gpu/drm/i915/intel_display.c
35667 @@ -2255,7 +2255,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
35668
35669 wait_event(dev_priv->pending_flip_queue,
35670 atomic_read(&dev_priv->mm.wedged) ||
35671 - atomic_read(&obj->pending_flip) == 0);
35672 + atomic_read_unchecked(&obj->pending_flip) == 0);
35673
35674 /* Big Hammer, we also need to ensure that any pending
35675 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
35676 @@ -7122,8 +7122,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
35677
35678 obj = work->old_fb_obj;
35679
35680 - atomic_clear_mask(1 << intel_crtc->plane,
35681 - &obj->pending_flip.counter);
35682 + atomic_clear_mask_unchecked(1 << intel_crtc->plane, &obj->pending_flip);
35683 wake_up(&dev_priv->pending_flip_queue);
35684
35685 queue_work(dev_priv->wq, &work->work);
35686 @@ -7486,7 +7485,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35687 /* Block clients from rendering to the new back buffer until
35688 * the flip occurs and the object is no longer visible.
35689 */
35690 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35691 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35692 atomic_inc(&intel_crtc->unpin_work_count);
35693
35694 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
35695 @@ -7504,7 +7503,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35696 cleanup_pending:
35697 atomic_dec(&intel_crtc->unpin_work_count);
35698 crtc->fb = old_fb;
35699 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35700 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35701 drm_gem_object_unreference(&work->old_fb_obj->base);
35702 drm_gem_object_unreference(&obj->base);
35703 mutex_unlock(&dev->struct_mutex);
35704 @@ -8846,13 +8845,13 @@ struct intel_quirk {
35705 int subsystem_vendor;
35706 int subsystem_device;
35707 void (*hook)(struct drm_device *dev);
35708 -};
35709 +} __do_const;
35710
35711 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35712 struct intel_dmi_quirk {
35713 void (*hook)(struct drm_device *dev);
35714 const struct dmi_system_id (*dmi_id_list)[];
35715 -};
35716 +} __do_const;
35717
35718 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35719 {
35720 @@ -8860,18 +8859,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35721 return 1;
35722 }
35723
35724 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35725 + {
35726 + .callback = intel_dmi_reverse_brightness,
35727 + .ident = "NCR Corporation",
35728 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35729 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35730 + },
35731 + },
35732 + { } /* terminating entry */
35733 +};
35734 +
35735 static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35736 {
35737 - .dmi_id_list = &(const struct dmi_system_id[]) {
35738 - {
35739 - .callback = intel_dmi_reverse_brightness,
35740 - .ident = "NCR Corporation",
35741 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35742 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35743 - },
35744 - },
35745 - { } /* terminating entry */
35746 - },
35747 + .dmi_id_list = &intel_dmi_quirks_table,
35748 .hook = quirk_invert_brightness,
35749 },
35750 };
35751 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35752 index 54558a0..2d97005 100644
35753 --- a/drivers/gpu/drm/mga/mga_drv.h
35754 +++ b/drivers/gpu/drm/mga/mga_drv.h
35755 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35756 u32 clear_cmd;
35757 u32 maccess;
35758
35759 - atomic_t vbl_received; /**< Number of vblanks received. */
35760 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35761 wait_queue_head_t fence_queue;
35762 - atomic_t last_fence_retired;
35763 + atomic_unchecked_t last_fence_retired;
35764 u32 next_fence_to_post;
35765
35766 unsigned int fb_cpp;
35767 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35768 index 709e90d..89a1c0d 100644
35769 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35770 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35771 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35772 return 0;
35773 }
35774
35775 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35776 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35777 [DRM_MGA_INIT] = compat_mga_init,
35778 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35779 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35780 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35781 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35782 {
35783 unsigned int nr = DRM_IOCTL_NR(cmd);
35784 - drm_ioctl_compat_t *fn = NULL;
35785 int ret;
35786
35787 if (nr < DRM_COMMAND_BASE)
35788 return drm_compat_ioctl(filp, cmd, arg);
35789
35790 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35791 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35792 -
35793 - if (fn != NULL)
35794 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35795 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35796 ret = (*fn) (filp, cmd, arg);
35797 - else
35798 + } else
35799 ret = drm_ioctl(filp, cmd, arg);
35800
35801 return ret;
35802 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35803 index 598c281..60d590e 100644
35804 --- a/drivers/gpu/drm/mga/mga_irq.c
35805 +++ b/drivers/gpu/drm/mga/mga_irq.c
35806 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35807 if (crtc != 0)
35808 return 0;
35809
35810 - return atomic_read(&dev_priv->vbl_received);
35811 + return atomic_read_unchecked(&dev_priv->vbl_received);
35812 }
35813
35814
35815 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35816 /* VBLANK interrupt */
35817 if (status & MGA_VLINEPEN) {
35818 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35819 - atomic_inc(&dev_priv->vbl_received);
35820 + atomic_inc_unchecked(&dev_priv->vbl_received);
35821 drm_handle_vblank(dev, 0);
35822 handled = 1;
35823 }
35824 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35825 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35826 MGA_WRITE(MGA_PRIMEND, prim_end);
35827
35828 - atomic_inc(&dev_priv->last_fence_retired);
35829 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35830 DRM_WAKEUP(&dev_priv->fence_queue);
35831 handled = 1;
35832 }
35833 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35834 * using fences.
35835 */
35836 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35837 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35838 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35839 - *sequence) <= (1 << 23)));
35840
35841 *sequence = cur_fence;
35842 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35843 index 865eddf..62c4cc3 100644
35844 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35845 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35846 @@ -1015,7 +1015,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35847 struct bit_table {
35848 const char id;
35849 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35850 -};
35851 +} __no_const;
35852
35853 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35854
35855 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35856 index aa89eb9..d45d38b 100644
35857 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35858 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35859 @@ -80,7 +80,7 @@ struct nouveau_drm {
35860 struct drm_global_reference mem_global_ref;
35861 struct ttm_bo_global_ref bo_global_ref;
35862 struct ttm_bo_device bdev;
35863 - atomic_t validate_sequence;
35864 + atomic_unchecked_t validate_sequence;
35865 int (*move)(struct nouveau_channel *,
35866 struct ttm_buffer_object *,
35867 struct ttm_mem_reg *, struct ttm_mem_reg *);
35868 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
35869 index cdb83ac..27f0a16 100644
35870 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h
35871 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
35872 @@ -43,7 +43,7 @@ struct nouveau_fence_priv {
35873 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
35874 struct nouveau_channel *);
35875 u32 (*read)(struct nouveau_channel *);
35876 -};
35877 +} __no_const;
35878
35879 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
35880
35881 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35882 index 8bf695c..9fbc90a 100644
35883 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35884 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35885 @@ -321,7 +321,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35886 int trycnt = 0;
35887 int ret, i;
35888
35889 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35890 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35891 retry:
35892 if (++trycnt > 100000) {
35893 NV_ERROR(drm, "%s failed and gave up.\n", __func__);
35894 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35895 index 08214bc..9208577 100644
35896 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35897 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35898 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35899 unsigned long arg)
35900 {
35901 unsigned int nr = DRM_IOCTL_NR(cmd);
35902 - drm_ioctl_compat_t *fn = NULL;
35903 + drm_ioctl_compat_t fn = NULL;
35904 int ret;
35905
35906 if (nr < DRM_COMMAND_BASE)
35907 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35908 index 25d3495..d81aaf6 100644
35909 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35910 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35911 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35912 bool can_switch;
35913
35914 spin_lock(&dev->count_lock);
35915 - can_switch = (dev->open_count == 0);
35916 + can_switch = (local_read(&dev->open_count) == 0);
35917 spin_unlock(&dev->count_lock);
35918 return can_switch;
35919 }
35920 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35921 index d4660cf..70dbe65 100644
35922 --- a/drivers/gpu/drm/r128/r128_cce.c
35923 +++ b/drivers/gpu/drm/r128/r128_cce.c
35924 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35925
35926 /* GH: Simple idle check.
35927 */
35928 - atomic_set(&dev_priv->idle_count, 0);
35929 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35930
35931 /* We don't support anything other than bus-mastering ring mode,
35932 * but the ring can be in either AGP or PCI space for the ring
35933 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35934 index 930c71b..499aded 100644
35935 --- a/drivers/gpu/drm/r128/r128_drv.h
35936 +++ b/drivers/gpu/drm/r128/r128_drv.h
35937 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35938 int is_pci;
35939 unsigned long cce_buffers_offset;
35940
35941 - atomic_t idle_count;
35942 + atomic_unchecked_t idle_count;
35943
35944 int page_flipping;
35945 int current_page;
35946 u32 crtc_offset;
35947 u32 crtc_offset_cntl;
35948
35949 - atomic_t vbl_received;
35950 + atomic_unchecked_t vbl_received;
35951
35952 u32 color_fmt;
35953 unsigned int front_offset;
35954 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
35955 index a954c54..9cc595c 100644
35956 --- a/drivers/gpu/drm/r128/r128_ioc32.c
35957 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
35958 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
35959 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
35960 }
35961
35962 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
35963 +drm_ioctl_compat_t r128_compat_ioctls[] = {
35964 [DRM_R128_INIT] = compat_r128_init,
35965 [DRM_R128_DEPTH] = compat_r128_depth,
35966 [DRM_R128_STIPPLE] = compat_r128_stipple,
35967 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
35968 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35969 {
35970 unsigned int nr = DRM_IOCTL_NR(cmd);
35971 - drm_ioctl_compat_t *fn = NULL;
35972 int ret;
35973
35974 if (nr < DRM_COMMAND_BASE)
35975 return drm_compat_ioctl(filp, cmd, arg);
35976
35977 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
35978 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35979 -
35980 - if (fn != NULL)
35981 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
35982 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
35983 ret = (*fn) (filp, cmd, arg);
35984 - else
35985 + } else
35986 ret = drm_ioctl(filp, cmd, arg);
35987
35988 return ret;
35989 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
35990 index 2ea4f09..d391371 100644
35991 --- a/drivers/gpu/drm/r128/r128_irq.c
35992 +++ b/drivers/gpu/drm/r128/r128_irq.c
35993 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
35994 if (crtc != 0)
35995 return 0;
35996
35997 - return atomic_read(&dev_priv->vbl_received);
35998 + return atomic_read_unchecked(&dev_priv->vbl_received);
35999 }
36000
36001 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36002 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36003 /* VBLANK interrupt */
36004 if (status & R128_CRTC_VBLANK_INT) {
36005 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
36006 - atomic_inc(&dev_priv->vbl_received);
36007 + atomic_inc_unchecked(&dev_priv->vbl_received);
36008 drm_handle_vblank(dev, 0);
36009 return IRQ_HANDLED;
36010 }
36011 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
36012 index 19bb7e6..de7e2a2 100644
36013 --- a/drivers/gpu/drm/r128/r128_state.c
36014 +++ b/drivers/gpu/drm/r128/r128_state.c
36015 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
36016
36017 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
36018 {
36019 - if (atomic_read(&dev_priv->idle_count) == 0)
36020 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
36021 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
36022 else
36023 - atomic_set(&dev_priv->idle_count, 0);
36024 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36025 }
36026
36027 #endif
36028 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
36029 index 5a82b6b..9e69c73 100644
36030 --- a/drivers/gpu/drm/radeon/mkregtable.c
36031 +++ b/drivers/gpu/drm/radeon/mkregtable.c
36032 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
36033 regex_t mask_rex;
36034 regmatch_t match[4];
36035 char buf[1024];
36036 - size_t end;
36037 + long end;
36038 int len;
36039 int done = 0;
36040 int r;
36041 unsigned o;
36042 struct offset *offset;
36043 char last_reg_s[10];
36044 - int last_reg;
36045 + unsigned long last_reg;
36046
36047 if (regcomp
36048 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
36049 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
36050 index 0d6562b..a154330 100644
36051 --- a/drivers/gpu/drm/radeon/radeon_device.c
36052 +++ b/drivers/gpu/drm/radeon/radeon_device.c
36053 @@ -969,7 +969,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
36054 bool can_switch;
36055
36056 spin_lock(&dev->count_lock);
36057 - can_switch = (dev->open_count == 0);
36058 + can_switch = (local_read(&dev->open_count) == 0);
36059 spin_unlock(&dev->count_lock);
36060 return can_switch;
36061 }
36062 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
36063 index e7fdf16..f4f6490 100644
36064 --- a/drivers/gpu/drm/radeon/radeon_drv.h
36065 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
36066 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
36067
36068 /* SW interrupt */
36069 wait_queue_head_t swi_queue;
36070 - atomic_t swi_emitted;
36071 + atomic_unchecked_t swi_emitted;
36072 int vblank_crtc;
36073 uint32_t irq_enable_reg;
36074 uint32_t r500_disp_irq_reg;
36075 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36076 index c180df8..5fd8186 100644
36077 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36078 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36079 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36080 request = compat_alloc_user_space(sizeof(*request));
36081 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36082 || __put_user(req32.param, &request->param)
36083 - || __put_user((void __user *)(unsigned long)req32.value,
36084 + || __put_user((unsigned long)req32.value,
36085 &request->value))
36086 return -EFAULT;
36087
36088 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36089 #define compat_radeon_cp_setparam NULL
36090 #endif /* X86_64 || IA64 */
36091
36092 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36093 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36094 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36095 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36096 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36097 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36098 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36099 {
36100 unsigned int nr = DRM_IOCTL_NR(cmd);
36101 - drm_ioctl_compat_t *fn = NULL;
36102 int ret;
36103
36104 if (nr < DRM_COMMAND_BASE)
36105 return drm_compat_ioctl(filp, cmd, arg);
36106
36107 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36108 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36109 -
36110 - if (fn != NULL)
36111 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36112 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36113 ret = (*fn) (filp, cmd, arg);
36114 - else
36115 + } else
36116 ret = drm_ioctl(filp, cmd, arg);
36117
36118 return ret;
36119 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36120 index e771033..a0bc6b3 100644
36121 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36122 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36123 @@ -224,8 +224,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36124 unsigned int ret;
36125 RING_LOCALS;
36126
36127 - atomic_inc(&dev_priv->swi_emitted);
36128 - ret = atomic_read(&dev_priv->swi_emitted);
36129 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36130 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36131
36132 BEGIN_RING(4);
36133 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36134 @@ -351,7 +351,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36135 drm_radeon_private_t *dev_priv =
36136 (drm_radeon_private_t *) dev->dev_private;
36137
36138 - atomic_set(&dev_priv->swi_emitted, 0);
36139 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36140 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36141
36142 dev->max_vblank_count = 0x001fffff;
36143 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36144 index 8e9057b..af6dacb 100644
36145 --- a/drivers/gpu/drm/radeon/radeon_state.c
36146 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36147 @@ -2166,7 +2166,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36148 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36149 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36150
36151 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36152 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36153 sarea_priv->nbox * sizeof(depth_boxes[0])))
36154 return -EFAULT;
36155
36156 @@ -3029,7 +3029,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36157 {
36158 drm_radeon_private_t *dev_priv = dev->dev_private;
36159 drm_radeon_getparam_t *param = data;
36160 - int value;
36161 + int value = 0;
36162
36163 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36164
36165 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36166 index 93f760e..8088227 100644
36167 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36168 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36169 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36170 man->size = size >> PAGE_SHIFT;
36171 }
36172
36173 -static struct vm_operations_struct radeon_ttm_vm_ops;
36174 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36175 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36176
36177 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36178 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36179 }
36180 if (unlikely(ttm_vm_ops == NULL)) {
36181 ttm_vm_ops = vma->vm_ops;
36182 + pax_open_kernel();
36183 radeon_ttm_vm_ops = *ttm_vm_ops;
36184 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36185 + pax_close_kernel();
36186 }
36187 vma->vm_ops = &radeon_ttm_vm_ops;
36188 return 0;
36189 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36190 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36191 else
36192 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36193 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36194 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36195 - radeon_mem_types_list[i].driver_features = 0;
36196 + pax_open_kernel();
36197 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36198 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36199 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36200 if (i == 0)
36201 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36202 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36203 else
36204 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36205 -
36206 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36207 + pax_close_kernel();
36208 }
36209 /* Add ttm page pool to debugfs */
36210 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36211 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36212 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36213 - radeon_mem_types_list[i].driver_features = 0;
36214 - radeon_mem_types_list[i++].data = NULL;
36215 + pax_open_kernel();
36216 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36217 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36218 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36219 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36220 + pax_close_kernel();
36221 #ifdef CONFIG_SWIOTLB
36222 if (swiotlb_nr_tbl()) {
36223 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36224 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36225 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36226 - radeon_mem_types_list[i].driver_features = 0;
36227 - radeon_mem_types_list[i++].data = NULL;
36228 + pax_open_kernel();
36229 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36230 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36231 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36232 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36233 + pax_close_kernel();
36234 }
36235 #endif
36236 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36237 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36238 index 5706d2a..17aedaa 100644
36239 --- a/drivers/gpu/drm/radeon/rs690.c
36240 +++ b/drivers/gpu/drm/radeon/rs690.c
36241 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36242 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36243 rdev->pm.sideport_bandwidth.full)
36244 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36245 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36246 + read_delay_latency.full = dfixed_const(800 * 1000);
36247 read_delay_latency.full = dfixed_div(read_delay_latency,
36248 rdev->pm.igp_sideport_mclk);
36249 + a.full = dfixed_const(370);
36250 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36251 } else {
36252 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36253 rdev->pm.k8_bandwidth.full)
36254 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36255 index bd2a3b4..122d9ad 100644
36256 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36257 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36258 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36259 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36260 struct shrink_control *sc)
36261 {
36262 - static atomic_t start_pool = ATOMIC_INIT(0);
36263 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36264 unsigned i;
36265 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36266 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36267 struct ttm_page_pool *pool;
36268 int shrink_pages = sc->nr_to_scan;
36269
36270 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36271 index 1eb060c..188b1fc 100644
36272 --- a/drivers/gpu/drm/udl/udl_fb.c
36273 +++ b/drivers/gpu/drm/udl/udl_fb.c
36274 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36275 fb_deferred_io_cleanup(info);
36276 kfree(info->fbdefio);
36277 info->fbdefio = NULL;
36278 - info->fbops->fb_mmap = udl_fb_mmap;
36279 }
36280
36281 pr_warn("released /dev/fb%d user=%d count=%d\n",
36282 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36283 index 893a650..6190d3b 100644
36284 --- a/drivers/gpu/drm/via/via_drv.h
36285 +++ b/drivers/gpu/drm/via/via_drv.h
36286 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36287 typedef uint32_t maskarray_t[5];
36288
36289 typedef struct drm_via_irq {
36290 - atomic_t irq_received;
36291 + atomic_unchecked_t irq_received;
36292 uint32_t pending_mask;
36293 uint32_t enable_mask;
36294 wait_queue_head_t irq_queue;
36295 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36296 struct timeval last_vblank;
36297 int last_vblank_valid;
36298 unsigned usec_per_vblank;
36299 - atomic_t vbl_received;
36300 + atomic_unchecked_t vbl_received;
36301 drm_via_state_t hc_state;
36302 char pci_buf[VIA_PCI_BUF_SIZE];
36303 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36304 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36305 index ac98964..5dbf512 100644
36306 --- a/drivers/gpu/drm/via/via_irq.c
36307 +++ b/drivers/gpu/drm/via/via_irq.c
36308 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36309 if (crtc != 0)
36310 return 0;
36311
36312 - return atomic_read(&dev_priv->vbl_received);
36313 + return atomic_read_unchecked(&dev_priv->vbl_received);
36314 }
36315
36316 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36317 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36318
36319 status = VIA_READ(VIA_REG_INTERRUPT);
36320 if (status & VIA_IRQ_VBLANK_PENDING) {
36321 - atomic_inc(&dev_priv->vbl_received);
36322 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36323 + atomic_inc_unchecked(&dev_priv->vbl_received);
36324 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36325 do_gettimeofday(&cur_vblank);
36326 if (dev_priv->last_vblank_valid) {
36327 dev_priv->usec_per_vblank =
36328 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36329 dev_priv->last_vblank = cur_vblank;
36330 dev_priv->last_vblank_valid = 1;
36331 }
36332 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36333 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36334 DRM_DEBUG("US per vblank is: %u\n",
36335 dev_priv->usec_per_vblank);
36336 }
36337 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36338
36339 for (i = 0; i < dev_priv->num_irqs; ++i) {
36340 if (status & cur_irq->pending_mask) {
36341 - atomic_inc(&cur_irq->irq_received);
36342 + atomic_inc_unchecked(&cur_irq->irq_received);
36343 DRM_WAKEUP(&cur_irq->irq_queue);
36344 handled = 1;
36345 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36346 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36347 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36348 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36349 masks[irq][4]));
36350 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36351 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36352 } else {
36353 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36354 (((cur_irq_sequence =
36355 - atomic_read(&cur_irq->irq_received)) -
36356 + atomic_read_unchecked(&cur_irq->irq_received)) -
36357 *sequence) <= (1 << 23)));
36358 }
36359 *sequence = cur_irq_sequence;
36360 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36361 }
36362
36363 for (i = 0; i < dev_priv->num_irqs; ++i) {
36364 - atomic_set(&cur_irq->irq_received, 0);
36365 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36366 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36367 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36368 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36369 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36370 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36371 case VIA_IRQ_RELATIVE:
36372 irqwait->request.sequence +=
36373 - atomic_read(&cur_irq->irq_received);
36374 + atomic_read_unchecked(&cur_irq->irq_received);
36375 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36376 case VIA_IRQ_ABSOLUTE:
36377 break;
36378 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36379 index 13aeda7..4a952d1 100644
36380 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36381 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36382 @@ -290,7 +290,7 @@ struct vmw_private {
36383 * Fencing and IRQs.
36384 */
36385
36386 - atomic_t marker_seq;
36387 + atomic_unchecked_t marker_seq;
36388 wait_queue_head_t fence_queue;
36389 wait_queue_head_t fifo_queue;
36390 int fence_queue_waiters; /* Protected by hw_mutex */
36391 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36392 index 3eb1486..0a47ee9 100644
36393 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36394 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36395 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36396 (unsigned int) min,
36397 (unsigned int) fifo->capabilities);
36398
36399 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36400 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36401 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36402 vmw_marker_queue_init(&fifo->marker_queue);
36403 return vmw_fifo_send_fence(dev_priv, &dummy);
36404 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36405 if (reserveable)
36406 iowrite32(bytes, fifo_mem +
36407 SVGA_FIFO_RESERVED);
36408 - return fifo_mem + (next_cmd >> 2);
36409 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36410 } else {
36411 need_bounce = true;
36412 }
36413 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36414
36415 fm = vmw_fifo_reserve(dev_priv, bytes);
36416 if (unlikely(fm == NULL)) {
36417 - *seqno = atomic_read(&dev_priv->marker_seq);
36418 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36419 ret = -ENOMEM;
36420 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36421 false, 3*HZ);
36422 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36423 }
36424
36425 do {
36426 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36427 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36428 } while (*seqno == 0);
36429
36430 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36431 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36432 index 4640adb..e1384ed 100644
36433 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36434 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36435 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36436 * emitted. Then the fence is stale and signaled.
36437 */
36438
36439 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36440 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36441 > VMW_FENCE_WRAP);
36442
36443 return ret;
36444 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36445
36446 if (fifo_idle)
36447 down_read(&fifo_state->rwsem);
36448 - signal_seq = atomic_read(&dev_priv->marker_seq);
36449 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36450 ret = 0;
36451
36452 for (;;) {
36453 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36454 index 8a8725c..afed796 100644
36455 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36456 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36457 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36458 while (!vmw_lag_lt(queue, us)) {
36459 spin_lock(&queue->lock);
36460 if (list_empty(&queue->head))
36461 - seqno = atomic_read(&dev_priv->marker_seq);
36462 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36463 else {
36464 marker = list_first_entry(&queue->head,
36465 struct vmw_marker, head);
36466 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36467 index ceb3040..6160c5c 100644
36468 --- a/drivers/hid/hid-core.c
36469 +++ b/drivers/hid/hid-core.c
36470 @@ -2242,7 +2242,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36471
36472 int hid_add_device(struct hid_device *hdev)
36473 {
36474 - static atomic_t id = ATOMIC_INIT(0);
36475 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36476 int ret;
36477
36478 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36479 @@ -2276,7 +2276,7 @@ int hid_add_device(struct hid_device *hdev)
36480 /* XXX hack, any other cleaner solution after the driver core
36481 * is converted to allow more than 20 bytes as the device name? */
36482 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36483 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36484 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36485
36486 hid_debug_register(hdev, dev_name(&hdev->dev));
36487 ret = device_add(&hdev->dev);
36488 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36489 index eec3291..8ed706b 100644
36490 --- a/drivers/hid/hid-wiimote-debug.c
36491 +++ b/drivers/hid/hid-wiimote-debug.c
36492 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36493 else if (size == 0)
36494 return -EIO;
36495
36496 - if (copy_to_user(u, buf, size))
36497 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36498 return -EFAULT;
36499
36500 *off += size;
36501 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36502 index 773a2f2..7ce08bc 100644
36503 --- a/drivers/hv/channel.c
36504 +++ b/drivers/hv/channel.c
36505 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36506 int ret = 0;
36507 int t;
36508
36509 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36510 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36511 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36512 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36513
36514 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36515 if (ret)
36516 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36517 index 3648f8f..30ef30d 100644
36518 --- a/drivers/hv/hv.c
36519 +++ b/drivers/hv/hv.c
36520 @@ -111,7 +111,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36521 u64 output_address = (output) ? virt_to_phys(output) : 0;
36522 u32 output_address_hi = output_address >> 32;
36523 u32 output_address_lo = output_address & 0xFFFFFFFF;
36524 - void *hypercall_page = hv_context.hypercall_page;
36525 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36526
36527 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36528 "=a"(hv_status_lo) : "d" (control_hi),
36529 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36530 index d8d1fad..b91caf7 100644
36531 --- a/drivers/hv/hyperv_vmbus.h
36532 +++ b/drivers/hv/hyperv_vmbus.h
36533 @@ -594,7 +594,7 @@ enum vmbus_connect_state {
36534 struct vmbus_connection {
36535 enum vmbus_connect_state conn_state;
36536
36537 - atomic_t next_gpadl_handle;
36538 + atomic_unchecked_t next_gpadl_handle;
36539
36540 /*
36541 * Represents channel interrupts. Each bit position represents a
36542 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36543 index 8e1a9ec..4687821 100644
36544 --- a/drivers/hv/vmbus_drv.c
36545 +++ b/drivers/hv/vmbus_drv.c
36546 @@ -629,10 +629,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36547 {
36548 int ret = 0;
36549
36550 - static atomic_t device_num = ATOMIC_INIT(0);
36551 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36552
36553 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36554 - atomic_inc_return(&device_num));
36555 + atomic_inc_return_unchecked(&device_num));
36556
36557 child_device_obj->device.bus = &hv_bus;
36558 child_device_obj->device.parent = &hv_acpi_dev->dev;
36559 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36560 index 1672e2a..4a6297c 100644
36561 --- a/drivers/hwmon/acpi_power_meter.c
36562 +++ b/drivers/hwmon/acpi_power_meter.c
36563 @@ -117,7 +117,7 @@ struct sensor_template {
36564 struct device_attribute *devattr,
36565 const char *buf, size_t count);
36566 int index;
36567 -};
36568 +} __do_const;
36569
36570 /* Averaging interval */
36571 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36572 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36573 struct sensor_template *attrs)
36574 {
36575 struct device *dev = &resource->acpi_dev->dev;
36576 - struct sensor_device_attribute *sensors =
36577 + sensor_device_attribute_no_const *sensors =
36578 &resource->sensors[resource->num_sensors];
36579 int res = 0;
36580
36581 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36582 index b41baff..4953e4d 100644
36583 --- a/drivers/hwmon/applesmc.c
36584 +++ b/drivers/hwmon/applesmc.c
36585 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36586 {
36587 struct applesmc_node_group *grp;
36588 struct applesmc_dev_attr *node;
36589 - struct attribute *attr;
36590 + attribute_no_const *attr;
36591 int ret, i;
36592
36593 for (grp = groups; grp->format; grp++) {
36594 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36595 index 56dbcfb..9874bf1 100644
36596 --- a/drivers/hwmon/asus_atk0110.c
36597 +++ b/drivers/hwmon/asus_atk0110.c
36598 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36599 struct atk_sensor_data {
36600 struct list_head list;
36601 struct atk_data *data;
36602 - struct device_attribute label_attr;
36603 - struct device_attribute input_attr;
36604 - struct device_attribute limit1_attr;
36605 - struct device_attribute limit2_attr;
36606 + device_attribute_no_const label_attr;
36607 + device_attribute_no_const input_attr;
36608 + device_attribute_no_const limit1_attr;
36609 + device_attribute_no_const limit2_attr;
36610 char label_attr_name[ATTR_NAME_SIZE];
36611 char input_attr_name[ATTR_NAME_SIZE];
36612 char limit1_attr_name[ATTR_NAME_SIZE];
36613 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36614 static struct device_attribute atk_name_attr =
36615 __ATTR(name, 0444, atk_name_show, NULL);
36616
36617 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36618 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36619 sysfs_show_func show)
36620 {
36621 sysfs_attr_init(&attr->attr);
36622 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36623 index d64923d..72591e8 100644
36624 --- a/drivers/hwmon/coretemp.c
36625 +++ b/drivers/hwmon/coretemp.c
36626 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36627 return NOTIFY_OK;
36628 }
36629
36630 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36631 +static struct notifier_block coretemp_cpu_notifier = {
36632 .notifier_call = coretemp_cpu_callback,
36633 };
36634
36635 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36636 index a14f634..2916ee2 100644
36637 --- a/drivers/hwmon/ibmaem.c
36638 +++ b/drivers/hwmon/ibmaem.c
36639 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36640 struct aem_rw_sensor_template *rw)
36641 {
36642 struct device *dev = &data->pdev->dev;
36643 - struct sensor_device_attribute *sensors = data->sensors;
36644 + sensor_device_attribute_no_const *sensors = data->sensors;
36645 int err;
36646
36647 /* Set up read-only sensors */
36648 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36649 index 7d19b1b..8fdaaac 100644
36650 --- a/drivers/hwmon/pmbus/pmbus_core.c
36651 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36652 @@ -811,7 +811,7 @@ static ssize_t pmbus_show_label(struct device *dev,
36653
36654 #define PMBUS_ADD_ATTR(data, _name, _idx, _mode, _type, _show, _set) \
36655 do { \
36656 - struct sensor_device_attribute *a \
36657 + sensor_device_attribute_no_const *a \
36658 = &data->_type##s[data->num_##_type##s].attribute; \
36659 BUG_ON(data->num_attributes >= data->max_attributes); \
36660 sysfs_attr_init(&a->dev_attr.attr); \
36661 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36662 index 8047fed..1e956f0 100644
36663 --- a/drivers/hwmon/sht15.c
36664 +++ b/drivers/hwmon/sht15.c
36665 @@ -169,7 +169,7 @@ struct sht15_data {
36666 int supply_uV;
36667 bool supply_uV_valid;
36668 struct work_struct update_supply_work;
36669 - atomic_t interrupt_handled;
36670 + atomic_unchecked_t interrupt_handled;
36671 };
36672
36673 /**
36674 @@ -512,13 +512,13 @@ static int sht15_measurement(struct sht15_data *data,
36675 return ret;
36676
36677 gpio_direction_input(data->pdata->gpio_data);
36678 - atomic_set(&data->interrupt_handled, 0);
36679 + atomic_set_unchecked(&data->interrupt_handled, 0);
36680
36681 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36682 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36683 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36684 /* Only relevant if the interrupt hasn't occurred. */
36685 - if (!atomic_read(&data->interrupt_handled))
36686 + if (!atomic_read_unchecked(&data->interrupt_handled))
36687 schedule_work(&data->read_work);
36688 }
36689 ret = wait_event_timeout(data->wait_queue,
36690 @@ -785,7 +785,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36691
36692 /* First disable the interrupt */
36693 disable_irq_nosync(irq);
36694 - atomic_inc(&data->interrupt_handled);
36695 + atomic_inc_unchecked(&data->interrupt_handled);
36696 /* Then schedule a reading work struct */
36697 if (data->state != SHT15_READING_NOTHING)
36698 schedule_work(&data->read_work);
36699 @@ -807,11 +807,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36700 * If not, then start the interrupt again - care here as could
36701 * have gone low in meantime so verify it hasn't!
36702 */
36703 - atomic_set(&data->interrupt_handled, 0);
36704 + atomic_set_unchecked(&data->interrupt_handled, 0);
36705 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36706 /* If still not occurred or another handler was scheduled */
36707 if (gpio_get_value(data->pdata->gpio_data)
36708 - || atomic_read(&data->interrupt_handled))
36709 + || atomic_read_unchecked(&data->interrupt_handled))
36710 return;
36711 }
36712
36713 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36714 index 76f157b..9c0db1b 100644
36715 --- a/drivers/hwmon/via-cputemp.c
36716 +++ b/drivers/hwmon/via-cputemp.c
36717 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36718 return NOTIFY_OK;
36719 }
36720
36721 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36722 +static struct notifier_block via_cputemp_cpu_notifier = {
36723 .notifier_call = via_cputemp_cpu_callback,
36724 };
36725
36726 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36727 index 378fcb5..5e91fa8 100644
36728 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36729 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36730 @@ -43,7 +43,7 @@
36731 extern struct i2c_adapter amd756_smbus;
36732
36733 static struct i2c_adapter *s4882_adapter;
36734 -static struct i2c_algorithm *s4882_algo;
36735 +static i2c_algorithm_no_const *s4882_algo;
36736
36737 /* Wrapper access functions for multiplexed SMBus */
36738 static DEFINE_MUTEX(amd756_lock);
36739 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36740 index 29015eb..af2d8e9 100644
36741 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36742 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36743 @@ -41,7 +41,7 @@
36744 extern struct i2c_adapter *nforce2_smbus;
36745
36746 static struct i2c_adapter *s4985_adapter;
36747 -static struct i2c_algorithm *s4985_algo;
36748 +static i2c_algorithm_no_const *s4985_algo;
36749
36750 /* Wrapper access functions for multiplexed SMBus */
36751 static DEFINE_MUTEX(nforce2_lock);
36752 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36753 index 8126824..55a2798 100644
36754 --- a/drivers/ide/ide-cd.c
36755 +++ b/drivers/ide/ide-cd.c
36756 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36757 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36758 if ((unsigned long)buf & alignment
36759 || blk_rq_bytes(rq) & q->dma_pad_mask
36760 - || object_is_on_stack(buf))
36761 + || object_starts_on_stack(buf))
36762 drive->dma = 0;
36763 }
36764 }
36765 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36766 index 8848f16..f8e6dd8 100644
36767 --- a/drivers/iio/industrialio-core.c
36768 +++ b/drivers/iio/industrialio-core.c
36769 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36770 }
36771
36772 static
36773 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36774 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36775 const char *postfix,
36776 struct iio_chan_spec const *chan,
36777 ssize_t (*readfunc)(struct device *dev,
36778 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36779 index 394fea2..c833880 100644
36780 --- a/drivers/infiniband/core/cm.c
36781 +++ b/drivers/infiniband/core/cm.c
36782 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36783
36784 struct cm_counter_group {
36785 struct kobject obj;
36786 - atomic_long_t counter[CM_ATTR_COUNT];
36787 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36788 };
36789
36790 struct cm_counter_attribute {
36791 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36792 struct ib_mad_send_buf *msg = NULL;
36793 int ret;
36794
36795 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36796 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36797 counter[CM_REQ_COUNTER]);
36798
36799 /* Quick state check to discard duplicate REQs. */
36800 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36801 if (!cm_id_priv)
36802 return;
36803
36804 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36805 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36806 counter[CM_REP_COUNTER]);
36807 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36808 if (ret)
36809 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
36810 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36811 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36812 spin_unlock_irq(&cm_id_priv->lock);
36813 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36814 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36815 counter[CM_RTU_COUNTER]);
36816 goto out;
36817 }
36818 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
36819 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36820 dreq_msg->local_comm_id);
36821 if (!cm_id_priv) {
36822 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36823 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36824 counter[CM_DREQ_COUNTER]);
36825 cm_issue_drep(work->port, work->mad_recv_wc);
36826 return -EINVAL;
36827 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
36828 case IB_CM_MRA_REP_RCVD:
36829 break;
36830 case IB_CM_TIMEWAIT:
36831 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36832 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36833 counter[CM_DREQ_COUNTER]);
36834 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36835 goto unlock;
36836 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
36837 cm_free_msg(msg);
36838 goto deref;
36839 case IB_CM_DREQ_RCVD:
36840 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36841 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36842 counter[CM_DREQ_COUNTER]);
36843 goto unlock;
36844 default:
36845 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
36846 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36847 cm_id_priv->msg, timeout)) {
36848 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36849 - atomic_long_inc(&work->port->
36850 + atomic_long_inc_unchecked(&work->port->
36851 counter_group[CM_RECV_DUPLICATES].
36852 counter[CM_MRA_COUNTER]);
36853 goto out;
36854 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
36855 break;
36856 case IB_CM_MRA_REQ_RCVD:
36857 case IB_CM_MRA_REP_RCVD:
36858 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36859 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36860 counter[CM_MRA_COUNTER]);
36861 /* fall through */
36862 default:
36863 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
36864 case IB_CM_LAP_IDLE:
36865 break;
36866 case IB_CM_MRA_LAP_SENT:
36867 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36868 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36869 counter[CM_LAP_COUNTER]);
36870 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36871 goto unlock;
36872 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
36873 cm_free_msg(msg);
36874 goto deref;
36875 case IB_CM_LAP_RCVD:
36876 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36877 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36878 counter[CM_LAP_COUNTER]);
36879 goto unlock;
36880 default:
36881 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36882 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36883 if (cur_cm_id_priv) {
36884 spin_unlock_irq(&cm.lock);
36885 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36886 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36887 counter[CM_SIDR_REQ_COUNTER]);
36888 goto out; /* Duplicate message. */
36889 }
36890 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36891 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36892 msg->retries = 1;
36893
36894 - atomic_long_add(1 + msg->retries,
36895 + atomic_long_add_unchecked(1 + msg->retries,
36896 &port->counter_group[CM_XMIT].counter[attr_index]);
36897 if (msg->retries)
36898 - atomic_long_add(msg->retries,
36899 + atomic_long_add_unchecked(msg->retries,
36900 &port->counter_group[CM_XMIT_RETRIES].
36901 counter[attr_index]);
36902
36903 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36904 }
36905
36906 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36907 - atomic_long_inc(&port->counter_group[CM_RECV].
36908 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36909 counter[attr_id - CM_ATTR_ID_OFFSET]);
36910
36911 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36912 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36913 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36914
36915 return sprintf(buf, "%ld\n",
36916 - atomic_long_read(&group->counter[cm_attr->index]));
36917 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36918 }
36919
36920 static const struct sysfs_ops cm_counter_ops = {
36921 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36922 index 176c8f9..2627b62 100644
36923 --- a/drivers/infiniband/core/fmr_pool.c
36924 +++ b/drivers/infiniband/core/fmr_pool.c
36925 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36926
36927 struct task_struct *thread;
36928
36929 - atomic_t req_ser;
36930 - atomic_t flush_ser;
36931 + atomic_unchecked_t req_ser;
36932 + atomic_unchecked_t flush_ser;
36933
36934 wait_queue_head_t force_wait;
36935 };
36936 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36937 struct ib_fmr_pool *pool = pool_ptr;
36938
36939 do {
36940 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36941 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
36942 ib_fmr_batch_release(pool);
36943
36944 - atomic_inc(&pool->flush_ser);
36945 + atomic_inc_unchecked(&pool->flush_ser);
36946 wake_up_interruptible(&pool->force_wait);
36947
36948 if (pool->flush_function)
36949 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36950 }
36951
36952 set_current_state(TASK_INTERRUPTIBLE);
36953 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
36954 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
36955 !kthread_should_stop())
36956 schedule();
36957 __set_current_state(TASK_RUNNING);
36958 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
36959 pool->dirty_watermark = params->dirty_watermark;
36960 pool->dirty_len = 0;
36961 spin_lock_init(&pool->pool_lock);
36962 - atomic_set(&pool->req_ser, 0);
36963 - atomic_set(&pool->flush_ser, 0);
36964 + atomic_set_unchecked(&pool->req_ser, 0);
36965 + atomic_set_unchecked(&pool->flush_ser, 0);
36966 init_waitqueue_head(&pool->force_wait);
36967
36968 pool->thread = kthread_run(ib_fmr_cleanup_thread,
36969 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
36970 }
36971 spin_unlock_irq(&pool->pool_lock);
36972
36973 - serial = atomic_inc_return(&pool->req_ser);
36974 + serial = atomic_inc_return_unchecked(&pool->req_ser);
36975 wake_up_process(pool->thread);
36976
36977 if (wait_event_interruptible(pool->force_wait,
36978 - atomic_read(&pool->flush_ser) - serial >= 0))
36979 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
36980 return -EINTR;
36981
36982 return 0;
36983 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
36984 } else {
36985 list_add_tail(&fmr->list, &pool->dirty_list);
36986 if (++pool->dirty_len >= pool->dirty_watermark) {
36987 - atomic_inc(&pool->req_ser);
36988 + atomic_inc_unchecked(&pool->req_ser);
36989 wake_up_process(pool->thread);
36990 }
36991 }
36992 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
36993 index afd8179..598063f 100644
36994 --- a/drivers/infiniband/hw/cxgb4/mem.c
36995 +++ b/drivers/infiniband/hw/cxgb4/mem.c
36996 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
36997 int err;
36998 struct fw_ri_tpte tpt;
36999 u32 stag_idx;
37000 - static atomic_t key;
37001 + static atomic_unchecked_t key;
37002
37003 if (c4iw_fatal_error(rdev))
37004 return -EIO;
37005 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37006 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37007 rdev->stats.stag.max = rdev->stats.stag.cur;
37008 mutex_unlock(&rdev->stats.lock);
37009 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37010 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37011 }
37012 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37013 __func__, stag_state, type, pdid, stag_idx);
37014 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37015 index 79b3dbc..96e5fcc 100644
37016 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37017 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37018 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37019 struct ib_atomic_eth *ateth;
37020 struct ipath_ack_entry *e;
37021 u64 vaddr;
37022 - atomic64_t *maddr;
37023 + atomic64_unchecked_t *maddr;
37024 u64 sdata;
37025 u32 rkey;
37026 u8 next;
37027 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37028 IB_ACCESS_REMOTE_ATOMIC)))
37029 goto nack_acc_unlck;
37030 /* Perform atomic OP and save result. */
37031 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37032 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37033 sdata = be64_to_cpu(ateth->swap_data);
37034 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37035 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37036 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37037 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37038 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37039 be64_to_cpu(ateth->compare_data),
37040 sdata);
37041 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37042 index 1f95bba..9530f87 100644
37043 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37044 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37045 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37046 unsigned long flags;
37047 struct ib_wc wc;
37048 u64 sdata;
37049 - atomic64_t *maddr;
37050 + atomic64_unchecked_t *maddr;
37051 enum ib_wc_status send_status;
37052
37053 /*
37054 @@ -382,11 +382,11 @@ again:
37055 IB_ACCESS_REMOTE_ATOMIC)))
37056 goto acc_err;
37057 /* Perform atomic OP and save result. */
37058 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37059 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37060 sdata = wqe->wr.wr.atomic.compare_add;
37061 *(u64 *) sqp->s_sge.sge.vaddr =
37062 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37063 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37064 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37065 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37066 sdata, wqe->wr.wr.atomic.swap);
37067 goto send_comp;
37068 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37069 index 9d3e5c1..d9afe4a 100644
37070 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37071 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37072 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37073 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37074 }
37075
37076 -int mthca_QUERY_FW(struct mthca_dev *dev)
37077 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37078 {
37079 struct mthca_mailbox *mailbox;
37080 u32 *outbox;
37081 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37082 index ed9a989..e0c5871 100644
37083 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37084 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37085 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37086 return key;
37087 }
37088
37089 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37090 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37091 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37092 {
37093 struct mthca_mailbox *mailbox;
37094 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37095 index 5b152a3..c1f3e83 100644
37096 --- a/drivers/infiniband/hw/nes/nes.c
37097 +++ b/drivers/infiniband/hw/nes/nes.c
37098 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37099 LIST_HEAD(nes_adapter_list);
37100 static LIST_HEAD(nes_dev_list);
37101
37102 -atomic_t qps_destroyed;
37103 +atomic_unchecked_t qps_destroyed;
37104
37105 static unsigned int ee_flsh_adapter;
37106 static unsigned int sysfs_nonidx_addr;
37107 @@ -267,7 +267,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37108 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37109 struct nes_adapter *nesadapter = nesdev->nesadapter;
37110
37111 - atomic_inc(&qps_destroyed);
37112 + atomic_inc_unchecked(&qps_destroyed);
37113
37114 /* Free the control structures */
37115
37116 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37117 index 33cc589..3bd6538 100644
37118 --- a/drivers/infiniband/hw/nes/nes.h
37119 +++ b/drivers/infiniband/hw/nes/nes.h
37120 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37121 extern unsigned int wqm_quanta;
37122 extern struct list_head nes_adapter_list;
37123
37124 -extern atomic_t cm_connects;
37125 -extern atomic_t cm_accepts;
37126 -extern atomic_t cm_disconnects;
37127 -extern atomic_t cm_closes;
37128 -extern atomic_t cm_connecteds;
37129 -extern atomic_t cm_connect_reqs;
37130 -extern atomic_t cm_rejects;
37131 -extern atomic_t mod_qp_timouts;
37132 -extern atomic_t qps_created;
37133 -extern atomic_t qps_destroyed;
37134 -extern atomic_t sw_qps_destroyed;
37135 +extern atomic_unchecked_t cm_connects;
37136 +extern atomic_unchecked_t cm_accepts;
37137 +extern atomic_unchecked_t cm_disconnects;
37138 +extern atomic_unchecked_t cm_closes;
37139 +extern atomic_unchecked_t cm_connecteds;
37140 +extern atomic_unchecked_t cm_connect_reqs;
37141 +extern atomic_unchecked_t cm_rejects;
37142 +extern atomic_unchecked_t mod_qp_timouts;
37143 +extern atomic_unchecked_t qps_created;
37144 +extern atomic_unchecked_t qps_destroyed;
37145 +extern atomic_unchecked_t sw_qps_destroyed;
37146 extern u32 mh_detected;
37147 extern u32 mh_pauses_sent;
37148 extern u32 cm_packets_sent;
37149 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37150 extern u32 cm_packets_received;
37151 extern u32 cm_packets_dropped;
37152 extern u32 cm_packets_retrans;
37153 -extern atomic_t cm_listens_created;
37154 -extern atomic_t cm_listens_destroyed;
37155 +extern atomic_unchecked_t cm_listens_created;
37156 +extern atomic_unchecked_t cm_listens_destroyed;
37157 extern u32 cm_backlog_drops;
37158 -extern atomic_t cm_loopbacks;
37159 -extern atomic_t cm_nodes_created;
37160 -extern atomic_t cm_nodes_destroyed;
37161 -extern atomic_t cm_accel_dropped_pkts;
37162 -extern atomic_t cm_resets_recvd;
37163 -extern atomic_t pau_qps_created;
37164 -extern atomic_t pau_qps_destroyed;
37165 +extern atomic_unchecked_t cm_loopbacks;
37166 +extern atomic_unchecked_t cm_nodes_created;
37167 +extern atomic_unchecked_t cm_nodes_destroyed;
37168 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37169 +extern atomic_unchecked_t cm_resets_recvd;
37170 +extern atomic_unchecked_t pau_qps_created;
37171 +extern atomic_unchecked_t pau_qps_destroyed;
37172
37173 extern u32 int_mod_timer_init;
37174 extern u32 int_mod_cq_depth_256;
37175 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37176 index 22ea67e..dcbe3bc 100644
37177 --- a/drivers/infiniband/hw/nes/nes_cm.c
37178 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37179 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37180 u32 cm_packets_retrans;
37181 u32 cm_packets_created;
37182 u32 cm_packets_received;
37183 -atomic_t cm_listens_created;
37184 -atomic_t cm_listens_destroyed;
37185 +atomic_unchecked_t cm_listens_created;
37186 +atomic_unchecked_t cm_listens_destroyed;
37187 u32 cm_backlog_drops;
37188 -atomic_t cm_loopbacks;
37189 -atomic_t cm_nodes_created;
37190 -atomic_t cm_nodes_destroyed;
37191 -atomic_t cm_accel_dropped_pkts;
37192 -atomic_t cm_resets_recvd;
37193 +atomic_unchecked_t cm_loopbacks;
37194 +atomic_unchecked_t cm_nodes_created;
37195 +atomic_unchecked_t cm_nodes_destroyed;
37196 +atomic_unchecked_t cm_accel_dropped_pkts;
37197 +atomic_unchecked_t cm_resets_recvd;
37198
37199 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37200 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37201 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37202
37203 static struct nes_cm_core *g_cm_core;
37204
37205 -atomic_t cm_connects;
37206 -atomic_t cm_accepts;
37207 -atomic_t cm_disconnects;
37208 -atomic_t cm_closes;
37209 -atomic_t cm_connecteds;
37210 -atomic_t cm_connect_reqs;
37211 -atomic_t cm_rejects;
37212 +atomic_unchecked_t cm_connects;
37213 +atomic_unchecked_t cm_accepts;
37214 +atomic_unchecked_t cm_disconnects;
37215 +atomic_unchecked_t cm_closes;
37216 +atomic_unchecked_t cm_connecteds;
37217 +atomic_unchecked_t cm_connect_reqs;
37218 +atomic_unchecked_t cm_rejects;
37219
37220 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37221 {
37222 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37223 kfree(listener);
37224 listener = NULL;
37225 ret = 0;
37226 - atomic_inc(&cm_listens_destroyed);
37227 + atomic_inc_unchecked(&cm_listens_destroyed);
37228 } else {
37229 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37230 }
37231 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37232 cm_node->rem_mac);
37233
37234 add_hte_node(cm_core, cm_node);
37235 - atomic_inc(&cm_nodes_created);
37236 + atomic_inc_unchecked(&cm_nodes_created);
37237
37238 return cm_node;
37239 }
37240 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37241 }
37242
37243 atomic_dec(&cm_core->node_cnt);
37244 - atomic_inc(&cm_nodes_destroyed);
37245 + atomic_inc_unchecked(&cm_nodes_destroyed);
37246 nesqp = cm_node->nesqp;
37247 if (nesqp) {
37248 nesqp->cm_node = NULL;
37249 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37250
37251 static void drop_packet(struct sk_buff *skb)
37252 {
37253 - atomic_inc(&cm_accel_dropped_pkts);
37254 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37255 dev_kfree_skb_any(skb);
37256 }
37257
37258 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37259 {
37260
37261 int reset = 0; /* whether to send reset in case of err.. */
37262 - atomic_inc(&cm_resets_recvd);
37263 + atomic_inc_unchecked(&cm_resets_recvd);
37264 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37265 " refcnt=%d\n", cm_node, cm_node->state,
37266 atomic_read(&cm_node->ref_count));
37267 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37268 rem_ref_cm_node(cm_node->cm_core, cm_node);
37269 return NULL;
37270 }
37271 - atomic_inc(&cm_loopbacks);
37272 + atomic_inc_unchecked(&cm_loopbacks);
37273 loopbackremotenode->loopbackpartner = cm_node;
37274 loopbackremotenode->tcp_cntxt.rcv_wscale =
37275 NES_CM_DEFAULT_RCV_WND_SCALE;
37276 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37277 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37278 else {
37279 rem_ref_cm_node(cm_core, cm_node);
37280 - atomic_inc(&cm_accel_dropped_pkts);
37281 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37282 dev_kfree_skb_any(skb);
37283 }
37284 break;
37285 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37286
37287 if ((cm_id) && (cm_id->event_handler)) {
37288 if (issue_disconn) {
37289 - atomic_inc(&cm_disconnects);
37290 + atomic_inc_unchecked(&cm_disconnects);
37291 cm_event.event = IW_CM_EVENT_DISCONNECT;
37292 cm_event.status = disconn_status;
37293 cm_event.local_addr = cm_id->local_addr;
37294 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37295 }
37296
37297 if (issue_close) {
37298 - atomic_inc(&cm_closes);
37299 + atomic_inc_unchecked(&cm_closes);
37300 nes_disconnect(nesqp, 1);
37301
37302 cm_id->provider_data = nesqp;
37303 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37304
37305 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37306 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37307 - atomic_inc(&cm_accepts);
37308 + atomic_inc_unchecked(&cm_accepts);
37309
37310 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37311 netdev_refcnt_read(nesvnic->netdev));
37312 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37313 struct nes_cm_core *cm_core;
37314 u8 *start_buff;
37315
37316 - atomic_inc(&cm_rejects);
37317 + atomic_inc_unchecked(&cm_rejects);
37318 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37319 loopback = cm_node->loopbackpartner;
37320 cm_core = cm_node->cm_core;
37321 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37322 ntohl(cm_id->local_addr.sin_addr.s_addr),
37323 ntohs(cm_id->local_addr.sin_port));
37324
37325 - atomic_inc(&cm_connects);
37326 + atomic_inc_unchecked(&cm_connects);
37327 nesqp->active_conn = 1;
37328
37329 /* cache the cm_id in the qp */
37330 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37331 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37332 return err;
37333 }
37334 - atomic_inc(&cm_listens_created);
37335 + atomic_inc_unchecked(&cm_listens_created);
37336 }
37337
37338 cm_id->add_ref(cm_id);
37339 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37340
37341 if (nesqp->destroyed)
37342 return;
37343 - atomic_inc(&cm_connecteds);
37344 + atomic_inc_unchecked(&cm_connecteds);
37345 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37346 " local port 0x%04X. jiffies = %lu.\n",
37347 nesqp->hwqp.qp_id,
37348 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37349
37350 cm_id->add_ref(cm_id);
37351 ret = cm_id->event_handler(cm_id, &cm_event);
37352 - atomic_inc(&cm_closes);
37353 + atomic_inc_unchecked(&cm_closes);
37354 cm_event.event = IW_CM_EVENT_CLOSE;
37355 cm_event.status = 0;
37356 cm_event.provider_data = cm_id->provider_data;
37357 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37358 return;
37359 cm_id = cm_node->cm_id;
37360
37361 - atomic_inc(&cm_connect_reqs);
37362 + atomic_inc_unchecked(&cm_connect_reqs);
37363 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37364 cm_node, cm_id, jiffies);
37365
37366 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37367 return;
37368 cm_id = cm_node->cm_id;
37369
37370 - atomic_inc(&cm_connect_reqs);
37371 + atomic_inc_unchecked(&cm_connect_reqs);
37372 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37373 cm_node, cm_id, jiffies);
37374
37375 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37376 index 4166452..fc952c3 100644
37377 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37378 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37379 @@ -40,8 +40,8 @@
37380 #include "nes.h"
37381 #include "nes_mgt.h"
37382
37383 -atomic_t pau_qps_created;
37384 -atomic_t pau_qps_destroyed;
37385 +atomic_unchecked_t pau_qps_created;
37386 +atomic_unchecked_t pau_qps_destroyed;
37387
37388 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37389 {
37390 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37391 {
37392 struct sk_buff *skb;
37393 unsigned long flags;
37394 - atomic_inc(&pau_qps_destroyed);
37395 + atomic_inc_unchecked(&pau_qps_destroyed);
37396
37397 /* Free packets that have not yet been forwarded */
37398 /* Lock is acquired by skb_dequeue when removing the skb */
37399 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37400 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37401 skb_queue_head_init(&nesqp->pau_list);
37402 spin_lock_init(&nesqp->pau_lock);
37403 - atomic_inc(&pau_qps_created);
37404 + atomic_inc_unchecked(&pau_qps_created);
37405 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37406 }
37407
37408 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37409 index 9542e16..a008c40 100644
37410 --- a/drivers/infiniband/hw/nes/nes_nic.c
37411 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37412 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37413 target_stat_values[++index] = mh_detected;
37414 target_stat_values[++index] = mh_pauses_sent;
37415 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37416 - target_stat_values[++index] = atomic_read(&cm_connects);
37417 - target_stat_values[++index] = atomic_read(&cm_accepts);
37418 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37419 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37420 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37421 - target_stat_values[++index] = atomic_read(&cm_rejects);
37422 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37423 - target_stat_values[++index] = atomic_read(&qps_created);
37424 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37425 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37426 - target_stat_values[++index] = atomic_read(&cm_closes);
37427 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37428 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37429 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37430 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37431 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37432 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37433 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37434 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37435 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37436 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37437 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37438 target_stat_values[++index] = cm_packets_sent;
37439 target_stat_values[++index] = cm_packets_bounced;
37440 target_stat_values[++index] = cm_packets_created;
37441 target_stat_values[++index] = cm_packets_received;
37442 target_stat_values[++index] = cm_packets_dropped;
37443 target_stat_values[++index] = cm_packets_retrans;
37444 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37445 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37446 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37447 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37448 target_stat_values[++index] = cm_backlog_drops;
37449 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37450 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37451 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37452 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37453 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37454 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37455 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37456 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37457 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37458 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37459 target_stat_values[++index] = nesadapter->free_4kpbl;
37460 target_stat_values[++index] = nesadapter->free_256pbl;
37461 target_stat_values[++index] = int_mod_timer_init;
37462 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37463 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37464 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37465 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37466 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37467 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37468 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37469 }
37470
37471 /**
37472 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37473 index 07e4fba..685f041 100644
37474 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37475 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37476 @@ -46,9 +46,9 @@
37477
37478 #include <rdma/ib_umem.h>
37479
37480 -atomic_t mod_qp_timouts;
37481 -atomic_t qps_created;
37482 -atomic_t sw_qps_destroyed;
37483 +atomic_unchecked_t mod_qp_timouts;
37484 +atomic_unchecked_t qps_created;
37485 +atomic_unchecked_t sw_qps_destroyed;
37486
37487 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37488
37489 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37490 if (init_attr->create_flags)
37491 return ERR_PTR(-EINVAL);
37492
37493 - atomic_inc(&qps_created);
37494 + atomic_inc_unchecked(&qps_created);
37495 switch (init_attr->qp_type) {
37496 case IB_QPT_RC:
37497 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37498 @@ -1462,7 +1462,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37499 struct iw_cm_event cm_event;
37500 int ret = 0;
37501
37502 - atomic_inc(&sw_qps_destroyed);
37503 + atomic_inc_unchecked(&sw_qps_destroyed);
37504 nesqp->destroyed = 1;
37505
37506 /* Blow away the connection if it exists. */
37507 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37508 index 4d11575..3e890e5 100644
37509 --- a/drivers/infiniband/hw/qib/qib.h
37510 +++ b/drivers/infiniband/hw/qib/qib.h
37511 @@ -51,6 +51,7 @@
37512 #include <linux/completion.h>
37513 #include <linux/kref.h>
37514 #include <linux/sched.h>
37515 +#include <linux/slab.h>
37516
37517 #include "qib_common.h"
37518 #include "qib_verbs.h"
37519 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37520 index da739d9..da1c7f4 100644
37521 --- a/drivers/input/gameport/gameport.c
37522 +++ b/drivers/input/gameport/gameport.c
37523 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37524 */
37525 static void gameport_init_port(struct gameport *gameport)
37526 {
37527 - static atomic_t gameport_no = ATOMIC_INIT(0);
37528 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37529
37530 __module_get(THIS_MODULE);
37531
37532 mutex_init(&gameport->drv_mutex);
37533 device_initialize(&gameport->dev);
37534 dev_set_name(&gameport->dev, "gameport%lu",
37535 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37536 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37537 gameport->dev.bus = &gameport_bus;
37538 gameport->dev.release = gameport_release_port;
37539 if (gameport->parent)
37540 diff --git a/drivers/input/input.c b/drivers/input/input.c
37541 index c044699..174d71a 100644
37542 --- a/drivers/input/input.c
37543 +++ b/drivers/input/input.c
37544 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37545 */
37546 int input_register_device(struct input_dev *dev)
37547 {
37548 - static atomic_t input_no = ATOMIC_INIT(0);
37549 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37550 struct input_devres *devres = NULL;
37551 struct input_handler *handler;
37552 unsigned int packet_size;
37553 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37554 dev->setkeycode = input_default_setkeycode;
37555
37556 dev_set_name(&dev->dev, "input%ld",
37557 - (unsigned long) atomic_inc_return(&input_no) - 1);
37558 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37559
37560 error = device_add(&dev->dev);
37561 if (error)
37562 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37563 index 04c69af..5f92d00 100644
37564 --- a/drivers/input/joystick/sidewinder.c
37565 +++ b/drivers/input/joystick/sidewinder.c
37566 @@ -30,6 +30,7 @@
37567 #include <linux/kernel.h>
37568 #include <linux/module.h>
37569 #include <linux/slab.h>
37570 +#include <linux/sched.h>
37571 #include <linux/init.h>
37572 #include <linux/input.h>
37573 #include <linux/gameport.h>
37574 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37575 index d6cbfe9..6225402 100644
37576 --- a/drivers/input/joystick/xpad.c
37577 +++ b/drivers/input/joystick/xpad.c
37578 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37579
37580 static int xpad_led_probe(struct usb_xpad *xpad)
37581 {
37582 - static atomic_t led_seq = ATOMIC_INIT(0);
37583 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37584 long led_no;
37585 struct xpad_led *led;
37586 struct led_classdev *led_cdev;
37587 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37588 if (!led)
37589 return -ENOMEM;
37590
37591 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37592 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37593
37594 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37595 led->xpad = xpad;
37596 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37597 index fe1df23..5b710f3 100644
37598 --- a/drivers/input/mouse/psmouse.h
37599 +++ b/drivers/input/mouse/psmouse.h
37600 @@ -115,7 +115,7 @@ struct psmouse_attribute {
37601 ssize_t (*set)(struct psmouse *psmouse, void *data,
37602 const char *buf, size_t count);
37603 bool protect;
37604 -};
37605 +} __do_const;
37606 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37607
37608 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37609 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37610 index 4c842c3..590b0bf 100644
37611 --- a/drivers/input/mousedev.c
37612 +++ b/drivers/input/mousedev.c
37613 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37614
37615 spin_unlock_irq(&client->packet_lock);
37616
37617 - if (copy_to_user(buffer, data, count))
37618 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37619 return -EFAULT;
37620
37621 return count;
37622 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37623 index 25fc597..558bf3b 100644
37624 --- a/drivers/input/serio/serio.c
37625 +++ b/drivers/input/serio/serio.c
37626 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37627 */
37628 static void serio_init_port(struct serio *serio)
37629 {
37630 - static atomic_t serio_no = ATOMIC_INIT(0);
37631 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37632
37633 __module_get(THIS_MODULE);
37634
37635 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37636 mutex_init(&serio->drv_mutex);
37637 device_initialize(&serio->dev);
37638 dev_set_name(&serio->dev, "serio%ld",
37639 - (long)atomic_inc_return(&serio_no) - 1);
37640 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37641 serio->dev.bus = &serio_bus;
37642 serio->dev.release = serio_release_port;
37643 serio->dev.groups = serio_device_attr_groups;
37644 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37645 index ddbdaca..be18a78 100644
37646 --- a/drivers/iommu/iommu.c
37647 +++ b/drivers/iommu/iommu.c
37648 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37649 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37650 {
37651 bus_register_notifier(bus, &iommu_bus_nb);
37652 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37653 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37654 }
37655
37656 /**
37657 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37658 index 89562a8..218999b 100644
37659 --- a/drivers/isdn/capi/capi.c
37660 +++ b/drivers/isdn/capi/capi.c
37661 @@ -81,8 +81,8 @@ struct capiminor {
37662
37663 struct capi20_appl *ap;
37664 u32 ncci;
37665 - atomic_t datahandle;
37666 - atomic_t msgid;
37667 + atomic_unchecked_t datahandle;
37668 + atomic_unchecked_t msgid;
37669
37670 struct tty_port port;
37671 int ttyinstop;
37672 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37673 capimsg_setu16(s, 2, mp->ap->applid);
37674 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37675 capimsg_setu8 (s, 5, CAPI_RESP);
37676 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37677 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37678 capimsg_setu32(s, 8, mp->ncci);
37679 capimsg_setu16(s, 12, datahandle);
37680 }
37681 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37682 mp->outbytes -= len;
37683 spin_unlock_bh(&mp->outlock);
37684
37685 - datahandle = atomic_inc_return(&mp->datahandle);
37686 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37687 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37688 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37689 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37690 capimsg_setu16(skb->data, 2, mp->ap->applid);
37691 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37692 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37693 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37694 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37695 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37696 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37697 capimsg_setu16(skb->data, 16, len); /* Data length */
37698 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37699 index 67abf3f..076b3a6 100644
37700 --- a/drivers/isdn/gigaset/interface.c
37701 +++ b/drivers/isdn/gigaset/interface.c
37702 @@ -160,9 +160,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37703 }
37704 tty->driver_data = cs;
37705
37706 - ++cs->port.count;
37707 + atomic_inc(&cs->port.count);
37708
37709 - if (cs->port.count == 1) {
37710 + if (atomic_read(&cs->port.count) == 1) {
37711 tty_port_tty_set(&cs->port, tty);
37712 tty->low_latency = 1;
37713 }
37714 @@ -186,9 +186,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37715
37716 if (!cs->connected)
37717 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37718 - else if (!cs->port.count)
37719 + else if (!atomic_read(&cs->port.count))
37720 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37721 - else if (!--cs->port.count)
37722 + else if (!atomic_dec_return(&cs->port.count))
37723 tty_port_tty_set(&cs->port, NULL);
37724
37725 mutex_unlock(&cs->mutex);
37726 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37727 index 821f7ac..28d4030 100644
37728 --- a/drivers/isdn/hardware/avm/b1.c
37729 +++ b/drivers/isdn/hardware/avm/b1.c
37730 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37731 }
37732 if (left) {
37733 if (t4file->user) {
37734 - if (copy_from_user(buf, dp, left))
37735 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37736 return -EFAULT;
37737 } else {
37738 memcpy(buf, dp, left);
37739 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37740 }
37741 if (left) {
37742 if (config->user) {
37743 - if (copy_from_user(buf, dp, left))
37744 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37745 return -EFAULT;
37746 } else {
37747 memcpy(buf, dp, left);
37748 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37749 index e09dc8a..15e2efb 100644
37750 --- a/drivers/isdn/i4l/isdn_tty.c
37751 +++ b/drivers/isdn/i4l/isdn_tty.c
37752 @@ -1513,9 +1513,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37753
37754 #ifdef ISDN_DEBUG_MODEM_OPEN
37755 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37756 - port->count);
37757 + atomic_read(&port->count));
37758 #endif
37759 - port->count++;
37760 + atomic_inc(&port->count);
37761 port->tty = tty;
37762 /*
37763 * Start up serial port
37764 @@ -1559,7 +1559,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37765 #endif
37766 return;
37767 }
37768 - if ((tty->count == 1) && (port->count != 1)) {
37769 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37770 /*
37771 * Uh, oh. tty->count is 1, which means that the tty
37772 * structure will be freed. Info->count should always
37773 @@ -1568,15 +1568,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37774 * serial port won't be shutdown.
37775 */
37776 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37777 - "info->count is %d\n", port->count);
37778 - port->count = 1;
37779 + "info->count is %d\n", atomic_read(&port->count));
37780 + atomic_set(&port->count, 1);
37781 }
37782 - if (--port->count < 0) {
37783 + if (atomic_dec_return(&port->count) < 0) {
37784 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37785 - info->line, port->count);
37786 - port->count = 0;
37787 + info->line, atomic_read(&port->count));
37788 + atomic_set(&port->count, 0);
37789 }
37790 - if (port->count) {
37791 + if (atomic_read(&port->count)) {
37792 #ifdef ISDN_DEBUG_MODEM_OPEN
37793 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37794 #endif
37795 @@ -1630,7 +1630,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37796 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37797 return;
37798 isdn_tty_shutdown(info);
37799 - port->count = 0;
37800 + atomic_set(&port->count, 0);
37801 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37802 port->tty = NULL;
37803 wake_up_interruptible(&port->open_wait);
37804 @@ -1975,7 +1975,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37805 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37806 modem_info *info = &dev->mdm.info[i];
37807
37808 - if (info->port.count == 0)
37809 + if (atomic_read(&info->port.count) == 0)
37810 continue;
37811 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37812 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37813 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37814 index e74df7c..03a03ba 100644
37815 --- a/drivers/isdn/icn/icn.c
37816 +++ b/drivers/isdn/icn/icn.c
37817 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37818 if (count > len)
37819 count = len;
37820 if (user) {
37821 - if (copy_from_user(msg, buf, count))
37822 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37823 return -EFAULT;
37824 } else
37825 memcpy(msg, buf, count);
37826 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37827 index 6a8405d..0bd1c7e 100644
37828 --- a/drivers/leds/leds-clevo-mail.c
37829 +++ b/drivers/leds/leds-clevo-mail.c
37830 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37831 * detected as working, but in reality it is not) as low as
37832 * possible.
37833 */
37834 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37835 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37836 {
37837 .callback = clevo_mail_led_dmi_callback,
37838 .ident = "Clevo D410J",
37839 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37840 index ec9b287..65c9bf4 100644
37841 --- a/drivers/leds/leds-ss4200.c
37842 +++ b/drivers/leds/leds-ss4200.c
37843 @@ -92,7 +92,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37844 * detected as working, but in reality it is not) as low as
37845 * possible.
37846 */
37847 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37848 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37849 {
37850 .callback = ss4200_led_dmi_callback,
37851 .ident = "Intel SS4200-E",
37852 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37853 index a5ebc00..982886f 100644
37854 --- a/drivers/lguest/core.c
37855 +++ b/drivers/lguest/core.c
37856 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37857 * it's worked so far. The end address needs +1 because __get_vm_area
37858 * allocates an extra guard page, so we need space for that.
37859 */
37860 +
37861 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37862 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37863 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37864 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37865 +#else
37866 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37867 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37868 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37869 +#endif
37870 +
37871 if (!switcher_vma) {
37872 err = -ENOMEM;
37873 printk("lguest: could not map switcher pages high\n");
37874 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37875 * Now the Switcher is mapped at the right address, we can't fail!
37876 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37877 */
37878 - memcpy(switcher_vma->addr, start_switcher_text,
37879 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37880 end_switcher_text - start_switcher_text);
37881
37882 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37883 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37884 index 3b62be16..e33134a 100644
37885 --- a/drivers/lguest/page_tables.c
37886 +++ b/drivers/lguest/page_tables.c
37887 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37888 /*:*/
37889
37890 #ifdef CONFIG_X86_PAE
37891 -static void release_pmd(pmd_t *spmd)
37892 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37893 {
37894 /* If the entry's not present, there's nothing to release. */
37895 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37896 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37897 index 4af12e1..0e89afe 100644
37898 --- a/drivers/lguest/x86/core.c
37899 +++ b/drivers/lguest/x86/core.c
37900 @@ -59,7 +59,7 @@ static struct {
37901 /* Offset from where switcher.S was compiled to where we've copied it */
37902 static unsigned long switcher_offset(void)
37903 {
37904 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37905 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37906 }
37907
37908 /* This cpu's struct lguest_pages. */
37909 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37910 * These copies are pretty cheap, so we do them unconditionally: */
37911 /* Save the current Host top-level page directory.
37912 */
37913 +
37914 +#ifdef CONFIG_PAX_PER_CPU_PGD
37915 + pages->state.host_cr3 = read_cr3();
37916 +#else
37917 pages->state.host_cr3 = __pa(current->mm->pgd);
37918 +#endif
37919 +
37920 /*
37921 * Set up the Guest's page tables to see this CPU's pages (and no
37922 * other CPU's pages).
37923 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37924 * compiled-in switcher code and the high-mapped copy we just made.
37925 */
37926 for (i = 0; i < IDT_ENTRIES; i++)
37927 - default_idt_entries[i] += switcher_offset();
37928 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37929
37930 /*
37931 * Set up the Switcher's per-cpu areas.
37932 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37933 * it will be undisturbed when we switch. To change %cs and jump we
37934 * need this structure to feed to Intel's "lcall" instruction.
37935 */
37936 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37937 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37938 lguest_entry.segment = LGUEST_CS;
37939
37940 /*
37941 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
37942 index 40634b0..4f5855e 100644
37943 --- a/drivers/lguest/x86/switcher_32.S
37944 +++ b/drivers/lguest/x86/switcher_32.S
37945 @@ -87,6 +87,7 @@
37946 #include <asm/page.h>
37947 #include <asm/segment.h>
37948 #include <asm/lguest.h>
37949 +#include <asm/processor-flags.h>
37950
37951 // We mark the start of the code to copy
37952 // It's placed in .text tho it's never run here
37953 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
37954 // Changes type when we load it: damn Intel!
37955 // For after we switch over our page tables
37956 // That entry will be read-only: we'd crash.
37957 +
37958 +#ifdef CONFIG_PAX_KERNEXEC
37959 + mov %cr0, %edx
37960 + xor $X86_CR0_WP, %edx
37961 + mov %edx, %cr0
37962 +#endif
37963 +
37964 movl $(GDT_ENTRY_TSS*8), %edx
37965 ltr %dx
37966
37967 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
37968 // Let's clear it again for our return.
37969 // The GDT descriptor of the Host
37970 // Points to the table after two "size" bytes
37971 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
37972 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
37973 // Clear "used" from type field (byte 5, bit 2)
37974 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
37975 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
37976 +
37977 +#ifdef CONFIG_PAX_KERNEXEC
37978 + mov %cr0, %eax
37979 + xor $X86_CR0_WP, %eax
37980 + mov %eax, %cr0
37981 +#endif
37982
37983 // Once our page table's switched, the Guest is live!
37984 // The Host fades as we run this final step.
37985 @@ -295,13 +309,12 @@ deliver_to_host:
37986 // I consulted gcc, and it gave
37987 // These instructions, which I gladly credit:
37988 leal (%edx,%ebx,8), %eax
37989 - movzwl (%eax),%edx
37990 - movl 4(%eax), %eax
37991 - xorw %ax, %ax
37992 - orl %eax, %edx
37993 + movl 4(%eax), %edx
37994 + movw (%eax), %dx
37995 // Now the address of the handler's in %edx
37996 // We call it now: its "iret" drops us home.
37997 - jmp *%edx
37998 + ljmp $__KERNEL_CS, $1f
37999 +1: jmp *%edx
38000
38001 // Every interrupt can come to us here
38002 // But we must truly tell each apart.
38003 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38004 index 7155945..4bcc562 100644
38005 --- a/drivers/md/bitmap.c
38006 +++ b/drivers/md/bitmap.c
38007 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38008 chunk_kb ? "KB" : "B");
38009 if (bitmap->storage.file) {
38010 seq_printf(seq, ", file: ");
38011 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38012 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38013 }
38014
38015 seq_printf(seq, "\n");
38016 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38017 index eee353d..74504c4 100644
38018 --- a/drivers/md/dm-ioctl.c
38019 +++ b/drivers/md/dm-ioctl.c
38020 @@ -1632,7 +1632,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38021 cmd == DM_LIST_VERSIONS_CMD)
38022 return 0;
38023
38024 - if ((cmd == DM_DEV_CREATE_CMD)) {
38025 + if (cmd == DM_DEV_CREATE_CMD) {
38026 if (!*param->name) {
38027 DMWARN("name not supplied when creating device");
38028 return -EINVAL;
38029 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38030 index 7f24190..0e18099 100644
38031 --- a/drivers/md/dm-raid1.c
38032 +++ b/drivers/md/dm-raid1.c
38033 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38034
38035 struct mirror {
38036 struct mirror_set *ms;
38037 - atomic_t error_count;
38038 + atomic_unchecked_t error_count;
38039 unsigned long error_type;
38040 struct dm_dev *dev;
38041 sector_t offset;
38042 @@ -183,7 +183,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38043 struct mirror *m;
38044
38045 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38046 - if (!atomic_read(&m->error_count))
38047 + if (!atomic_read_unchecked(&m->error_count))
38048 return m;
38049
38050 return NULL;
38051 @@ -215,7 +215,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38052 * simple way to tell if a device has encountered
38053 * errors.
38054 */
38055 - atomic_inc(&m->error_count);
38056 + atomic_inc_unchecked(&m->error_count);
38057
38058 if (test_and_set_bit(error_type, &m->error_type))
38059 return;
38060 @@ -406,7 +406,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38061 struct mirror *m = get_default_mirror(ms);
38062
38063 do {
38064 - if (likely(!atomic_read(&m->error_count)))
38065 + if (likely(!atomic_read_unchecked(&m->error_count)))
38066 return m;
38067
38068 if (m-- == ms->mirror)
38069 @@ -420,7 +420,7 @@ static int default_ok(struct mirror *m)
38070 {
38071 struct mirror *default_mirror = get_default_mirror(m->ms);
38072
38073 - return !atomic_read(&default_mirror->error_count);
38074 + return !atomic_read_unchecked(&default_mirror->error_count);
38075 }
38076
38077 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38078 @@ -557,7 +557,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38079 */
38080 if (likely(region_in_sync(ms, region, 1)))
38081 m = choose_mirror(ms, bio->bi_sector);
38082 - else if (m && atomic_read(&m->error_count))
38083 + else if (m && atomic_read_unchecked(&m->error_count))
38084 m = NULL;
38085
38086 if (likely(m))
38087 @@ -924,7 +924,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38088 }
38089
38090 ms->mirror[mirror].ms = ms;
38091 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38092 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38093 ms->mirror[mirror].error_type = 0;
38094 ms->mirror[mirror].offset = offset;
38095
38096 @@ -1337,7 +1337,7 @@ static void mirror_resume(struct dm_target *ti)
38097 */
38098 static char device_status_char(struct mirror *m)
38099 {
38100 - if (!atomic_read(&(m->error_count)))
38101 + if (!atomic_read_unchecked(&(m->error_count)))
38102 return 'A';
38103
38104 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38105 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38106 index aaecefa..23b3026 100644
38107 --- a/drivers/md/dm-stripe.c
38108 +++ b/drivers/md/dm-stripe.c
38109 @@ -20,7 +20,7 @@ struct stripe {
38110 struct dm_dev *dev;
38111 sector_t physical_start;
38112
38113 - atomic_t error_count;
38114 + atomic_unchecked_t error_count;
38115 };
38116
38117 struct stripe_c {
38118 @@ -184,7 +184,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38119 kfree(sc);
38120 return r;
38121 }
38122 - atomic_set(&(sc->stripe[i].error_count), 0);
38123 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38124 }
38125
38126 ti->private = sc;
38127 @@ -325,7 +325,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38128 DMEMIT("%d ", sc->stripes);
38129 for (i = 0; i < sc->stripes; i++) {
38130 DMEMIT("%s ", sc->stripe[i].dev->name);
38131 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38132 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38133 'D' : 'A';
38134 }
38135 buffer[i] = '\0';
38136 @@ -370,8 +370,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38137 */
38138 for (i = 0; i < sc->stripes; i++)
38139 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38140 - atomic_inc(&(sc->stripe[i].error_count));
38141 - if (atomic_read(&(sc->stripe[i].error_count)) <
38142 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38143 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38144 DM_IO_ERROR_THRESHOLD)
38145 schedule_work(&sc->trigger_event);
38146 }
38147 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38148 index daf25d0..d74f49f 100644
38149 --- a/drivers/md/dm-table.c
38150 +++ b/drivers/md/dm-table.c
38151 @@ -390,7 +390,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38152 if (!dev_size)
38153 return 0;
38154
38155 - if ((start >= dev_size) || (start + len > dev_size)) {
38156 + if ((start >= dev_size) || (len > dev_size - start)) {
38157 DMWARN("%s: %s too small for target: "
38158 "start=%llu, len=%llu, dev_size=%llu",
38159 dm_device_name(ti->table->md), bdevname(bdev, b),
38160 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38161 index 4d6e853..a234157 100644
38162 --- a/drivers/md/dm-thin-metadata.c
38163 +++ b/drivers/md/dm-thin-metadata.c
38164 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38165 {
38166 pmd->info.tm = pmd->tm;
38167 pmd->info.levels = 2;
38168 - pmd->info.value_type.context = pmd->data_sm;
38169 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38170 pmd->info.value_type.size = sizeof(__le64);
38171 pmd->info.value_type.inc = data_block_inc;
38172 pmd->info.value_type.dec = data_block_dec;
38173 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38174
38175 pmd->bl_info.tm = pmd->tm;
38176 pmd->bl_info.levels = 1;
38177 - pmd->bl_info.value_type.context = pmd->data_sm;
38178 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38179 pmd->bl_info.value_type.size = sizeof(__le64);
38180 pmd->bl_info.value_type.inc = data_block_inc;
38181 pmd->bl_info.value_type.dec = data_block_dec;
38182 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38183 index 0d8f086..f5a91d5 100644
38184 --- a/drivers/md/dm.c
38185 +++ b/drivers/md/dm.c
38186 @@ -170,9 +170,9 @@ struct mapped_device {
38187 /*
38188 * Event handling.
38189 */
38190 - atomic_t event_nr;
38191 + atomic_unchecked_t event_nr;
38192 wait_queue_head_t eventq;
38193 - atomic_t uevent_seq;
38194 + atomic_unchecked_t uevent_seq;
38195 struct list_head uevent_list;
38196 spinlock_t uevent_lock; /* Protect access to uevent_list */
38197
38198 @@ -1872,8 +1872,8 @@ static struct mapped_device *alloc_dev(int minor)
38199 rwlock_init(&md->map_lock);
38200 atomic_set(&md->holders, 1);
38201 atomic_set(&md->open_count, 0);
38202 - atomic_set(&md->event_nr, 0);
38203 - atomic_set(&md->uevent_seq, 0);
38204 + atomic_set_unchecked(&md->event_nr, 0);
38205 + atomic_set_unchecked(&md->uevent_seq, 0);
38206 INIT_LIST_HEAD(&md->uevent_list);
38207 spin_lock_init(&md->uevent_lock);
38208
38209 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
38210
38211 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38212
38213 - atomic_inc(&md->event_nr);
38214 + atomic_inc_unchecked(&md->event_nr);
38215 wake_up(&md->eventq);
38216 }
38217
38218 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38219
38220 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38221 {
38222 - return atomic_add_return(1, &md->uevent_seq);
38223 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38224 }
38225
38226 uint32_t dm_get_event_nr(struct mapped_device *md)
38227 {
38228 - return atomic_read(&md->event_nr);
38229 + return atomic_read_unchecked(&md->event_nr);
38230 }
38231
38232 int dm_wait_event(struct mapped_device *md, int event_nr)
38233 {
38234 return wait_event_interruptible(md->eventq,
38235 - (event_nr != atomic_read(&md->event_nr)));
38236 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38237 }
38238
38239 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38240 diff --git a/drivers/md/md.c b/drivers/md/md.c
38241 index f363135..9b38815 100644
38242 --- a/drivers/md/md.c
38243 +++ b/drivers/md/md.c
38244 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38245 * start build, activate spare
38246 */
38247 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38248 -static atomic_t md_event_count;
38249 +static atomic_unchecked_t md_event_count;
38250 void md_new_event(struct mddev *mddev)
38251 {
38252 - atomic_inc(&md_event_count);
38253 + atomic_inc_unchecked(&md_event_count);
38254 wake_up(&md_event_waiters);
38255 }
38256 EXPORT_SYMBOL_GPL(md_new_event);
38257 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38258 */
38259 static void md_new_event_inintr(struct mddev *mddev)
38260 {
38261 - atomic_inc(&md_event_count);
38262 + atomic_inc_unchecked(&md_event_count);
38263 wake_up(&md_event_waiters);
38264 }
38265
38266 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38267 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38268 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38269 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38270 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38271 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38272
38273 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38274 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38275 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38276 else
38277 sb->resync_offset = cpu_to_le64(0);
38278
38279 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38280 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38281
38282 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38283 sb->size = cpu_to_le64(mddev->dev_sectors);
38284 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38285 static ssize_t
38286 errors_show(struct md_rdev *rdev, char *page)
38287 {
38288 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38289 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38290 }
38291
38292 static ssize_t
38293 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38294 char *e;
38295 unsigned long n = simple_strtoul(buf, &e, 10);
38296 if (*buf && (*e == 0 || *e == '\n')) {
38297 - atomic_set(&rdev->corrected_errors, n);
38298 + atomic_set_unchecked(&rdev->corrected_errors, n);
38299 return len;
38300 }
38301 return -EINVAL;
38302 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38303 rdev->sb_loaded = 0;
38304 rdev->bb_page = NULL;
38305 atomic_set(&rdev->nr_pending, 0);
38306 - atomic_set(&rdev->read_errors, 0);
38307 - atomic_set(&rdev->corrected_errors, 0);
38308 + atomic_set_unchecked(&rdev->read_errors, 0);
38309 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38310
38311 INIT_LIST_HEAD(&rdev->same_set);
38312 init_waitqueue_head(&rdev->blocked_wait);
38313 @@ -6987,7 +6987,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38314
38315 spin_unlock(&pers_lock);
38316 seq_printf(seq, "\n");
38317 - seq->poll_event = atomic_read(&md_event_count);
38318 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38319 return 0;
38320 }
38321 if (v == (void*)2) {
38322 @@ -7090,7 +7090,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38323 return error;
38324
38325 seq = file->private_data;
38326 - seq->poll_event = atomic_read(&md_event_count);
38327 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38328 return error;
38329 }
38330
38331 @@ -7104,7 +7104,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38332 /* always allow read */
38333 mask = POLLIN | POLLRDNORM;
38334
38335 - if (seq->poll_event != atomic_read(&md_event_count))
38336 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38337 mask |= POLLERR | POLLPRI;
38338 return mask;
38339 }
38340 @@ -7148,7 +7148,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38341 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38342 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38343 (int)part_stat_read(&disk->part0, sectors[1]) -
38344 - atomic_read(&disk->sync_io);
38345 + atomic_read_unchecked(&disk->sync_io);
38346 /* sync IO will cause sync_io to increase before the disk_stats
38347 * as sync_io is counted when a request starts, and
38348 * disk_stats is counted when it completes.
38349 diff --git a/drivers/md/md.h b/drivers/md/md.h
38350 index eca59c3..7c42285 100644
38351 --- a/drivers/md/md.h
38352 +++ b/drivers/md/md.h
38353 @@ -94,13 +94,13 @@ struct md_rdev {
38354 * only maintained for arrays that
38355 * support hot removal
38356 */
38357 - atomic_t read_errors; /* number of consecutive read errors that
38358 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38359 * we have tried to ignore.
38360 */
38361 struct timespec last_read_error; /* monotonic time since our
38362 * last read error
38363 */
38364 - atomic_t corrected_errors; /* number of corrected read errors,
38365 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38366 * for reporting to userspace and storing
38367 * in superblock.
38368 */
38369 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38370
38371 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38372 {
38373 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38374 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38375 }
38376
38377 struct md_personality
38378 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38379 index 1cbfc6b..56e1dbb 100644
38380 --- a/drivers/md/persistent-data/dm-space-map.h
38381 +++ b/drivers/md/persistent-data/dm-space-map.h
38382 @@ -60,6 +60,7 @@ struct dm_space_map {
38383 int (*root_size)(struct dm_space_map *sm, size_t *result);
38384 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38385 };
38386 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38387
38388 /*----------------------------------------------------------------*/
38389
38390 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38391 index 75b1f89..00ba344 100644
38392 --- a/drivers/md/raid1.c
38393 +++ b/drivers/md/raid1.c
38394 @@ -1819,7 +1819,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38395 if (r1_sync_page_io(rdev, sect, s,
38396 bio->bi_io_vec[idx].bv_page,
38397 READ) != 0)
38398 - atomic_add(s, &rdev->corrected_errors);
38399 + atomic_add_unchecked(s, &rdev->corrected_errors);
38400 }
38401 sectors -= s;
38402 sect += s;
38403 @@ -2041,7 +2041,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38404 test_bit(In_sync, &rdev->flags)) {
38405 if (r1_sync_page_io(rdev, sect, s,
38406 conf->tmppage, READ)) {
38407 - atomic_add(s, &rdev->corrected_errors);
38408 + atomic_add_unchecked(s, &rdev->corrected_errors);
38409 printk(KERN_INFO
38410 "md/raid1:%s: read error corrected "
38411 "(%d sectors at %llu on %s)\n",
38412 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38413 index 8d925dc..11d674f 100644
38414 --- a/drivers/md/raid10.c
38415 +++ b/drivers/md/raid10.c
38416 @@ -1878,7 +1878,7 @@ static void end_sync_read(struct bio *bio, int error)
38417 /* The write handler will notice the lack of
38418 * R10BIO_Uptodate and record any errors etc
38419 */
38420 - atomic_add(r10_bio->sectors,
38421 + atomic_add_unchecked(r10_bio->sectors,
38422 &conf->mirrors[d].rdev->corrected_errors);
38423
38424 /* for reconstruct, we always reschedule after a read.
38425 @@ -2227,7 +2227,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38426 {
38427 struct timespec cur_time_mon;
38428 unsigned long hours_since_last;
38429 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38430 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38431
38432 ktime_get_ts(&cur_time_mon);
38433
38434 @@ -2249,9 +2249,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38435 * overflowing the shift of read_errors by hours_since_last.
38436 */
38437 if (hours_since_last >= 8 * sizeof(read_errors))
38438 - atomic_set(&rdev->read_errors, 0);
38439 + atomic_set_unchecked(&rdev->read_errors, 0);
38440 else
38441 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38442 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38443 }
38444
38445 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38446 @@ -2305,8 +2305,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38447 return;
38448
38449 check_decay_read_errors(mddev, rdev);
38450 - atomic_inc(&rdev->read_errors);
38451 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38452 + atomic_inc_unchecked(&rdev->read_errors);
38453 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38454 char b[BDEVNAME_SIZE];
38455 bdevname(rdev->bdev, b);
38456
38457 @@ -2314,7 +2314,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38458 "md/raid10:%s: %s: Raid device exceeded "
38459 "read_error threshold [cur %d:max %d]\n",
38460 mdname(mddev), b,
38461 - atomic_read(&rdev->read_errors), max_read_errors);
38462 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38463 printk(KERN_NOTICE
38464 "md/raid10:%s: %s: Failing raid device\n",
38465 mdname(mddev), b);
38466 @@ -2469,7 +2469,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38467 sect +
38468 choose_data_offset(r10_bio, rdev)),
38469 bdevname(rdev->bdev, b));
38470 - atomic_add(s, &rdev->corrected_errors);
38471 + atomic_add_unchecked(s, &rdev->corrected_errors);
38472 }
38473
38474 rdev_dec_pending(rdev, mddev);
38475 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38476 index 94ce78e..df99e24 100644
38477 --- a/drivers/md/raid5.c
38478 +++ b/drivers/md/raid5.c
38479 @@ -1800,21 +1800,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38480 mdname(conf->mddev), STRIPE_SECTORS,
38481 (unsigned long long)s,
38482 bdevname(rdev->bdev, b));
38483 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38484 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38485 clear_bit(R5_ReadError, &sh->dev[i].flags);
38486 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38487 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38488 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38489
38490 - if (atomic_read(&rdev->read_errors))
38491 - atomic_set(&rdev->read_errors, 0);
38492 + if (atomic_read_unchecked(&rdev->read_errors))
38493 + atomic_set_unchecked(&rdev->read_errors, 0);
38494 } else {
38495 const char *bdn = bdevname(rdev->bdev, b);
38496 int retry = 0;
38497 int set_bad = 0;
38498
38499 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38500 - atomic_inc(&rdev->read_errors);
38501 + atomic_inc_unchecked(&rdev->read_errors);
38502 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38503 printk_ratelimited(
38504 KERN_WARNING
38505 @@ -1842,7 +1842,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38506 mdname(conf->mddev),
38507 (unsigned long long)s,
38508 bdn);
38509 - } else if (atomic_read(&rdev->read_errors)
38510 + } else if (atomic_read_unchecked(&rdev->read_errors)
38511 > conf->max_nr_stripes)
38512 printk(KERN_WARNING
38513 "md/raid:%s: Too many read errors, failing device %s.\n",
38514 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38515 index d33101a..6b13069 100644
38516 --- a/drivers/media/dvb-core/dvbdev.c
38517 +++ b/drivers/media/dvb-core/dvbdev.c
38518 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38519 const struct dvb_device *template, void *priv, int type)
38520 {
38521 struct dvb_device *dvbdev;
38522 - struct file_operations *dvbdevfops;
38523 + file_operations_no_const *dvbdevfops;
38524 struct device *clsdev;
38525 int minor;
38526 int id;
38527 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38528 index 404f63a..4796533 100644
38529 --- a/drivers/media/dvb-frontends/dib3000.h
38530 +++ b/drivers/media/dvb-frontends/dib3000.h
38531 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38532 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38533 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38534 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38535 -};
38536 +} __no_const;
38537
38538 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
38539 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38540 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38541 index bc78354..42c9459 100644
38542 --- a/drivers/media/pci/cx88/cx88-video.c
38543 +++ b/drivers/media/pci/cx88/cx88-video.c
38544 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38545
38546 /* ------------------------------------------------------------------ */
38547
38548 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38549 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38550 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38551 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38552 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38553 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38554
38555 module_param_array(video_nr, int, NULL, 0444);
38556 module_param_array(vbi_nr, int, NULL, 0444);
38557 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38558 index 8e9a668..78d6310 100644
38559 --- a/drivers/media/platform/omap/omap_vout.c
38560 +++ b/drivers/media/platform/omap/omap_vout.c
38561 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38562 OMAP_VIDEO2,
38563 };
38564
38565 -static struct videobuf_queue_ops video_vbq_ops;
38566 /* Variables configurable through module params*/
38567 static u32 video1_numbuffers = 3;
38568 static u32 video2_numbuffers = 3;
38569 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38570 {
38571 struct videobuf_queue *q;
38572 struct omap_vout_device *vout = NULL;
38573 + static struct videobuf_queue_ops video_vbq_ops = {
38574 + .buf_setup = omap_vout_buffer_setup,
38575 + .buf_prepare = omap_vout_buffer_prepare,
38576 + .buf_release = omap_vout_buffer_release,
38577 + .buf_queue = omap_vout_buffer_queue,
38578 + };
38579
38580 vout = video_drvdata(file);
38581 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38582 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38583 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38584
38585 q = &vout->vbq;
38586 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38587 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38588 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38589 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38590 spin_lock_init(&vout->vbq_lock);
38591
38592 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38593 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38594 index b671e20..34088b7 100644
38595 --- a/drivers/media/platform/s5p-tv/mixer.h
38596 +++ b/drivers/media/platform/s5p-tv/mixer.h
38597 @@ -155,7 +155,7 @@ struct mxr_layer {
38598 /** layer index (unique identifier) */
38599 int idx;
38600 /** callbacks for layer methods */
38601 - struct mxr_layer_ops ops;
38602 + struct mxr_layer_ops *ops;
38603 /** format array */
38604 const struct mxr_format **fmt_array;
38605 /** size of format array */
38606 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38607 index b93a21f..2535195 100644
38608 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38609 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38610 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38611 {
38612 struct mxr_layer *layer;
38613 int ret;
38614 - struct mxr_layer_ops ops = {
38615 + static struct mxr_layer_ops ops = {
38616 .release = mxr_graph_layer_release,
38617 .buffer_set = mxr_graph_buffer_set,
38618 .stream_set = mxr_graph_stream_set,
38619 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38620 index 3b1670a..595c939 100644
38621 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38622 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38623 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38624 layer->update_buf = next;
38625 }
38626
38627 - layer->ops.buffer_set(layer, layer->update_buf);
38628 + layer->ops->buffer_set(layer, layer->update_buf);
38629
38630 if (done && done != layer->shadow_buf)
38631 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38632 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38633 index 1f3b743..e839271 100644
38634 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38635 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38636 @@ -208,7 +208,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38637 layer->geo.src.height = layer->geo.src.full_height;
38638
38639 mxr_geometry_dump(mdev, &layer->geo);
38640 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38641 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38642 mxr_geometry_dump(mdev, &layer->geo);
38643 }
38644
38645 @@ -226,7 +226,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38646 layer->geo.dst.full_width = mbus_fmt.width;
38647 layer->geo.dst.full_height = mbus_fmt.height;
38648 layer->geo.dst.field = mbus_fmt.field;
38649 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38650 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38651
38652 mxr_geometry_dump(mdev, &layer->geo);
38653 }
38654 @@ -332,7 +332,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38655 /* set source size to highest accepted value */
38656 geo->src.full_width = max(geo->dst.full_width, pix->width);
38657 geo->src.full_height = max(geo->dst.full_height, pix->height);
38658 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38659 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38660 mxr_geometry_dump(mdev, &layer->geo);
38661 /* set cropping to total visible screen */
38662 geo->src.width = pix->width;
38663 @@ -340,12 +340,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38664 geo->src.x_offset = 0;
38665 geo->src.y_offset = 0;
38666 /* assure consistency of geometry */
38667 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38668 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38669 mxr_geometry_dump(mdev, &layer->geo);
38670 /* set full size to lowest possible value */
38671 geo->src.full_width = 0;
38672 geo->src.full_height = 0;
38673 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38674 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38675 mxr_geometry_dump(mdev, &layer->geo);
38676
38677 /* returning results */
38678 @@ -472,7 +472,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38679 target->width = s->r.width;
38680 target->height = s->r.height;
38681
38682 - layer->ops.fix_geometry(layer, stage, s->flags);
38683 + layer->ops->fix_geometry(layer, stage, s->flags);
38684
38685 /* retrieve update selection rectangle */
38686 res.left = target->x_offset;
38687 @@ -937,13 +937,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38688 mxr_output_get(mdev);
38689
38690 mxr_layer_update_output(layer);
38691 - layer->ops.format_set(layer);
38692 + layer->ops->format_set(layer);
38693 /* enabling layer in hardware */
38694 spin_lock_irqsave(&layer->enq_slock, flags);
38695 layer->state = MXR_LAYER_STREAMING;
38696 spin_unlock_irqrestore(&layer->enq_slock, flags);
38697
38698 - layer->ops.stream_set(layer, MXR_ENABLE);
38699 + layer->ops->stream_set(layer, MXR_ENABLE);
38700 mxr_streamer_get(mdev);
38701
38702 return 0;
38703 @@ -1013,7 +1013,7 @@ static int stop_streaming(struct vb2_queue *vq)
38704 spin_unlock_irqrestore(&layer->enq_slock, flags);
38705
38706 /* disabling layer in hardware */
38707 - layer->ops.stream_set(layer, MXR_DISABLE);
38708 + layer->ops->stream_set(layer, MXR_DISABLE);
38709 /* remove one streamer */
38710 mxr_streamer_put(mdev);
38711 /* allow changes in output configuration */
38712 @@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38713
38714 void mxr_layer_release(struct mxr_layer *layer)
38715 {
38716 - if (layer->ops.release)
38717 - layer->ops.release(layer);
38718 + if (layer->ops->release)
38719 + layer->ops->release(layer);
38720 }
38721
38722 void mxr_base_layer_release(struct mxr_layer *layer)
38723 @@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38724
38725 layer->mdev = mdev;
38726 layer->idx = idx;
38727 - layer->ops = *ops;
38728 + layer->ops = ops;
38729
38730 spin_lock_init(&layer->enq_slock);
38731 INIT_LIST_HEAD(&layer->enq_list);
38732 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38733 index 3d13a63..da31bf1 100644
38734 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38735 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38736 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38737 {
38738 struct mxr_layer *layer;
38739 int ret;
38740 - struct mxr_layer_ops ops = {
38741 + static struct mxr_layer_ops ops = {
38742 .release = mxr_vp_layer_release,
38743 .buffer_set = mxr_vp_buffer_set,
38744 .stream_set = mxr_vp_stream_set,
38745 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38746 index 643d80a..56bb96b 100644
38747 --- a/drivers/media/radio/radio-cadet.c
38748 +++ b/drivers/media/radio/radio-cadet.c
38749 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38750 unsigned char readbuf[RDS_BUFFER];
38751 int i = 0;
38752
38753 + if (count > RDS_BUFFER)
38754 + return -EFAULT;
38755 mutex_lock(&dev->lock);
38756 if (dev->rdsstat == 0)
38757 cadet_start_rds(dev);
38758 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38759 while (i < count && dev->rdsin != dev->rdsout)
38760 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38761
38762 - if (i && copy_to_user(data, readbuf, i))
38763 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38764 i = -EFAULT;
38765 unlock:
38766 mutex_unlock(&dev->lock);
38767 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38768 index 3940bb0..fb3952a 100644
38769 --- a/drivers/media/usb/dvb-usb/cxusb.c
38770 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38771 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38772
38773 struct dib0700_adapter_state {
38774 int (*set_param_save) (struct dvb_frontend *);
38775 -};
38776 +} __no_const;
38777
38778 static int dib7070_set_param_override(struct dvb_frontend *fe)
38779 {
38780 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38781 index 9382895..ac8093c 100644
38782 --- a/drivers/media/usb/dvb-usb/dw2102.c
38783 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38784 @@ -95,7 +95,7 @@ struct su3000_state {
38785
38786 struct s6x0_state {
38787 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38788 -};
38789 +} __no_const;
38790
38791 /* debug */
38792 static int dvb_usb_dw2102_debug;
38793 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38794 index aa6e7c7..4cd8061 100644
38795 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38796 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38797 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
38798 struct file *file, void *fh, void *p);
38799 } u;
38800 void (*debug)(const void *arg, bool write_only);
38801 -};
38802 +} __do_const;
38803 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38804
38805 /* This control needs a priority check */
38806 #define INFO_FL_PRIO (1 << 0)
38807 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
38808 struct video_device *vfd = video_devdata(file);
38809 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38810 bool write_only = false;
38811 - struct v4l2_ioctl_info default_info;
38812 + v4l2_ioctl_info_no_const default_info;
38813 const struct v4l2_ioctl_info *info;
38814 void *fh = file->private_data;
38815 struct v4l2_fh *vfh = NULL;
38816 diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
38817 index 29b2172..a7c5b31 100644
38818 --- a/drivers/memstick/host/r592.c
38819 +++ b/drivers/memstick/host/r592.c
38820 @@ -454,7 +454,7 @@ static int r592_transfer_fifo_pio(struct r592_device *dev)
38821 /* Executes one TPC (data is read/written from small or large fifo) */
38822 static void r592_execute_tpc(struct r592_device *dev)
38823 {
38824 - bool is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38825 + bool is_write;
38826 int len, error;
38827 u32 status, reg;
38828
38829 @@ -463,6 +463,7 @@ static void r592_execute_tpc(struct r592_device *dev)
38830 return;
38831 }
38832
38833 + is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38834 len = dev->req->long_data ?
38835 dev->req->sg.length : dev->req->data_len;
38836
38837 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38838 index fb69baa..3aeea2e 100644
38839 --- a/drivers/message/fusion/mptbase.c
38840 +++ b/drivers/message/fusion/mptbase.c
38841 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38842 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38843 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38844
38845 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38846 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38847 +#else
38848 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38849 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38850 +#endif
38851 +
38852 /*
38853 * Rounding UP to nearest 4-kB boundary here...
38854 */
38855 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38856 ioc->facts.GlobalCredits);
38857
38858 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38859 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38860 + NULL, NULL);
38861 +#else
38862 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38863 +#endif
38864 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38865 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38866 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38867 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38868 index fa43c39..daeb158 100644
38869 --- a/drivers/message/fusion/mptsas.c
38870 +++ b/drivers/message/fusion/mptsas.c
38871 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38872 return 0;
38873 }
38874
38875 +static inline void
38876 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38877 +{
38878 + if (phy_info->port_details) {
38879 + phy_info->port_details->rphy = rphy;
38880 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38881 + ioc->name, rphy));
38882 + }
38883 +
38884 + if (rphy) {
38885 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38886 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38887 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38888 + ioc->name, rphy, rphy->dev.release));
38889 + }
38890 +}
38891 +
38892 /* no mutex */
38893 static void
38894 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38895 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38896 return NULL;
38897 }
38898
38899 -static inline void
38900 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38901 -{
38902 - if (phy_info->port_details) {
38903 - phy_info->port_details->rphy = rphy;
38904 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38905 - ioc->name, rphy));
38906 - }
38907 -
38908 - if (rphy) {
38909 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38910 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38911 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38912 - ioc->name, rphy, rphy->dev.release));
38913 - }
38914 -}
38915 -
38916 static inline struct sas_port *
38917 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38918 {
38919 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38920 index 164afa7..b6b2e74 100644
38921 --- a/drivers/message/fusion/mptscsih.c
38922 +++ b/drivers/message/fusion/mptscsih.c
38923 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38924
38925 h = shost_priv(SChost);
38926
38927 - if (h) {
38928 - if (h->info_kbuf == NULL)
38929 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38930 - return h->info_kbuf;
38931 - h->info_kbuf[0] = '\0';
38932 + if (!h)
38933 + return NULL;
38934
38935 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38936 - h->info_kbuf[size-1] = '\0';
38937 - }
38938 + if (h->info_kbuf == NULL)
38939 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38940 + return h->info_kbuf;
38941 + h->info_kbuf[0] = '\0';
38942 +
38943 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38944 + h->info_kbuf[size-1] = '\0';
38945
38946 return h->info_kbuf;
38947 }
38948 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
38949 index 8001aa6..b137580 100644
38950 --- a/drivers/message/i2o/i2o_proc.c
38951 +++ b/drivers/message/i2o/i2o_proc.c
38952 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
38953 "Array Controller Device"
38954 };
38955
38956 -static char *chtostr(char *tmp, u8 *chars, int n)
38957 -{
38958 - tmp[0] = 0;
38959 - return strncat(tmp, (char *)chars, n);
38960 -}
38961 -
38962 static int i2o_report_query_status(struct seq_file *seq, int block_status,
38963 char *group)
38964 {
38965 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38966 } *result;
38967
38968 i2o_exec_execute_ddm_table ddm_table;
38969 - char tmp[28 + 1];
38970
38971 result = kmalloc(sizeof(*result), GFP_KERNEL);
38972 if (!result)
38973 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
38974
38975 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
38976 seq_printf(seq, "%-#8x", ddm_table.module_id);
38977 - seq_printf(seq, "%-29s",
38978 - chtostr(tmp, ddm_table.module_name_version, 28));
38979 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
38980 seq_printf(seq, "%9d ", ddm_table.data_size);
38981 seq_printf(seq, "%8d", ddm_table.code_size);
38982
38983 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38984
38985 i2o_driver_result_table *result;
38986 i2o_driver_store_table *dst;
38987 - char tmp[28 + 1];
38988
38989 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
38990 if (result == NULL)
38991 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
38992
38993 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
38994 seq_printf(seq, "%-#8x", dst->module_id);
38995 - seq_printf(seq, "%-29s",
38996 - chtostr(tmp, dst->module_name_version, 28));
38997 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
38998 + seq_printf(seq, "%-.28s", dst->module_name_version);
38999 + seq_printf(seq, "%-.8s", dst->date);
39000 seq_printf(seq, "%8d ", dst->module_size);
39001 seq_printf(seq, "%8d ", dst->mpb_size);
39002 seq_printf(seq, "0x%04x", dst->module_flags);
39003 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39004 // == (allow) 512d bytes (max)
39005 static u16 *work16 = (u16 *) work32;
39006 int token;
39007 - char tmp[16 + 1];
39008
39009 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39010
39011 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39012 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39013 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39014 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39015 - seq_printf(seq, "Vendor info : %s\n",
39016 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39017 - seq_printf(seq, "Product info : %s\n",
39018 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39019 - seq_printf(seq, "Description : %s\n",
39020 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39021 - seq_printf(seq, "Product rev. : %s\n",
39022 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39023 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39024 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39025 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39026 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39027
39028 seq_printf(seq, "Serial number : ");
39029 print_serial_number(seq, (u8 *) (work32 + 16),
39030 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39031 u8 pad[256]; // allow up to 256 byte (max) serial number
39032 } result;
39033
39034 - char tmp[24 + 1];
39035 -
39036 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39037
39038 if (token < 0) {
39039 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39040 }
39041
39042 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39043 - seq_printf(seq, "Module name : %s\n",
39044 - chtostr(tmp, result.module_name, 24));
39045 - seq_printf(seq, "Module revision : %s\n",
39046 - chtostr(tmp, result.module_rev, 8));
39047 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39048 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39049
39050 seq_printf(seq, "Serial number : ");
39051 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39052 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39053 u8 instance_number[4];
39054 } result;
39055
39056 - char tmp[64 + 1];
39057 -
39058 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39059
39060 if (token < 0) {
39061 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39062 return 0;
39063 }
39064
39065 - seq_printf(seq, "Device name : %s\n",
39066 - chtostr(tmp, result.device_name, 64));
39067 - seq_printf(seq, "Service name : %s\n",
39068 - chtostr(tmp, result.service_name, 64));
39069 - seq_printf(seq, "Physical name : %s\n",
39070 - chtostr(tmp, result.physical_location, 64));
39071 - seq_printf(seq, "Instance number : %s\n",
39072 - chtostr(tmp, result.instance_number, 4));
39073 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39074 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39075 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39076 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39077
39078 return 0;
39079 }
39080 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39081 index a8c08f3..155fe3d 100644
39082 --- a/drivers/message/i2o/iop.c
39083 +++ b/drivers/message/i2o/iop.c
39084 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39085
39086 spin_lock_irqsave(&c->context_list_lock, flags);
39087
39088 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39089 - atomic_inc(&c->context_list_counter);
39090 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39091 + atomic_inc_unchecked(&c->context_list_counter);
39092
39093 - entry->context = atomic_read(&c->context_list_counter);
39094 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39095
39096 list_add(&entry->list, &c->context_list);
39097
39098 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39099
39100 #if BITS_PER_LONG == 64
39101 spin_lock_init(&c->context_list_lock);
39102 - atomic_set(&c->context_list_counter, 0);
39103 + atomic_set_unchecked(&c->context_list_counter, 0);
39104 INIT_LIST_HEAD(&c->context_list);
39105 #endif
39106
39107 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39108 index 45ece11..8efa218 100644
39109 --- a/drivers/mfd/janz-cmodio.c
39110 +++ b/drivers/mfd/janz-cmodio.c
39111 @@ -13,6 +13,7 @@
39112
39113 #include <linux/kernel.h>
39114 #include <linux/module.h>
39115 +#include <linux/slab.h>
39116 #include <linux/init.h>
39117 #include <linux/pci.h>
39118 #include <linux/interrupt.h>
39119 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39120 index a5f9888..1c0ed56 100644
39121 --- a/drivers/mfd/twl4030-irq.c
39122 +++ b/drivers/mfd/twl4030-irq.c
39123 @@ -35,6 +35,7 @@
39124 #include <linux/of.h>
39125 #include <linux/irqdomain.h>
39126 #include <linux/i2c/twl.h>
39127 +#include <asm/pgtable.h>
39128
39129 #include "twl-core.h"
39130
39131 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39132 * Install an irq handler for each of the SIH modules;
39133 * clone dummy irq_chip since PIH can't *do* anything
39134 */
39135 - twl4030_irq_chip = dummy_irq_chip;
39136 - twl4030_irq_chip.name = "twl4030";
39137 + pax_open_kernel();
39138 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39139 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39140
39141 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39142 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39143 + pax_close_kernel();
39144
39145 for (i = irq_base; i < irq_end; i++) {
39146 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39147 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39148 index 277a8db..0e0b754 100644
39149 --- a/drivers/mfd/twl6030-irq.c
39150 +++ b/drivers/mfd/twl6030-irq.c
39151 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39152 * install an irq handler for each of the modules;
39153 * clone dummy irq_chip since PIH can't *do* anything
39154 */
39155 - twl6030_irq_chip = dummy_irq_chip;
39156 - twl6030_irq_chip.name = "twl6030";
39157 - twl6030_irq_chip.irq_set_type = NULL;
39158 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39159 + pax_open_kernel();
39160 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39161 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39162 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39163 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39164 + pax_close_kernel();
39165
39166 for (i = irq_base; i < irq_end; i++) {
39167 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39168 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39169 index f428d86..274c368 100644
39170 --- a/drivers/misc/c2port/core.c
39171 +++ b/drivers/misc/c2port/core.c
39172 @@ -924,7 +924,9 @@ struct c2port_device *c2port_device_register(char *name,
39173 mutex_init(&c2dev->mutex);
39174
39175 /* Create binary file */
39176 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39177 + pax_open_kernel();
39178 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39179 + pax_close_kernel();
39180 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39181 if (unlikely(ret))
39182 goto error_device_create_bin_file;
39183 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39184 index 3aa9a96..59cf685 100644
39185 --- a/drivers/misc/kgdbts.c
39186 +++ b/drivers/misc/kgdbts.c
39187 @@ -832,7 +832,7 @@ static void run_plant_and_detach_test(int is_early)
39188 char before[BREAK_INSTR_SIZE];
39189 char after[BREAK_INSTR_SIZE];
39190
39191 - probe_kernel_read(before, (char *)kgdbts_break_test,
39192 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39193 BREAK_INSTR_SIZE);
39194 init_simple_test();
39195 ts.tst = plant_and_detach_test;
39196 @@ -840,7 +840,7 @@ static void run_plant_and_detach_test(int is_early)
39197 /* Activate test with initial breakpoint */
39198 if (!is_early)
39199 kgdb_breakpoint();
39200 - probe_kernel_read(after, (char *)kgdbts_break_test,
39201 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39202 BREAK_INSTR_SIZE);
39203 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39204 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39205 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39206 index 4a87e5c..76bdf5c 100644
39207 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39208 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39209 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39210 * the lid is closed. This leads to interrupts as soon as a little move
39211 * is done.
39212 */
39213 - atomic_inc(&lis3->count);
39214 + atomic_inc_unchecked(&lis3->count);
39215
39216 wake_up_interruptible(&lis3->misc_wait);
39217 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39218 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39219 if (lis3->pm_dev)
39220 pm_runtime_get_sync(lis3->pm_dev);
39221
39222 - atomic_set(&lis3->count, 0);
39223 + atomic_set_unchecked(&lis3->count, 0);
39224 return 0;
39225 }
39226
39227 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39228 add_wait_queue(&lis3->misc_wait, &wait);
39229 while (true) {
39230 set_current_state(TASK_INTERRUPTIBLE);
39231 - data = atomic_xchg(&lis3->count, 0);
39232 + data = atomic_xchg_unchecked(&lis3->count, 0);
39233 if (data)
39234 break;
39235
39236 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39237 struct lis3lv02d, miscdev);
39238
39239 poll_wait(file, &lis3->misc_wait, wait);
39240 - if (atomic_read(&lis3->count))
39241 + if (atomic_read_unchecked(&lis3->count))
39242 return POLLIN | POLLRDNORM;
39243 return 0;
39244 }
39245 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39246 index c439c82..1f20f57 100644
39247 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39248 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39249 @@ -297,7 +297,7 @@ struct lis3lv02d {
39250 struct input_polled_dev *idev; /* input device */
39251 struct platform_device *pdev; /* platform device */
39252 struct regulator_bulk_data regulators[2];
39253 - atomic_t count; /* interrupt count after last read */
39254 + atomic_unchecked_t count; /* interrupt count after last read */
39255 union axis_conversion ac; /* hw -> logical axis */
39256 int mapped_btns[3];
39257
39258 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39259 index 2f30bad..c4c13d0 100644
39260 --- a/drivers/misc/sgi-gru/gruhandles.c
39261 +++ b/drivers/misc/sgi-gru/gruhandles.c
39262 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39263 unsigned long nsec;
39264
39265 nsec = CLKS2NSEC(clks);
39266 - atomic_long_inc(&mcs_op_statistics[op].count);
39267 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39268 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39269 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39270 if (mcs_op_statistics[op].max < nsec)
39271 mcs_op_statistics[op].max = nsec;
39272 }
39273 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39274 index 950dbe9..eeef0f8 100644
39275 --- a/drivers/misc/sgi-gru/gruprocfs.c
39276 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39277 @@ -32,9 +32,9 @@
39278
39279 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39280
39281 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39282 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39283 {
39284 - unsigned long val = atomic_long_read(v);
39285 + unsigned long val = atomic_long_read_unchecked(v);
39286
39287 seq_printf(s, "%16lu %s\n", val, id);
39288 }
39289 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39290
39291 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39292 for (op = 0; op < mcsop_last; op++) {
39293 - count = atomic_long_read(&mcs_op_statistics[op].count);
39294 - total = atomic_long_read(&mcs_op_statistics[op].total);
39295 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39296 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39297 max = mcs_op_statistics[op].max;
39298 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39299 count ? total / count : 0, max);
39300 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39301 index 5c3ce24..4915ccb 100644
39302 --- a/drivers/misc/sgi-gru/grutables.h
39303 +++ b/drivers/misc/sgi-gru/grutables.h
39304 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39305 * GRU statistics.
39306 */
39307 struct gru_stats_s {
39308 - atomic_long_t vdata_alloc;
39309 - atomic_long_t vdata_free;
39310 - atomic_long_t gts_alloc;
39311 - atomic_long_t gts_free;
39312 - atomic_long_t gms_alloc;
39313 - atomic_long_t gms_free;
39314 - atomic_long_t gts_double_allocate;
39315 - atomic_long_t assign_context;
39316 - atomic_long_t assign_context_failed;
39317 - atomic_long_t free_context;
39318 - atomic_long_t load_user_context;
39319 - atomic_long_t load_kernel_context;
39320 - atomic_long_t lock_kernel_context;
39321 - atomic_long_t unlock_kernel_context;
39322 - atomic_long_t steal_user_context;
39323 - atomic_long_t steal_kernel_context;
39324 - atomic_long_t steal_context_failed;
39325 - atomic_long_t nopfn;
39326 - atomic_long_t asid_new;
39327 - atomic_long_t asid_next;
39328 - atomic_long_t asid_wrap;
39329 - atomic_long_t asid_reuse;
39330 - atomic_long_t intr;
39331 - atomic_long_t intr_cbr;
39332 - atomic_long_t intr_tfh;
39333 - atomic_long_t intr_spurious;
39334 - atomic_long_t intr_mm_lock_failed;
39335 - atomic_long_t call_os;
39336 - atomic_long_t call_os_wait_queue;
39337 - atomic_long_t user_flush_tlb;
39338 - atomic_long_t user_unload_context;
39339 - atomic_long_t user_exception;
39340 - atomic_long_t set_context_option;
39341 - atomic_long_t check_context_retarget_intr;
39342 - atomic_long_t check_context_unload;
39343 - atomic_long_t tlb_dropin;
39344 - atomic_long_t tlb_preload_page;
39345 - atomic_long_t tlb_dropin_fail_no_asid;
39346 - atomic_long_t tlb_dropin_fail_upm;
39347 - atomic_long_t tlb_dropin_fail_invalid;
39348 - atomic_long_t tlb_dropin_fail_range_active;
39349 - atomic_long_t tlb_dropin_fail_idle;
39350 - atomic_long_t tlb_dropin_fail_fmm;
39351 - atomic_long_t tlb_dropin_fail_no_exception;
39352 - atomic_long_t tfh_stale_on_fault;
39353 - atomic_long_t mmu_invalidate_range;
39354 - atomic_long_t mmu_invalidate_page;
39355 - atomic_long_t flush_tlb;
39356 - atomic_long_t flush_tlb_gru;
39357 - atomic_long_t flush_tlb_gru_tgh;
39358 - atomic_long_t flush_tlb_gru_zero_asid;
39359 + atomic_long_unchecked_t vdata_alloc;
39360 + atomic_long_unchecked_t vdata_free;
39361 + atomic_long_unchecked_t gts_alloc;
39362 + atomic_long_unchecked_t gts_free;
39363 + atomic_long_unchecked_t gms_alloc;
39364 + atomic_long_unchecked_t gms_free;
39365 + atomic_long_unchecked_t gts_double_allocate;
39366 + atomic_long_unchecked_t assign_context;
39367 + atomic_long_unchecked_t assign_context_failed;
39368 + atomic_long_unchecked_t free_context;
39369 + atomic_long_unchecked_t load_user_context;
39370 + atomic_long_unchecked_t load_kernel_context;
39371 + atomic_long_unchecked_t lock_kernel_context;
39372 + atomic_long_unchecked_t unlock_kernel_context;
39373 + atomic_long_unchecked_t steal_user_context;
39374 + atomic_long_unchecked_t steal_kernel_context;
39375 + atomic_long_unchecked_t steal_context_failed;
39376 + atomic_long_unchecked_t nopfn;
39377 + atomic_long_unchecked_t asid_new;
39378 + atomic_long_unchecked_t asid_next;
39379 + atomic_long_unchecked_t asid_wrap;
39380 + atomic_long_unchecked_t asid_reuse;
39381 + atomic_long_unchecked_t intr;
39382 + atomic_long_unchecked_t intr_cbr;
39383 + atomic_long_unchecked_t intr_tfh;
39384 + atomic_long_unchecked_t intr_spurious;
39385 + atomic_long_unchecked_t intr_mm_lock_failed;
39386 + atomic_long_unchecked_t call_os;
39387 + atomic_long_unchecked_t call_os_wait_queue;
39388 + atomic_long_unchecked_t user_flush_tlb;
39389 + atomic_long_unchecked_t user_unload_context;
39390 + atomic_long_unchecked_t user_exception;
39391 + atomic_long_unchecked_t set_context_option;
39392 + atomic_long_unchecked_t check_context_retarget_intr;
39393 + atomic_long_unchecked_t check_context_unload;
39394 + atomic_long_unchecked_t tlb_dropin;
39395 + atomic_long_unchecked_t tlb_preload_page;
39396 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39397 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39398 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39399 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39400 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39401 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39402 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39403 + atomic_long_unchecked_t tfh_stale_on_fault;
39404 + atomic_long_unchecked_t mmu_invalidate_range;
39405 + atomic_long_unchecked_t mmu_invalidate_page;
39406 + atomic_long_unchecked_t flush_tlb;
39407 + atomic_long_unchecked_t flush_tlb_gru;
39408 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39409 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39410
39411 - atomic_long_t copy_gpa;
39412 - atomic_long_t read_gpa;
39413 + atomic_long_unchecked_t copy_gpa;
39414 + atomic_long_unchecked_t read_gpa;
39415
39416 - atomic_long_t mesq_receive;
39417 - atomic_long_t mesq_receive_none;
39418 - atomic_long_t mesq_send;
39419 - atomic_long_t mesq_send_failed;
39420 - atomic_long_t mesq_noop;
39421 - atomic_long_t mesq_send_unexpected_error;
39422 - atomic_long_t mesq_send_lb_overflow;
39423 - atomic_long_t mesq_send_qlimit_reached;
39424 - atomic_long_t mesq_send_amo_nacked;
39425 - atomic_long_t mesq_send_put_nacked;
39426 - atomic_long_t mesq_page_overflow;
39427 - atomic_long_t mesq_qf_locked;
39428 - atomic_long_t mesq_qf_noop_not_full;
39429 - atomic_long_t mesq_qf_switch_head_failed;
39430 - atomic_long_t mesq_qf_unexpected_error;
39431 - atomic_long_t mesq_noop_unexpected_error;
39432 - atomic_long_t mesq_noop_lb_overflow;
39433 - atomic_long_t mesq_noop_qlimit_reached;
39434 - atomic_long_t mesq_noop_amo_nacked;
39435 - atomic_long_t mesq_noop_put_nacked;
39436 - atomic_long_t mesq_noop_page_overflow;
39437 + atomic_long_unchecked_t mesq_receive;
39438 + atomic_long_unchecked_t mesq_receive_none;
39439 + atomic_long_unchecked_t mesq_send;
39440 + atomic_long_unchecked_t mesq_send_failed;
39441 + atomic_long_unchecked_t mesq_noop;
39442 + atomic_long_unchecked_t mesq_send_unexpected_error;
39443 + atomic_long_unchecked_t mesq_send_lb_overflow;
39444 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39445 + atomic_long_unchecked_t mesq_send_amo_nacked;
39446 + atomic_long_unchecked_t mesq_send_put_nacked;
39447 + atomic_long_unchecked_t mesq_page_overflow;
39448 + atomic_long_unchecked_t mesq_qf_locked;
39449 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39450 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39451 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39452 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39453 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39454 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39455 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39456 + atomic_long_unchecked_t mesq_noop_put_nacked;
39457 + atomic_long_unchecked_t mesq_noop_page_overflow;
39458
39459 };
39460
39461 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39462 tghop_invalidate, mcsop_last};
39463
39464 struct mcs_op_statistic {
39465 - atomic_long_t count;
39466 - atomic_long_t total;
39467 + atomic_long_unchecked_t count;
39468 + atomic_long_unchecked_t total;
39469 unsigned long max;
39470 };
39471
39472 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39473
39474 #define STAT(id) do { \
39475 if (gru_options & OPT_STATS) \
39476 - atomic_long_inc(&gru_stats.id); \
39477 + atomic_long_inc_unchecked(&gru_stats.id); \
39478 } while (0)
39479
39480 #ifdef CONFIG_SGI_GRU_DEBUG
39481 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39482 index c862cd4..0d176fe 100644
39483 --- a/drivers/misc/sgi-xp/xp.h
39484 +++ b/drivers/misc/sgi-xp/xp.h
39485 @@ -288,7 +288,7 @@ struct xpc_interface {
39486 xpc_notify_func, void *);
39487 void (*received) (short, int, void *);
39488 enum xp_retval (*partid_to_nasids) (short, void *);
39489 -};
39490 +} __no_const;
39491
39492 extern struct xpc_interface xpc_interface;
39493
39494 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39495 index b94d5f7..7f494c5 100644
39496 --- a/drivers/misc/sgi-xp/xpc.h
39497 +++ b/drivers/misc/sgi-xp/xpc.h
39498 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39499 void (*received_payload) (struct xpc_channel *, void *);
39500 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39501 };
39502 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39503
39504 /* struct xpc_partition act_state values (for XPC HB) */
39505
39506 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39507 /* found in xpc_main.c */
39508 extern struct device *xpc_part;
39509 extern struct device *xpc_chan;
39510 -extern struct xpc_arch_operations xpc_arch_ops;
39511 +extern xpc_arch_operations_no_const xpc_arch_ops;
39512 extern int xpc_disengage_timelimit;
39513 extern int xpc_disengage_timedout;
39514 extern int xpc_activate_IRQ_rcvd;
39515 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39516 index d971817..33bdca5 100644
39517 --- a/drivers/misc/sgi-xp/xpc_main.c
39518 +++ b/drivers/misc/sgi-xp/xpc_main.c
39519 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39520 .notifier_call = xpc_system_die,
39521 };
39522
39523 -struct xpc_arch_operations xpc_arch_ops;
39524 +xpc_arch_operations_no_const xpc_arch_ops;
39525
39526 /*
39527 * Timer function to enforce the timelimit on the partition disengage.
39528 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39529
39530 if (((die_args->trapnr == X86_TRAP_MF) ||
39531 (die_args->trapnr == X86_TRAP_XF)) &&
39532 - !user_mode_vm(die_args->regs))
39533 + !user_mode(die_args->regs))
39534 xpc_die_deactivate();
39535
39536 break;
39537 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39538 index 6d8f701..35b6369 100644
39539 --- a/drivers/mmc/core/mmc_ops.c
39540 +++ b/drivers/mmc/core/mmc_ops.c
39541 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39542 void *data_buf;
39543 int is_on_stack;
39544
39545 - is_on_stack = object_is_on_stack(buf);
39546 + is_on_stack = object_starts_on_stack(buf);
39547 if (is_on_stack) {
39548 /*
39549 * dma onto stack is unsafe/nonportable, but callers to this
39550 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39551 index 53b8fd9..615b462 100644
39552 --- a/drivers/mmc/host/dw_mmc.h
39553 +++ b/drivers/mmc/host/dw_mmc.h
39554 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39555 int (*parse_dt)(struct dw_mci *host);
39556 int (*setup_bus)(struct dw_mci *host,
39557 struct device_node *slot_np, u8 bus_width);
39558 -};
39559 +} __do_const;
39560 #endif /* _DW_MMC_H_ */
39561 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39562 index 82a8de1..3c56ccb 100644
39563 --- a/drivers/mmc/host/sdhci-s3c.c
39564 +++ b/drivers/mmc/host/sdhci-s3c.c
39565 @@ -721,9 +721,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39566 * we can use overriding functions instead of default.
39567 */
39568 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39569 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39570 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39571 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39572 + pax_open_kernel();
39573 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39574 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39575 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39576 + pax_close_kernel();
39577 }
39578
39579 /* It supports additional host capabilities if needed */
39580 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39581 index a4eb8b5..8c0628f 100644
39582 --- a/drivers/mtd/devices/doc2000.c
39583 +++ b/drivers/mtd/devices/doc2000.c
39584 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39585
39586 /* The ECC will not be calculated correctly if less than 512 is written */
39587 /* DBB-
39588 - if (len != 0x200 && eccbuf)
39589 + if (len != 0x200)
39590 printk(KERN_WARNING
39591 "ECC needs a full sector write (adr: %lx size %lx)\n",
39592 (long) to, (long) len);
39593 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39594 index 0c8bb6b..6f35deb 100644
39595 --- a/drivers/mtd/nand/denali.c
39596 +++ b/drivers/mtd/nand/denali.c
39597 @@ -24,6 +24,7 @@
39598 #include <linux/slab.h>
39599 #include <linux/mtd/mtd.h>
39600 #include <linux/module.h>
39601 +#include <linux/slab.h>
39602
39603 #include "denali.h"
39604
39605 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39606 index 51b9d6a..52af9a7 100644
39607 --- a/drivers/mtd/nftlmount.c
39608 +++ b/drivers/mtd/nftlmount.c
39609 @@ -24,6 +24,7 @@
39610 #include <asm/errno.h>
39611 #include <linux/delay.h>
39612 #include <linux/slab.h>
39613 +#include <linux/sched.h>
39614 #include <linux/mtd/mtd.h>
39615 #include <linux/mtd/nand.h>
39616 #include <linux/mtd/nftl.h>
39617 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39618 index 8dd6ba5..419cc1d 100644
39619 --- a/drivers/mtd/sm_ftl.c
39620 +++ b/drivers/mtd/sm_ftl.c
39621 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39622 #define SM_CIS_VENDOR_OFFSET 0x59
39623 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39624 {
39625 - struct attribute_group *attr_group;
39626 + attribute_group_no_const *attr_group;
39627 struct attribute **attributes;
39628 struct sm_sysfs_attribute *vendor_attribute;
39629
39630 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39631 index 27cdf1f..8c37357 100644
39632 --- a/drivers/net/bonding/bond_main.c
39633 +++ b/drivers/net/bonding/bond_main.c
39634 @@ -4859,7 +4859,7 @@ static unsigned int bond_get_num_tx_queues(void)
39635 return tx_queues;
39636 }
39637
39638 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39639 +static struct rtnl_link_ops bond_link_ops = {
39640 .kind = "bond",
39641 .priv_size = sizeof(struct bonding),
39642 .setup = bond_setup,
39643 @@ -4975,8 +4975,8 @@ static void __exit bonding_exit(void)
39644
39645 bond_destroy_debugfs();
39646
39647 - rtnl_link_unregister(&bond_link_ops);
39648 unregister_pernet_subsys(&bond_net_ops);
39649 + rtnl_link_unregister(&bond_link_ops);
39650
39651 #ifdef CONFIG_NET_POLL_CONTROLLER
39652 /*
39653 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39654 index 70dba5d..11a0919 100644
39655 --- a/drivers/net/ethernet/8390/ax88796.c
39656 +++ b/drivers/net/ethernet/8390/ax88796.c
39657 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39658 if (ax->plat->reg_offsets)
39659 ei_local->reg_offset = ax->plat->reg_offsets;
39660 else {
39661 + resource_size_t _mem_size = mem_size;
39662 + do_div(_mem_size, 0x18);
39663 ei_local->reg_offset = ax->reg_offsets;
39664 for (ret = 0; ret < 0x18; ret++)
39665 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39666 + ax->reg_offsets[ret] = _mem_size * ret;
39667 }
39668
39669 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39670 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39671 index 0991534..8098e92 100644
39672 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39673 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39674 @@ -1094,7 +1094,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39675 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39676 {
39677 /* RX_MODE controlling object */
39678 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39679 + bnx2x_init_rx_mode_obj(bp);
39680
39681 /* multicast configuration controlling object */
39682 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39683 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39684 index 10bc093..a2fb42a 100644
39685 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39686 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39687 @@ -2136,12 +2136,12 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap)
39688 break;
39689 default:
39690 BNX2X_ERR("Non valid capability ID\n");
39691 - rval = -EINVAL;
39692 + rval = 1;
39693 break;
39694 }
39695 } else {
39696 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39697 - rval = -EINVAL;
39698 + rval = 1;
39699 }
39700
39701 DP(BNX2X_MSG_DCB, "capid %d:%x\n", capid, *cap);
39702 @@ -2167,12 +2167,12 @@ static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num)
39703 break;
39704 default:
39705 BNX2X_ERR("Non valid TC-ID\n");
39706 - rval = -EINVAL;
39707 + rval = 1;
39708 break;
39709 }
39710 } else {
39711 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39712 - rval = -EINVAL;
39713 + rval = 1;
39714 }
39715
39716 return rval;
39717 @@ -2185,7 +2185,7 @@ static int bnx2x_dcbnl_set_numtcs(struct net_device *netdev, int tcid, u8 num)
39718 return -EINVAL;
39719 }
39720
39721 -static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39722 +static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39723 {
39724 struct bnx2x *bp = netdev_priv(netdev);
39725 DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcbx_local_feat.pfc.enabled);
39726 @@ -2387,12 +2387,12 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid,
39727 break;
39728 default:
39729 BNX2X_ERR("Non valid featrue-ID\n");
39730 - rval = -EINVAL;
39731 + rval = 1;
39732 break;
39733 }
39734 } else {
39735 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39736 - rval = -EINVAL;
39737 + rval = 1;
39738 }
39739
39740 return rval;
39741 @@ -2428,12 +2428,12 @@ static u8 bnx2x_dcbnl_set_featcfg(struct net_device *netdev, int featid,
39742 break;
39743 default:
39744 BNX2X_ERR("Non valid featrue-ID\n");
39745 - rval = -EINVAL;
39746 + rval = 1;
39747 break;
39748 }
39749 } else {
39750 DP(BNX2X_MSG_DCB, "dcbnl call not valid\n");
39751 - rval = -EINVAL;
39752 + rval = 1;
39753 }
39754
39755 return rval;
39756 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39757 index 5523da3..4fcf274 100644
39758 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39759 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39760 @@ -4767,7 +4767,7 @@ static void bnx2x_after_function_update(struct bnx2x *bp)
39761 q);
39762 }
39763
39764 - if (!NO_FCOE(bp)) {
39765 + if (!NO_FCOE(bp) && CNIC_ENABLED(bp)) {
39766 fp = &bp->fp[FCOE_IDX(bp)];
39767 queue_params.q_obj = &bnx2x_sp_obj(bp, fp).q_obj;
39768
39769 @@ -13047,6 +13047,7 @@ static int bnx2x_unregister_cnic(struct net_device *dev)
39770 RCU_INIT_POINTER(bp->cnic_ops, NULL);
39771 mutex_unlock(&bp->cnic_mutex);
39772 synchronize_rcu();
39773 + bp->cnic_enabled = false;
39774 kfree(bp->cnic_kwq);
39775 bp->cnic_kwq = NULL;
39776
39777 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39778 index 09b625e..15b16fe 100644
39779 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39780 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39781 @@ -2375,15 +2375,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39782 return rc;
39783 }
39784
39785 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39786 - struct bnx2x_rx_mode_obj *o)
39787 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39788 {
39789 if (CHIP_IS_E1x(bp)) {
39790 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39791 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39792 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39793 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39794 } else {
39795 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39796 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39797 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39798 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39799 }
39800 }
39801
39802 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39803 index adbd91b..58ec94a 100644
39804 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39805 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39806 @@ -1293,8 +1293,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39807
39808 /********************* RX MODE ****************/
39809
39810 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39811 - struct bnx2x_rx_mode_obj *o);
39812 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39813
39814 /**
39815 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39816 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39817 index d330e81..ce1fb9a 100644
39818 --- a/drivers/net/ethernet/broadcom/tg3.h
39819 +++ b/drivers/net/ethernet/broadcom/tg3.h
39820 @@ -146,6 +146,7 @@
39821 #define CHIPREV_ID_5750_A0 0x4000
39822 #define CHIPREV_ID_5750_A1 0x4001
39823 #define CHIPREV_ID_5750_A3 0x4003
39824 +#define CHIPREV_ID_5750_C1 0x4201
39825 #define CHIPREV_ID_5750_C2 0x4202
39826 #define CHIPREV_ID_5752_A0_HW 0x5000
39827 #define CHIPREV_ID_5752_A0 0x6000
39828 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39829 index 8cffcdf..aadf043 100644
39830 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39831 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39832 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39833 */
39834 struct l2t_skb_cb {
39835 arp_failure_handler_func arp_failure_handler;
39836 -};
39837 +} __no_const;
39838
39839 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39840
39841 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39842 index 4c83003..2a2a5b9 100644
39843 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39844 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39845 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39846 for (i=0; i<ETH_ALEN; i++) {
39847 tmp.addr[i] = dev->dev_addr[i];
39848 }
39849 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39850 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39851 break;
39852
39853 case DE4X5_SET_HWADDR: /* Set the hardware address */
39854 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39855 spin_lock_irqsave(&lp->lock, flags);
39856 memcpy(&statbuf, &lp->pktStats, ioc->len);
39857 spin_unlock_irqrestore(&lp->lock, flags);
39858 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39859 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39860 return -EFAULT;
39861 break;
39862 }
39863 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39864 index 4d6f3c5..6169e60 100644
39865 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39866 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39867 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39868
39869 if (wrapped)
39870 newacc += 65536;
39871 - ACCESS_ONCE(*acc) = newacc;
39872 + ACCESS_ONCE_RW(*acc) = newacc;
39873 }
39874
39875 void be_parse_stats(struct be_adapter *adapter)
39876 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39877 index 74d749e..eefb1bd 100644
39878 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39879 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39880 @@ -31,6 +31,8 @@
39881 #include <linux/netdevice.h>
39882 #include <linux/phy.h>
39883 #include <linux/platform_device.h>
39884 +#include <linux/interrupt.h>
39885 +#include <linux/irqreturn.h>
39886 #include <net/ip.h>
39887
39888 #include "ftgmac100.h"
39889 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39890 index b901a01..1ff32ee 100644
39891 --- a/drivers/net/ethernet/faraday/ftmac100.c
39892 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39893 @@ -31,6 +31,8 @@
39894 #include <linux/module.h>
39895 #include <linux/netdevice.h>
39896 #include <linux/platform_device.h>
39897 +#include <linux/interrupt.h>
39898 +#include <linux/irqreturn.h>
39899
39900 #include "ftmac100.h"
39901
39902 diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
39903 index a59f077..7925d77 100644
39904 --- a/drivers/net/ethernet/intel/e100.c
39905 +++ b/drivers/net/ethernet/intel/e100.c
39906 @@ -870,7 +870,7 @@ err_unlock:
39907 }
39908
39909 static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39910 - void (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39911 + int (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39912 {
39913 struct cb *cb;
39914 unsigned long flags;
39915 @@ -888,10 +888,13 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39916 nic->cbs_avail--;
39917 cb->skb = skb;
39918
39919 + err = cb_prepare(nic, cb, skb);
39920 + if (err)
39921 + goto err_unlock;
39922 +
39923 if (unlikely(!nic->cbs_avail))
39924 err = -ENOSPC;
39925
39926 - cb_prepare(nic, cb, skb);
39927
39928 /* Order is important otherwise we'll be in a race with h/w:
39929 * set S-bit in current first, then clear S-bit in previous. */
39930 @@ -1091,7 +1094,7 @@ static void e100_get_defaults(struct nic *nic)
39931 nic->mii.mdio_write = mdio_write;
39932 }
39933
39934 -static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39935 +static int e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39936 {
39937 struct config *config = &cb->u.config;
39938 u8 *c = (u8 *)config;
39939 @@ -1181,6 +1184,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39940 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
39941 "[16-23]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
39942 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
39943 + return 0;
39944 }
39945
39946 /*************************************************************************
39947 @@ -1331,7 +1335,7 @@ static const struct firmware *e100_request_firmware(struct nic *nic)
39948 return fw;
39949 }
39950
39951 -static void e100_setup_ucode(struct nic *nic, struct cb *cb,
39952 +static int e100_setup_ucode(struct nic *nic, struct cb *cb,
39953 struct sk_buff *skb)
39954 {
39955 const struct firmware *fw = (void *)skb;
39956 @@ -1358,6 +1362,7 @@ static void e100_setup_ucode(struct nic *nic, struct cb *cb,
39957 cb->u.ucode[min_size] |= cpu_to_le32((BUNDLESMALL) ? 0xFFFF : 0xFF80);
39958
39959 cb->command = cpu_to_le16(cb_ucode | cb_el);
39960 + return 0;
39961 }
39962
39963 static inline int e100_load_ucode_wait(struct nic *nic)
39964 @@ -1400,18 +1405,20 @@ static inline int e100_load_ucode_wait(struct nic *nic)
39965 return err;
39966 }
39967
39968 -static void e100_setup_iaaddr(struct nic *nic, struct cb *cb,
39969 +static int e100_setup_iaaddr(struct nic *nic, struct cb *cb,
39970 struct sk_buff *skb)
39971 {
39972 cb->command = cpu_to_le16(cb_iaaddr);
39973 memcpy(cb->u.iaaddr, nic->netdev->dev_addr, ETH_ALEN);
39974 + return 0;
39975 }
39976
39977 -static void e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39978 +static int e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39979 {
39980 cb->command = cpu_to_le16(cb_dump);
39981 cb->u.dump_buffer_addr = cpu_to_le32(nic->dma_addr +
39982 offsetof(struct mem, dump_buf));
39983 + return 0;
39984 }
39985
39986 static int e100_phy_check_without_mii(struct nic *nic)
39987 @@ -1581,7 +1588,7 @@ static int e100_hw_init(struct nic *nic)
39988 return 0;
39989 }
39990
39991 -static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39992 +static int e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39993 {
39994 struct net_device *netdev = nic->netdev;
39995 struct netdev_hw_addr *ha;
39996 @@ -1596,6 +1603,7 @@ static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39997 memcpy(&cb->u.multi.addr[i++ * ETH_ALEN], &ha->addr,
39998 ETH_ALEN);
39999 }
40000 + return 0;
40001 }
40002
40003 static void e100_set_multicast_list(struct net_device *netdev)
40004 @@ -1756,11 +1764,18 @@ static void e100_watchdog(unsigned long data)
40005 round_jiffies(jiffies + E100_WATCHDOG_PERIOD));
40006 }
40007
40008 -static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40009 +static int e100_xmit_prepare(struct nic *nic, struct cb *cb,
40010 struct sk_buff *skb)
40011 {
40012 + dma_addr_t dma_addr;
40013 cb->command = nic->tx_command;
40014
40015 + dma_addr = pci_map_single(nic->pdev,
40016 + skb->data, skb->len, PCI_DMA_TODEVICE);
40017 + /* If we can't map the skb, have the upper layer try later */
40018 + if (pci_dma_mapping_error(nic->pdev, dma_addr))
40019 + return -ENOMEM;
40020 +
40021 /*
40022 * Use the last 4 bytes of the SKB payload packet as the CRC, used for
40023 * testing, ie sending frames with bad CRC.
40024 @@ -1777,11 +1792,10 @@ static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40025 cb->u.tcb.tcb_byte_count = 0;
40026 cb->u.tcb.threshold = nic->tx_threshold;
40027 cb->u.tcb.tbd_count = 1;
40028 - cb->u.tcb.tbd.buf_addr = cpu_to_le32(pci_map_single(nic->pdev,
40029 - skb->data, skb->len, PCI_DMA_TODEVICE));
40030 - /* check for mapping failure? */
40031 + cb->u.tcb.tbd.buf_addr = cpu_to_le32(dma_addr);
40032 cb->u.tcb.tbd.size = cpu_to_le16(skb->len);
40033 skb_tx_timestamp(skb);
40034 + return 0;
40035 }
40036
40037 static netdev_tx_t e100_xmit_frame(struct sk_buff *skb,
40038 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40039 index bb9256a..56d8752 100644
40040 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40041 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40042 @@ -806,7 +806,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
40043 }
40044
40045 /* update the base incval used to calculate frequency adjustment */
40046 - ACCESS_ONCE(adapter->base_incval) = incval;
40047 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40048 smp_mb();
40049
40050 /* need lock to prevent incorrect read while modifying cyclecounter */
40051 diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
40052 index c124e67..db9b897 100644
40053 --- a/drivers/net/ethernet/lantiq_etop.c
40054 +++ b/drivers/net/ethernet/lantiq_etop.c
40055 @@ -769,7 +769,7 @@ ltq_etop_probe(struct platform_device *pdev)
40056 return 0;
40057
40058 err_free:
40059 - kfree(dev);
40060 + free_netdev(dev);
40061 err_out:
40062 return err;
40063 }
40064 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40065 index fbe5363..266b4e3 100644
40066 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40067 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40068 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40069 struct __vxge_hw_fifo *fifo;
40070 struct vxge_hw_fifo_config *config;
40071 u32 txdl_size, txdl_per_memblock;
40072 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40073 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40074 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40075 + };
40076 +
40077 struct __vxge_hw_virtualpath *vpath;
40078
40079 if ((vp == NULL) || (attr == NULL)) {
40080 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40081 goto exit;
40082 }
40083
40084 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40085 -
40086 fifo->mempool =
40087 __vxge_hw_mempool_create(vpath->hldev,
40088 fifo->config->memblock_size,
40089 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40090 index 2d849da..23bba3b 100644
40091 --- a/drivers/net/ethernet/realtek/r8169.c
40092 +++ b/drivers/net/ethernet/realtek/r8169.c
40093 @@ -741,22 +741,22 @@ struct rtl8169_private {
40094 struct mdio_ops {
40095 void (*write)(struct rtl8169_private *, int, int);
40096 int (*read)(struct rtl8169_private *, int);
40097 - } mdio_ops;
40098 + } __no_const mdio_ops;
40099
40100 struct pll_power_ops {
40101 void (*down)(struct rtl8169_private *);
40102 void (*up)(struct rtl8169_private *);
40103 - } pll_power_ops;
40104 + } __no_const pll_power_ops;
40105
40106 struct jumbo_ops {
40107 void (*enable)(struct rtl8169_private *);
40108 void (*disable)(struct rtl8169_private *);
40109 - } jumbo_ops;
40110 + } __no_const jumbo_ops;
40111
40112 struct csi_ops {
40113 void (*write)(struct rtl8169_private *, int, int);
40114 u32 (*read)(struct rtl8169_private *, int);
40115 - } csi_ops;
40116 + } __no_const csi_ops;
40117
40118 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40119 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40120 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40121 index 3f93624..cf01144 100644
40122 --- a/drivers/net/ethernet/sfc/ptp.c
40123 +++ b/drivers/net/ethernet/sfc/ptp.c
40124 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40125 (u32)((u64)ptp->start.dma_addr >> 32));
40126
40127 /* Clear flag that signals MC ready */
40128 - ACCESS_ONCE(*start) = 0;
40129 + ACCESS_ONCE_RW(*start) = 0;
40130 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40131 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40132
40133 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40134 index 0c74a70..3bc6f68 100644
40135 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40136 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40137 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40138
40139 writel(value, ioaddr + MMC_CNTRL);
40140
40141 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40142 - MMC_CNTRL, value);
40143 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40144 +// MMC_CNTRL, value);
40145 }
40146
40147 /* To mask all all interrupts.*/
40148 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40149 index e6fe0d8..2b7d752 100644
40150 --- a/drivers/net/hyperv/hyperv_net.h
40151 +++ b/drivers/net/hyperv/hyperv_net.h
40152 @@ -101,7 +101,7 @@ struct rndis_device {
40153
40154 enum rndis_device_state state;
40155 bool link_state;
40156 - atomic_t new_req_id;
40157 + atomic_unchecked_t new_req_id;
40158
40159 spinlock_t request_lock;
40160 struct list_head req_list;
40161 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40162 index 2b657d4..9903bc0 100644
40163 --- a/drivers/net/hyperv/rndis_filter.c
40164 +++ b/drivers/net/hyperv/rndis_filter.c
40165 @@ -107,7 +107,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40166 * template
40167 */
40168 set = &rndis_msg->msg.set_req;
40169 - set->req_id = atomic_inc_return(&dev->new_req_id);
40170 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40171
40172 /* Add to the request list */
40173 spin_lock_irqsave(&dev->request_lock, flags);
40174 @@ -758,7 +758,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40175
40176 /* Setup the rndis set */
40177 halt = &request->request_msg.msg.halt_req;
40178 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40179 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40180
40181 /* Ignore return since this msg is optional. */
40182 rndis_filter_send_request(dev, request);
40183 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40184 index 1e9cb0b..7839125 100644
40185 --- a/drivers/net/ieee802154/fakehard.c
40186 +++ b/drivers/net/ieee802154/fakehard.c
40187 @@ -386,7 +386,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40188 phy->transmit_power = 0xbf;
40189
40190 dev->netdev_ops = &fake_ops;
40191 - dev->ml_priv = &fake_mlme;
40192 + dev->ml_priv = (void *)&fake_mlme;
40193
40194 priv = netdev_priv(dev);
40195 priv->phy = phy;
40196 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40197 index e5cb723..1fc0461 100644
40198 --- a/drivers/net/macvlan.c
40199 +++ b/drivers/net/macvlan.c
40200 @@ -852,13 +852,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40201 int macvlan_link_register(struct rtnl_link_ops *ops)
40202 {
40203 /* common fields */
40204 - ops->priv_size = sizeof(struct macvlan_dev);
40205 - ops->validate = macvlan_validate;
40206 - ops->maxtype = IFLA_MACVLAN_MAX;
40207 - ops->policy = macvlan_policy;
40208 - ops->changelink = macvlan_changelink;
40209 - ops->get_size = macvlan_get_size;
40210 - ops->fill_info = macvlan_fill_info;
40211 + pax_open_kernel();
40212 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40213 + *(void **)&ops->validate = macvlan_validate;
40214 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40215 + *(const void **)&ops->policy = macvlan_policy;
40216 + *(void **)&ops->changelink = macvlan_changelink;
40217 + *(void **)&ops->get_size = macvlan_get_size;
40218 + *(void **)&ops->fill_info = macvlan_fill_info;
40219 + pax_close_kernel();
40220
40221 return rtnl_link_register(ops);
40222 };
40223 @@ -914,7 +916,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40224 return NOTIFY_DONE;
40225 }
40226
40227 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40228 +static struct notifier_block macvlan_notifier_block = {
40229 .notifier_call = macvlan_device_event,
40230 };
40231
40232 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40233 index 0f0f9ce..0ca5819 100644
40234 --- a/drivers/net/macvtap.c
40235 +++ b/drivers/net/macvtap.c
40236 @@ -1100,7 +1100,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40237 return NOTIFY_DONE;
40238 }
40239
40240 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40241 +static struct notifier_block macvtap_notifier_block = {
40242 .notifier_call = macvtap_device_event,
40243 };
40244
40245 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40246 index daec9b0..6428fcb 100644
40247 --- a/drivers/net/phy/mdio-bitbang.c
40248 +++ b/drivers/net/phy/mdio-bitbang.c
40249 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40250 struct mdiobb_ctrl *ctrl = bus->priv;
40251
40252 module_put(ctrl->ops->owner);
40253 + mdiobus_unregister(bus);
40254 mdiobus_free(bus);
40255 }
40256 EXPORT_SYMBOL(free_mdio_bitbang);
40257 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40258 index 508570e..f706dc7 100644
40259 --- a/drivers/net/ppp/ppp_generic.c
40260 +++ b/drivers/net/ppp/ppp_generic.c
40261 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40262 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40263 struct ppp_stats stats;
40264 struct ppp_comp_stats cstats;
40265 - char *vers;
40266
40267 switch (cmd) {
40268 case SIOCGPPPSTATS:
40269 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40270 break;
40271
40272 case SIOCGPPPVER:
40273 - vers = PPP_VERSION;
40274 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40275 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40276 break;
40277 err = 0;
40278 break;
40279 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40280 index 8efe47a..a8075c5 100644
40281 --- a/drivers/net/team/team.c
40282 +++ b/drivers/net/team/team.c
40283 @@ -2603,7 +2603,7 @@ static int team_device_event(struct notifier_block *unused,
40284 return NOTIFY_DONE;
40285 }
40286
40287 -static struct notifier_block team_notifier_block __read_mostly = {
40288 +static struct notifier_block team_notifier_block = {
40289 .notifier_call = team_device_event,
40290 };
40291
40292 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40293 index cb95fe5..a5bdab5 100644
40294 --- a/drivers/net/tun.c
40295 +++ b/drivers/net/tun.c
40296 @@ -1838,7 +1838,7 @@ unlock:
40297 }
40298
40299 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40300 - unsigned long arg, int ifreq_len)
40301 + unsigned long arg, size_t ifreq_len)
40302 {
40303 struct tun_file *tfile = file->private_data;
40304 struct tun_struct *tun;
40305 @@ -1850,6 +1850,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40306 int vnet_hdr_sz;
40307 int ret;
40308
40309 + if (ifreq_len > sizeof ifr)
40310 + return -EFAULT;
40311 +
40312 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40313 if (copy_from_user(&ifr, argp, ifreq_len))
40314 return -EFAULT;
40315 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40316 index cd8ccb2..cff5144 100644
40317 --- a/drivers/net/usb/hso.c
40318 +++ b/drivers/net/usb/hso.c
40319 @@ -71,7 +71,7 @@
40320 #include <asm/byteorder.h>
40321 #include <linux/serial_core.h>
40322 #include <linux/serial.h>
40323 -
40324 +#include <asm/local.h>
40325
40326 #define MOD_AUTHOR "Option Wireless"
40327 #define MOD_DESCRIPTION "USB High Speed Option driver"
40328 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40329 struct urb *urb;
40330
40331 urb = serial->rx_urb[0];
40332 - if (serial->port.count > 0) {
40333 + if (atomic_read(&serial->port.count) > 0) {
40334 count = put_rxbuf_data(urb, serial);
40335 if (count == -1)
40336 return;
40337 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40338 DUMP1(urb->transfer_buffer, urb->actual_length);
40339
40340 /* Anyone listening? */
40341 - if (serial->port.count == 0)
40342 + if (atomic_read(&serial->port.count) == 0)
40343 return;
40344
40345 if (status == 0) {
40346 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40347 tty_port_tty_set(&serial->port, tty);
40348
40349 /* check for port already opened, if not set the termios */
40350 - serial->port.count++;
40351 - if (serial->port.count == 1) {
40352 + if (atomic_inc_return(&serial->port.count) == 1) {
40353 serial->rx_state = RX_IDLE;
40354 /* Force default termio settings */
40355 _hso_serial_set_termios(tty, NULL);
40356 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40357 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40358 if (result) {
40359 hso_stop_serial_device(serial->parent);
40360 - serial->port.count--;
40361 + atomic_dec(&serial->port.count);
40362 kref_put(&serial->parent->ref, hso_serial_ref_free);
40363 }
40364 } else {
40365 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40366
40367 /* reset the rts and dtr */
40368 /* do the actual close */
40369 - serial->port.count--;
40370 + atomic_dec(&serial->port.count);
40371
40372 - if (serial->port.count <= 0) {
40373 - serial->port.count = 0;
40374 + if (atomic_read(&serial->port.count) <= 0) {
40375 + atomic_set(&serial->port.count, 0);
40376 tty_port_tty_set(&serial->port, NULL);
40377 if (!usb_gone)
40378 hso_stop_serial_device(serial->parent);
40379 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40380
40381 /* the actual setup */
40382 spin_lock_irqsave(&serial->serial_lock, flags);
40383 - if (serial->port.count)
40384 + if (atomic_read(&serial->port.count))
40385 _hso_serial_set_termios(tty, old);
40386 else
40387 tty->termios = *old;
40388 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40389 D1("Pending read interrupt on port %d\n", i);
40390 spin_lock(&serial->serial_lock);
40391 if (serial->rx_state == RX_IDLE &&
40392 - serial->port.count > 0) {
40393 + atomic_read(&serial->port.count) > 0) {
40394 /* Setup and send a ctrl req read on
40395 * port i */
40396 if (!serial->rx_urb_filled[0]) {
40397 @@ -3079,7 +3078,7 @@ static int hso_resume(struct usb_interface *iface)
40398 /* Start all serial ports */
40399 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40400 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40401 - if (dev2ser(serial_table[i])->port.count) {
40402 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40403 result =
40404 hso_start_serial_device(serial_table[i], GFP_NOIO);
40405 hso_kick_transmit(dev2ser(serial_table[i]));
40406 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40407 index 6993bfa..9053a34 100644
40408 --- a/drivers/net/vxlan.c
40409 +++ b/drivers/net/vxlan.c
40410 @@ -1428,7 +1428,7 @@ nla_put_failure:
40411 return -EMSGSIZE;
40412 }
40413
40414 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40415 +static struct rtnl_link_ops vxlan_link_ops = {
40416 .kind = "vxlan",
40417 .maxtype = IFLA_VXLAN_MAX,
40418 .policy = vxlan_policy,
40419 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40420 index 77fa428..996b355 100644
40421 --- a/drivers/net/wireless/at76c50x-usb.c
40422 +++ b/drivers/net/wireless/at76c50x-usb.c
40423 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40424 }
40425
40426 /* Convert timeout from the DFU status to jiffies */
40427 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40428 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40429 {
40430 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40431 | (s->poll_timeout[1] << 8)
40432 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40433 index 8d78253..bebbb68 100644
40434 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40435 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40436 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40437 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40438 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40439
40440 - ACCESS_ONCE(ads->ds_link) = i->link;
40441 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40442 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40443 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40444
40445 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40446 ctl6 = SM(i->keytype, AR_EncrType);
40447 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40448
40449 if ((i->is_first || i->is_last) &&
40450 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40451 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40452 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40453 | set11nTries(i->rates, 1)
40454 | set11nTries(i->rates, 2)
40455 | set11nTries(i->rates, 3)
40456 | (i->dur_update ? AR_DurUpdateEna : 0)
40457 | SM(0, AR_BurstDur);
40458
40459 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40460 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40461 | set11nRate(i->rates, 1)
40462 | set11nRate(i->rates, 2)
40463 | set11nRate(i->rates, 3);
40464 } else {
40465 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40466 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40467 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40468 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40469 }
40470
40471 if (!i->is_first) {
40472 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40473 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40474 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40475 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40476 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40477 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40478 return;
40479 }
40480
40481 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40482 break;
40483 }
40484
40485 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40486 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40487 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40488 | SM(i->txpower, AR_XmitPower)
40489 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40490 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40491 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40492 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40493
40494 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40495 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40496 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40497 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40498
40499 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40500 return;
40501
40502 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40503 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40504 | set11nPktDurRTSCTS(i->rates, 1);
40505
40506 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40507 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40508 | set11nPktDurRTSCTS(i->rates, 3);
40509
40510 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40511 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40512 | set11nRateFlags(i->rates, 1)
40513 | set11nRateFlags(i->rates, 2)
40514 | set11nRateFlags(i->rates, 3)
40515 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40516 index 301bf72..3f5654f 100644
40517 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40518 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40519 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40520 (i->qcu << AR_TxQcuNum_S) | desc_len;
40521
40522 checksum += val;
40523 - ACCESS_ONCE(ads->info) = val;
40524 + ACCESS_ONCE_RW(ads->info) = val;
40525
40526 checksum += i->link;
40527 - ACCESS_ONCE(ads->link) = i->link;
40528 + ACCESS_ONCE_RW(ads->link) = i->link;
40529
40530 checksum += i->buf_addr[0];
40531 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40532 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40533 checksum += i->buf_addr[1];
40534 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40535 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40536 checksum += i->buf_addr[2];
40537 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40538 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40539 checksum += i->buf_addr[3];
40540 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40541 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40542
40543 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40544 - ACCESS_ONCE(ads->ctl3) = val;
40545 + ACCESS_ONCE_RW(ads->ctl3) = val;
40546 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40547 - ACCESS_ONCE(ads->ctl5) = val;
40548 + ACCESS_ONCE_RW(ads->ctl5) = val;
40549 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40550 - ACCESS_ONCE(ads->ctl7) = val;
40551 + ACCESS_ONCE_RW(ads->ctl7) = val;
40552 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40553 - ACCESS_ONCE(ads->ctl9) = val;
40554 + ACCESS_ONCE_RW(ads->ctl9) = val;
40555
40556 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40557 - ACCESS_ONCE(ads->ctl10) = checksum;
40558 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40559
40560 if (i->is_first || i->is_last) {
40561 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40562 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40563 | set11nTries(i->rates, 1)
40564 | set11nTries(i->rates, 2)
40565 | set11nTries(i->rates, 3)
40566 | (i->dur_update ? AR_DurUpdateEna : 0)
40567 | SM(0, AR_BurstDur);
40568
40569 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40570 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40571 | set11nRate(i->rates, 1)
40572 | set11nRate(i->rates, 2)
40573 | set11nRate(i->rates, 3);
40574 } else {
40575 - ACCESS_ONCE(ads->ctl13) = 0;
40576 - ACCESS_ONCE(ads->ctl14) = 0;
40577 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40578 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40579 }
40580
40581 ads->ctl20 = 0;
40582 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40583
40584 ctl17 = SM(i->keytype, AR_EncrType);
40585 if (!i->is_first) {
40586 - ACCESS_ONCE(ads->ctl11) = 0;
40587 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40588 - ACCESS_ONCE(ads->ctl15) = 0;
40589 - ACCESS_ONCE(ads->ctl16) = 0;
40590 - ACCESS_ONCE(ads->ctl17) = ctl17;
40591 - ACCESS_ONCE(ads->ctl18) = 0;
40592 - ACCESS_ONCE(ads->ctl19) = 0;
40593 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40594 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40595 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40596 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40597 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40598 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40599 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40600 return;
40601 }
40602
40603 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40604 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40605 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40606 | SM(i->txpower, AR_XmitPower)
40607 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40608 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40609 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40610 ctl12 |= SM(val, AR_PAPRDChainMask);
40611
40612 - ACCESS_ONCE(ads->ctl12) = ctl12;
40613 - ACCESS_ONCE(ads->ctl17) = ctl17;
40614 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40615 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40616
40617 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40618 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40619 | set11nPktDurRTSCTS(i->rates, 1);
40620
40621 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40622 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40623 | set11nPktDurRTSCTS(i->rates, 3);
40624
40625 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40626 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40627 | set11nRateFlags(i->rates, 1)
40628 | set11nRateFlags(i->rates, 2)
40629 | set11nRateFlags(i->rates, 3)
40630 | SM(i->rtscts_rate, AR_RTSCTSRate);
40631
40632 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40633 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40634 }
40635
40636 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40637 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40638 index 9d26fc5..60d9f14 100644
40639 --- a/drivers/net/wireless/ath/ath9k/hw.h
40640 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40641 @@ -658,7 +658,7 @@ struct ath_hw_private_ops {
40642
40643 /* ANI */
40644 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40645 -};
40646 +} __no_const;
40647
40648 /**
40649 * struct ath_hw_ops - callbacks used by hardware code and driver code
40650 @@ -688,7 +688,7 @@ struct ath_hw_ops {
40651 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
40652 struct ath_hw_antcomb_conf *antconf);
40653 void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
40654 -};
40655 +} __no_const;
40656
40657 struct ath_nf_limits {
40658 s16 max;
40659 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40660 index 3726cd6..b655808 100644
40661 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40662 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40663 @@ -3615,7 +3615,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40664 */
40665 if (il3945_mod_params.disable_hw_scan) {
40666 D_INFO("Disabling hw_scan\n");
40667 - il3945_mac_ops.hw_scan = NULL;
40668 + pax_open_kernel();
40669 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40670 + pax_close_kernel();
40671 }
40672
40673 D_INFO("*** LOAD DRIVER ***\n");
40674 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40675 index 5b9533e..7733880 100644
40676 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40677 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40678 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40679 {
40680 struct iwl_priv *priv = file->private_data;
40681 char buf[64];
40682 - int buf_size;
40683 + size_t buf_size;
40684 u32 offset, len;
40685
40686 memset(buf, 0, sizeof(buf));
40687 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40688 struct iwl_priv *priv = file->private_data;
40689
40690 char buf[8];
40691 - int buf_size;
40692 + size_t buf_size;
40693 u32 reset_flag;
40694
40695 memset(buf, 0, sizeof(buf));
40696 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40697 {
40698 struct iwl_priv *priv = file->private_data;
40699 char buf[8];
40700 - int buf_size;
40701 + size_t buf_size;
40702 int ht40;
40703
40704 memset(buf, 0, sizeof(buf));
40705 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40706 {
40707 struct iwl_priv *priv = file->private_data;
40708 char buf[8];
40709 - int buf_size;
40710 + size_t buf_size;
40711 int value;
40712
40713 memset(buf, 0, sizeof(buf));
40714 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40715 {
40716 struct iwl_priv *priv = file->private_data;
40717 char buf[8];
40718 - int buf_size;
40719 + size_t buf_size;
40720 int clear;
40721
40722 memset(buf, 0, sizeof(buf));
40723 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40724 {
40725 struct iwl_priv *priv = file->private_data;
40726 char buf[8];
40727 - int buf_size;
40728 + size_t buf_size;
40729 int trace;
40730
40731 memset(buf, 0, sizeof(buf));
40732 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40733 {
40734 struct iwl_priv *priv = file->private_data;
40735 char buf[8];
40736 - int buf_size;
40737 + size_t buf_size;
40738 int missed;
40739
40740 memset(buf, 0, sizeof(buf));
40741 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40742
40743 struct iwl_priv *priv = file->private_data;
40744 char buf[8];
40745 - int buf_size;
40746 + size_t buf_size;
40747 int plcp;
40748
40749 memset(buf, 0, sizeof(buf));
40750 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40751
40752 struct iwl_priv *priv = file->private_data;
40753 char buf[8];
40754 - int buf_size;
40755 + size_t buf_size;
40756 int flush;
40757
40758 memset(buf, 0, sizeof(buf));
40759 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40760
40761 struct iwl_priv *priv = file->private_data;
40762 char buf[8];
40763 - int buf_size;
40764 + size_t buf_size;
40765 int rts;
40766
40767 if (!priv->cfg->ht_params)
40768 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40769 {
40770 struct iwl_priv *priv = file->private_data;
40771 char buf[8];
40772 - int buf_size;
40773 + size_t buf_size;
40774
40775 memset(buf, 0, sizeof(buf));
40776 buf_size = min(count, sizeof(buf) - 1);
40777 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40778 struct iwl_priv *priv = file->private_data;
40779 u32 event_log_flag;
40780 char buf[8];
40781 - int buf_size;
40782 + size_t buf_size;
40783
40784 /* check that the interface is up */
40785 if (!iwl_is_ready(priv))
40786 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40787 struct iwl_priv *priv = file->private_data;
40788 char buf[8];
40789 u32 calib_disabled;
40790 - int buf_size;
40791 + size_t buf_size;
40792
40793 memset(buf, 0, sizeof(buf));
40794 buf_size = min(count, sizeof(buf) - 1);
40795 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40796 index 35708b9..31f7754 100644
40797 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40798 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40799 @@ -1100,7 +1100,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40800 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40801
40802 char buf[8];
40803 - int buf_size;
40804 + size_t buf_size;
40805 u32 reset_flag;
40806
40807 memset(buf, 0, sizeof(buf));
40808 @@ -1121,7 +1121,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40809 {
40810 struct iwl_trans *trans = file->private_data;
40811 char buf[8];
40812 - int buf_size;
40813 + size_t buf_size;
40814 int csr;
40815
40816 memset(buf, 0, sizeof(buf));
40817 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40818 index ff90855..e46d223 100644
40819 --- a/drivers/net/wireless/mac80211_hwsim.c
40820 +++ b/drivers/net/wireless/mac80211_hwsim.c
40821 @@ -2062,25 +2062,19 @@ static int __init init_mac80211_hwsim(void)
40822
40823 if (channels > 1) {
40824 hwsim_if_comb.num_different_channels = channels;
40825 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40826 - mac80211_hwsim_ops.cancel_hw_scan =
40827 - mac80211_hwsim_cancel_hw_scan;
40828 - mac80211_hwsim_ops.sw_scan_start = NULL;
40829 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40830 - mac80211_hwsim_ops.remain_on_channel =
40831 - mac80211_hwsim_roc;
40832 - mac80211_hwsim_ops.cancel_remain_on_channel =
40833 - mac80211_hwsim_croc;
40834 - mac80211_hwsim_ops.add_chanctx =
40835 - mac80211_hwsim_add_chanctx;
40836 - mac80211_hwsim_ops.remove_chanctx =
40837 - mac80211_hwsim_remove_chanctx;
40838 - mac80211_hwsim_ops.change_chanctx =
40839 - mac80211_hwsim_change_chanctx;
40840 - mac80211_hwsim_ops.assign_vif_chanctx =
40841 - mac80211_hwsim_assign_vif_chanctx;
40842 - mac80211_hwsim_ops.unassign_vif_chanctx =
40843 - mac80211_hwsim_unassign_vif_chanctx;
40844 + pax_open_kernel();
40845 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40846 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40847 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40848 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40849 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40850 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40851 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40852 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40853 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40854 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40855 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40856 + pax_close_kernel();
40857 }
40858
40859 spin_lock_init(&hwsim_radio_lock);
40860 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40861 index abe1d03..fb02c22 100644
40862 --- a/drivers/net/wireless/rndis_wlan.c
40863 +++ b/drivers/net/wireless/rndis_wlan.c
40864 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40865
40866 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40867
40868 - if (rts_threshold < 0 || rts_threshold > 2347)
40869 + if (rts_threshold > 2347)
40870 rts_threshold = 2347;
40871
40872 tmp = cpu_to_le32(rts_threshold);
40873 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40874 index 0751b35..246ba3e 100644
40875 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40876 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40877 @@ -398,7 +398,7 @@ struct rt2x00_intf {
40878 * for hardware which doesn't support hardware
40879 * sequence counting.
40880 */
40881 - atomic_t seqno;
40882 + atomic_unchecked_t seqno;
40883 };
40884
40885 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40886 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40887 index e488b94..14b6a0c 100644
40888 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40889 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40890 @@ -240,9 +240,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40891 * sequence counter given by mac80211.
40892 */
40893 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40894 - seqno = atomic_add_return(0x10, &intf->seqno);
40895 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40896 else
40897 - seqno = atomic_read(&intf->seqno);
40898 + seqno = atomic_read_unchecked(&intf->seqno);
40899
40900 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40901 hdr->seq_ctrl |= cpu_to_le16(seqno);
40902 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40903 index e57ee48..541cf6c 100644
40904 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40905 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40906 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40907
40908 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40909
40910 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40911 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40912 + pax_open_kernel();
40913 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40914 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40915 + pax_close_kernel();
40916
40917 wl1251_info("using dedicated interrupt line");
40918 } else {
40919 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40920 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40921 + pax_open_kernel();
40922 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40923 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40924 + pax_close_kernel();
40925
40926 wl1251_info("using SDIO interrupt");
40927 }
40928 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40929 index e5f5f8f..fdf15b7 100644
40930 --- a/drivers/net/wireless/ti/wl12xx/main.c
40931 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40932 @@ -644,7 +644,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40933 sizeof(wl->conf.mem));
40934
40935 /* read data preparation is only needed by wl127x */
40936 - wl->ops->prepare_read = wl127x_prepare_read;
40937 + pax_open_kernel();
40938 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40939 + pax_close_kernel();
40940
40941 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40942 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40943 @@ -665,7 +667,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40944 sizeof(wl->conf.mem));
40945
40946 /* read data preparation is only needed by wl127x */
40947 - wl->ops->prepare_read = wl127x_prepare_read;
40948 + pax_open_kernel();
40949 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40950 + pax_close_kernel();
40951
40952 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
40953 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
40954 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
40955 index 8d8c1f8..e754844 100644
40956 --- a/drivers/net/wireless/ti/wl18xx/main.c
40957 +++ b/drivers/net/wireless/ti/wl18xx/main.c
40958 @@ -1489,8 +1489,10 @@ static int wl18xx_setup(struct wl1271 *wl)
40959 }
40960
40961 if (!checksum_param) {
40962 - wl18xx_ops.set_rx_csum = NULL;
40963 - wl18xx_ops.init_vif = NULL;
40964 + pax_open_kernel();
40965 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
40966 + *(void **)&wl18xx_ops.init_vif = NULL;
40967 + pax_close_kernel();
40968 }
40969
40970 /* Enable 11a Band only if we have 5G antennas */
40971 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
40972 index ef2b171..bb513a6 100644
40973 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
40974 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
40975 @@ -387,7 +387,7 @@ static inline void handle_regs_int(struct urb *urb)
40976 {
40977 struct zd_usb *usb = urb->context;
40978 struct zd_usb_interrupt *intr = &usb->intr;
40979 - int len;
40980 + unsigned int len;
40981 u16 int_num;
40982
40983 ZD_ASSERT(in_interrupt());
40984 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
40985 index d93b2b6..ae50401 100644
40986 --- a/drivers/oprofile/buffer_sync.c
40987 +++ b/drivers/oprofile/buffer_sync.c
40988 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
40989 if (cookie == NO_COOKIE)
40990 offset = pc;
40991 if (cookie == INVALID_COOKIE) {
40992 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
40993 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
40994 offset = pc;
40995 }
40996 if (cookie != last_cookie) {
40997 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
40998 /* add userspace sample */
40999
41000 if (!mm) {
41001 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41002 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41003 return 0;
41004 }
41005
41006 cookie = lookup_dcookie(mm, s->eip, &offset);
41007
41008 if (cookie == INVALID_COOKIE) {
41009 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41010 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41011 return 0;
41012 }
41013
41014 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41015 /* ignore backtraces if failed to add a sample */
41016 if (state == sb_bt_start) {
41017 state = sb_bt_ignore;
41018 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41019 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41020 }
41021 }
41022 release_mm(mm);
41023 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41024 index c0cc4e7..44d4e54 100644
41025 --- a/drivers/oprofile/event_buffer.c
41026 +++ b/drivers/oprofile/event_buffer.c
41027 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41028 }
41029
41030 if (buffer_pos == buffer_size) {
41031 - atomic_inc(&oprofile_stats.event_lost_overflow);
41032 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41033 return;
41034 }
41035
41036 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41037 index ed2c3ec..deda85a 100644
41038 --- a/drivers/oprofile/oprof.c
41039 +++ b/drivers/oprofile/oprof.c
41040 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41041 if (oprofile_ops.switch_events())
41042 return;
41043
41044 - atomic_inc(&oprofile_stats.multiplex_counter);
41045 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41046 start_switch_worker();
41047 }
41048
41049 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41050 index 84a208d..d61b0a1 100644
41051 --- a/drivers/oprofile/oprofile_files.c
41052 +++ b/drivers/oprofile/oprofile_files.c
41053 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41054
41055 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41056
41057 -static ssize_t timeout_read(struct file *file, char __user *buf,
41058 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41059 size_t count, loff_t *offset)
41060 {
41061 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41062 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41063 index 917d28e..d62d981 100644
41064 --- a/drivers/oprofile/oprofile_stats.c
41065 +++ b/drivers/oprofile/oprofile_stats.c
41066 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41067 cpu_buf->sample_invalid_eip = 0;
41068 }
41069
41070 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41071 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41072 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41073 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41074 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41075 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41076 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41077 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41078 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41079 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41080 }
41081
41082
41083 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41084 index 38b6fc0..b5cbfce 100644
41085 --- a/drivers/oprofile/oprofile_stats.h
41086 +++ b/drivers/oprofile/oprofile_stats.h
41087 @@ -13,11 +13,11 @@
41088 #include <linux/atomic.h>
41089
41090 struct oprofile_stat_struct {
41091 - atomic_t sample_lost_no_mm;
41092 - atomic_t sample_lost_no_mapping;
41093 - atomic_t bt_lost_no_mapping;
41094 - atomic_t event_lost_overflow;
41095 - atomic_t multiplex_counter;
41096 + atomic_unchecked_t sample_lost_no_mm;
41097 + atomic_unchecked_t sample_lost_no_mapping;
41098 + atomic_unchecked_t bt_lost_no_mapping;
41099 + atomic_unchecked_t event_lost_overflow;
41100 + atomic_unchecked_t multiplex_counter;
41101 };
41102
41103 extern struct oprofile_stat_struct oprofile_stats;
41104 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41105 index 849357c..b83c1e0 100644
41106 --- a/drivers/oprofile/oprofilefs.c
41107 +++ b/drivers/oprofile/oprofilefs.c
41108 @@ -185,7 +185,7 @@ static const struct file_operations atomic_ro_fops = {
41109
41110
41111 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41112 - char const *name, atomic_t *val)
41113 + char const *name, atomic_unchecked_t *val)
41114 {
41115 return __oprofilefs_create_file(sb, root, name,
41116 &atomic_ro_fops, 0444, val);
41117 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41118 index 93404f7..4a313d8 100644
41119 --- a/drivers/oprofile/timer_int.c
41120 +++ b/drivers/oprofile/timer_int.c
41121 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41122 return NOTIFY_OK;
41123 }
41124
41125 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41126 +static struct notifier_block oprofile_cpu_notifier = {
41127 .notifier_call = oprofile_cpu_notify,
41128 };
41129
41130 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41131 index 3f56bc0..707d642 100644
41132 --- a/drivers/parport/procfs.c
41133 +++ b/drivers/parport/procfs.c
41134 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41135
41136 *ppos += len;
41137
41138 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41139 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41140 }
41141
41142 #ifdef CONFIG_PARPORT_1284
41143 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41144
41145 *ppos += len;
41146
41147 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41148 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41149 }
41150 #endif /* IEEE1284.3 support. */
41151
41152 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41153 index c35e8ad..fc33beb 100644
41154 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41155 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41156 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41157 goto init_cleanup;
41158 }
41159
41160 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41161 + pax_open_kernel();
41162 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41163 + pax_close_kernel();
41164 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41165
41166 return retval;
41167 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41168 index a6a71c4..c91097b 100644
41169 --- a/drivers/pci/hotplug/cpcihp_generic.c
41170 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41171 @@ -73,7 +73,6 @@ static u16 port;
41172 static unsigned int enum_bit;
41173 static u8 enum_mask;
41174
41175 -static struct cpci_hp_controller_ops generic_hpc_ops;
41176 static struct cpci_hp_controller generic_hpc;
41177
41178 static int __init validate_parameters(void)
41179 @@ -139,6 +138,10 @@ static int query_enum(void)
41180 return ((value & enum_mask) == enum_mask);
41181 }
41182
41183 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41184 + .query_enum = query_enum,
41185 +};
41186 +
41187 static int __init cpcihp_generic_init(void)
41188 {
41189 int status;
41190 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41191 pci_dev_put(dev);
41192
41193 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41194 - generic_hpc_ops.query_enum = query_enum;
41195 generic_hpc.ops = &generic_hpc_ops;
41196
41197 status = cpci_hp_register_controller(&generic_hpc);
41198 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41199 index 449b4bb..257e2e8 100644
41200 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41201 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41202 @@ -59,7 +59,6 @@
41203 /* local variables */
41204 static bool debug;
41205 static bool poll;
41206 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41207 static struct cpci_hp_controller zt5550_hpc;
41208
41209 /* Primary cPCI bus bridge device */
41210 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41211 return 0;
41212 }
41213
41214 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41215 + .query_enum = zt5550_hc_query_enum,
41216 +};
41217 +
41218 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41219 {
41220 int status;
41221 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41222 dbg("returned from zt5550_hc_config");
41223
41224 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41225 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41226 zt5550_hpc.ops = &zt5550_hpc_ops;
41227 if(!poll) {
41228 zt5550_hpc.irq = hc_dev->irq;
41229 zt5550_hpc.irq_flags = IRQF_SHARED;
41230 zt5550_hpc.dev_id = hc_dev;
41231
41232 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41233 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41234 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41235 + pax_open_kernel();
41236 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41237 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41238 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41239 + pax_open_kernel();
41240 } else {
41241 info("using ENUM# polling mode");
41242 }
41243 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41244 index 76ba8a1..20ca857 100644
41245 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41246 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41247 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41248
41249 void compaq_nvram_init (void __iomem *rom_start)
41250 {
41251 +
41252 +#ifndef CONFIG_PAX_KERNEXEC
41253 if (rom_start) {
41254 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41255 }
41256 +#endif
41257 +
41258 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41259
41260 /* initialize our int15 lock */
41261 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41262 index 202f4a9..8ee47d0 100644
41263 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41264 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41265 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41266 return -EINVAL;
41267 }
41268
41269 - slot->ops->owner = owner;
41270 - slot->ops->mod_name = mod_name;
41271 + pax_open_kernel();
41272 + *(struct module **)&slot->ops->owner = owner;
41273 + *(const char **)&slot->ops->mod_name = mod_name;
41274 + pax_close_kernel();
41275
41276 mutex_lock(&pci_hp_mutex);
41277 /*
41278 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41279 index 939bd1d..a1459c9 100644
41280 --- a/drivers/pci/hotplug/pciehp_core.c
41281 +++ b/drivers/pci/hotplug/pciehp_core.c
41282 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41283 struct slot *slot = ctrl->slot;
41284 struct hotplug_slot *hotplug = NULL;
41285 struct hotplug_slot_info *info = NULL;
41286 - struct hotplug_slot_ops *ops = NULL;
41287 + hotplug_slot_ops_no_const *ops = NULL;
41288 char name[SLOT_NAME_SIZE];
41289 int retval = -ENOMEM;
41290
41291 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41292 index 9c6e9bb..2916736 100644
41293 --- a/drivers/pci/pci-sysfs.c
41294 +++ b/drivers/pci/pci-sysfs.c
41295 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41296 {
41297 /* allocate attribute structure, piggyback attribute name */
41298 int name_len = write_combine ? 13 : 10;
41299 - struct bin_attribute *res_attr;
41300 + bin_attribute_no_const *res_attr;
41301 int retval;
41302
41303 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41304 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41305 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41306 {
41307 int retval;
41308 - struct bin_attribute *attr;
41309 + bin_attribute_no_const *attr;
41310
41311 /* If the device has VPD, try to expose it in sysfs. */
41312 if (dev->vpd) {
41313 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41314 {
41315 int retval;
41316 int rom_size = 0;
41317 - struct bin_attribute *attr;
41318 + bin_attribute_no_const *attr;
41319
41320 if (!sysfs_initialized)
41321 return -EACCES;
41322 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41323 index e851829..a1a7196 100644
41324 --- a/drivers/pci/pci.h
41325 +++ b/drivers/pci/pci.h
41326 @@ -98,7 +98,7 @@ struct pci_vpd_ops {
41327 struct pci_vpd {
41328 unsigned int len;
41329 const struct pci_vpd_ops *ops;
41330 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41331 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41332 };
41333
41334 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41335 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41336 index 8474b6a..ee81993 100644
41337 --- a/drivers/pci/pcie/aspm.c
41338 +++ b/drivers/pci/pcie/aspm.c
41339 @@ -27,9 +27,9 @@
41340 #define MODULE_PARAM_PREFIX "pcie_aspm."
41341
41342 /* Note: those are not register definitions */
41343 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41344 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41345 -#define ASPM_STATE_L1 (4) /* L1 state */
41346 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41347 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41348 +#define ASPM_STATE_L1 (4U) /* L1 state */
41349 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41350 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41351
41352 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41353 index 6186f03..1a78714 100644
41354 --- a/drivers/pci/probe.c
41355 +++ b/drivers/pci/probe.c
41356 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41357 struct pci_bus_region region;
41358 bool bar_too_big = false, bar_disabled = false;
41359
41360 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41361 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41362
41363 /* No printks while decoding is disabled! */
41364 if (!dev->mmio_always_on) {
41365 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41366 index 9b8505c..f00870a 100644
41367 --- a/drivers/pci/proc.c
41368 +++ b/drivers/pci/proc.c
41369 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41370 static int __init pci_proc_init(void)
41371 {
41372 struct pci_dev *dev = NULL;
41373 +
41374 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41375 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41376 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41377 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41378 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41379 +#endif
41380 +#else
41381 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41382 +#endif
41383 proc_create("devices", 0, proc_bus_pci_dir,
41384 &proc_bus_pci_dev_operations);
41385 proc_initialized = 1;
41386 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41387 index 2111dbb..79e434b 100644
41388 --- a/drivers/platform/x86/msi-laptop.c
41389 +++ b/drivers/platform/x86/msi-laptop.c
41390 @@ -820,12 +820,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41391 int result;
41392
41393 /* allow userland write sysfs file */
41394 - dev_attr_bluetooth.store = store_bluetooth;
41395 - dev_attr_wlan.store = store_wlan;
41396 - dev_attr_threeg.store = store_threeg;
41397 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41398 - dev_attr_wlan.attr.mode |= S_IWUSR;
41399 - dev_attr_threeg.attr.mode |= S_IWUSR;
41400 + pax_open_kernel();
41401 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41402 + *(void **)&dev_attr_wlan.store = store_wlan;
41403 + *(void **)&dev_attr_threeg.store = store_threeg;
41404 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41405 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41406 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41407 + pax_close_kernel();
41408
41409 /* disable hardware control by fn key */
41410 result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data);
41411 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41412 index 0fe987f..6f3d5c3 100644
41413 --- a/drivers/platform/x86/sony-laptop.c
41414 +++ b/drivers/platform/x86/sony-laptop.c
41415 @@ -2356,7 +2356,7 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
41416 }
41417
41418 /* High speed charging function */
41419 -static struct device_attribute *hsc_handle;
41420 +static device_attribute_no_const *hsc_handle;
41421
41422 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41423 struct device_attribute *attr,
41424 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41425 index f946ca7..f25c833 100644
41426 --- a/drivers/platform/x86/thinkpad_acpi.c
41427 +++ b/drivers/platform/x86/thinkpad_acpi.c
41428 @@ -2097,7 +2097,7 @@ static int hotkey_mask_get(void)
41429 return 0;
41430 }
41431
41432 -void static hotkey_mask_warn_incomplete_mask(void)
41433 +static void hotkey_mask_warn_incomplete_mask(void)
41434 {
41435 /* log only what the user can fix... */
41436 const u32 wantedmask = hotkey_driver_mask &
41437 @@ -2328,11 +2328,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41438 }
41439 }
41440
41441 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41442 - struct tp_nvram_state *newn,
41443 - const u32 event_mask)
41444 -{
41445 -
41446 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41447 do { \
41448 if ((event_mask & (1 << __scancode)) && \
41449 @@ -2346,36 +2341,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41450 tpacpi_hotkey_send_key(__scancode); \
41451 } while (0)
41452
41453 - void issue_volchange(const unsigned int oldvol,
41454 - const unsigned int newvol)
41455 - {
41456 - unsigned int i = oldvol;
41457 +static void issue_volchange(const unsigned int oldvol,
41458 + const unsigned int newvol,
41459 + const u32 event_mask)
41460 +{
41461 + unsigned int i = oldvol;
41462
41463 - while (i > newvol) {
41464 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41465 - i--;
41466 - }
41467 - while (i < newvol) {
41468 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41469 - i++;
41470 - }
41471 + while (i > newvol) {
41472 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41473 + i--;
41474 }
41475 + while (i < newvol) {
41476 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41477 + i++;
41478 + }
41479 +}
41480
41481 - void issue_brightnesschange(const unsigned int oldbrt,
41482 - const unsigned int newbrt)
41483 - {
41484 - unsigned int i = oldbrt;
41485 +static void issue_brightnesschange(const unsigned int oldbrt,
41486 + const unsigned int newbrt,
41487 + const u32 event_mask)
41488 +{
41489 + unsigned int i = oldbrt;
41490
41491 - while (i > newbrt) {
41492 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41493 - i--;
41494 - }
41495 - while (i < newbrt) {
41496 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41497 - i++;
41498 - }
41499 + while (i > newbrt) {
41500 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41501 + i--;
41502 + }
41503 + while (i < newbrt) {
41504 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41505 + i++;
41506 }
41507 +}
41508
41509 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41510 + struct tp_nvram_state *newn,
41511 + const u32 event_mask)
41512 +{
41513 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41514 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41515 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41516 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41517 oldn->volume_level != newn->volume_level) {
41518 /* recently muted, or repeated mute keypress, or
41519 * multiple presses ending in mute */
41520 - issue_volchange(oldn->volume_level, newn->volume_level);
41521 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41522 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41523 }
41524 } else {
41525 @@ -2419,7 +2420,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41526 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41527 }
41528 if (oldn->volume_level != newn->volume_level) {
41529 - issue_volchange(oldn->volume_level, newn->volume_level);
41530 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41531 } else if (oldn->volume_toggle != newn->volume_toggle) {
41532 /* repeated vol up/down keypress at end of scale ? */
41533 if (newn->volume_level == 0)
41534 @@ -2432,7 +2433,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41535 /* handle brightness */
41536 if (oldn->brightness_level != newn->brightness_level) {
41537 issue_brightnesschange(oldn->brightness_level,
41538 - newn->brightness_level);
41539 + newn->brightness_level,
41540 + event_mask);
41541 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41542 /* repeated key presses that didn't change state */
41543 if (newn->brightness_level == 0)
41544 @@ -2441,10 +2443,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41545 && !tp_features.bright_unkfw)
41546 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41547 }
41548 +}
41549
41550 #undef TPACPI_COMPARE_KEY
41551 #undef TPACPI_MAY_SEND_KEY
41552 -}
41553
41554 /*
41555 * Polling driver
41556 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41557 index 769d265..a3a05ca 100644
41558 --- a/drivers/pnp/pnpbios/bioscalls.c
41559 +++ b/drivers/pnp/pnpbios/bioscalls.c
41560 @@ -58,7 +58,7 @@ do { \
41561 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41562 } while(0)
41563
41564 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41565 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41566 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41567
41568 /*
41569 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41570
41571 cpu = get_cpu();
41572 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41573 +
41574 + pax_open_kernel();
41575 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41576 + pax_close_kernel();
41577
41578 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41579 spin_lock_irqsave(&pnp_bios_lock, flags);
41580 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41581 :"memory");
41582 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41583
41584 + pax_open_kernel();
41585 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41586 + pax_close_kernel();
41587 +
41588 put_cpu();
41589
41590 /* If we get here and this is set then the PnP BIOS faulted on us. */
41591 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41592 return status;
41593 }
41594
41595 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41596 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41597 {
41598 int i;
41599
41600 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41601 pnp_bios_callpoint.offset = header->fields.pm16offset;
41602 pnp_bios_callpoint.segment = PNP_CS16;
41603
41604 + pax_open_kernel();
41605 +
41606 for_each_possible_cpu(i) {
41607 struct desc_struct *gdt = get_cpu_gdt_table(i);
41608 if (!gdt)
41609 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41610 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41611 (unsigned long)__va(header->fields.pm16dseg));
41612 }
41613 +
41614 + pax_close_kernel();
41615 }
41616 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41617 index 3e6db1c..1fbbdae 100644
41618 --- a/drivers/pnp/resource.c
41619 +++ b/drivers/pnp/resource.c
41620 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41621 return 1;
41622
41623 /* check if the resource is valid */
41624 - if (*irq < 0 || *irq > 15)
41625 + if (*irq > 15)
41626 return 0;
41627
41628 /* check if the resource is reserved */
41629 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41630 return 1;
41631
41632 /* check if the resource is valid */
41633 - if (*dma < 0 || *dma == 4 || *dma > 7)
41634 + if (*dma == 4 || *dma > 7)
41635 return 0;
41636
41637 /* check if the resource is reserved */
41638 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41639 index 7df7c5f..bd48c47 100644
41640 --- a/drivers/power/pda_power.c
41641 +++ b/drivers/power/pda_power.c
41642 @@ -37,7 +37,11 @@ static int polling;
41643
41644 #ifdef CONFIG_USB_OTG_UTILS
41645 static struct usb_phy *transceiver;
41646 -static struct notifier_block otg_nb;
41647 +static int otg_handle_notification(struct notifier_block *nb,
41648 + unsigned long event, void *unused);
41649 +static struct notifier_block otg_nb = {
41650 + .notifier_call = otg_handle_notification
41651 +};
41652 #endif
41653
41654 static struct regulator *ac_draw;
41655 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41656
41657 #ifdef CONFIG_USB_OTG_UTILS
41658 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41659 - otg_nb.notifier_call = otg_handle_notification;
41660 ret = usb_register_notifier(transceiver, &otg_nb);
41661 if (ret) {
41662 dev_err(dev, "failure to register otg notifier\n");
41663 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41664 index cc439fd..8fa30df 100644
41665 --- a/drivers/power/power_supply.h
41666 +++ b/drivers/power/power_supply.h
41667 @@ -16,12 +16,12 @@ struct power_supply;
41668
41669 #ifdef CONFIG_SYSFS
41670
41671 -extern void power_supply_init_attrs(struct device_type *dev_type);
41672 +extern void power_supply_init_attrs(void);
41673 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41674
41675 #else
41676
41677 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41678 +static inline void power_supply_init_attrs(void) {}
41679 #define power_supply_uevent NULL
41680
41681 #endif /* CONFIG_SYSFS */
41682 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41683 index 8a7cfb3..72e6e9b 100644
41684 --- a/drivers/power/power_supply_core.c
41685 +++ b/drivers/power/power_supply_core.c
41686 @@ -24,7 +24,10 @@
41687 struct class *power_supply_class;
41688 EXPORT_SYMBOL_GPL(power_supply_class);
41689
41690 -static struct device_type power_supply_dev_type;
41691 +extern const struct attribute_group *power_supply_attr_groups[];
41692 +static struct device_type power_supply_dev_type = {
41693 + .groups = power_supply_attr_groups,
41694 +};
41695
41696 static int __power_supply_changed_work(struct device *dev, void *data)
41697 {
41698 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41699 return PTR_ERR(power_supply_class);
41700
41701 power_supply_class->dev_uevent = power_supply_uevent;
41702 - power_supply_init_attrs(&power_supply_dev_type);
41703 + power_supply_init_attrs();
41704
41705 return 0;
41706 }
41707 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41708 index 40fa3b7..d9c2e0e 100644
41709 --- a/drivers/power/power_supply_sysfs.c
41710 +++ b/drivers/power/power_supply_sysfs.c
41711 @@ -229,17 +229,15 @@ static struct attribute_group power_supply_attr_group = {
41712 .is_visible = power_supply_attr_is_visible,
41713 };
41714
41715 -static const struct attribute_group *power_supply_attr_groups[] = {
41716 +const struct attribute_group *power_supply_attr_groups[] = {
41717 &power_supply_attr_group,
41718 NULL,
41719 };
41720
41721 -void power_supply_init_attrs(struct device_type *dev_type)
41722 +void power_supply_init_attrs(void)
41723 {
41724 int i;
41725
41726 - dev_type->groups = power_supply_attr_groups;
41727 -
41728 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41729 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41730 }
41731 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41732 index 4d7c635..9860196 100644
41733 --- a/drivers/regulator/max8660.c
41734 +++ b/drivers/regulator/max8660.c
41735 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41736 max8660->shadow_regs[MAX8660_OVER1] = 5;
41737 } else {
41738 /* Otherwise devices can be toggled via software */
41739 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41740 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41741 + pax_open_kernel();
41742 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41743 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41744 + pax_close_kernel();
41745 }
41746
41747 /*
41748 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41749 index 9a8ea91..c483dd9 100644
41750 --- a/drivers/regulator/max8973-regulator.c
41751 +++ b/drivers/regulator/max8973-regulator.c
41752 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41753 if (!pdata->enable_ext_control) {
41754 max->desc.enable_reg = MAX8973_VOUT;
41755 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41756 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41757 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41758 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41759 + pax_open_kernel();
41760 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41761 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41762 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41763 + pax_close_kernel();
41764 }
41765
41766 max->enable_external_control = pdata->enable_ext_control;
41767 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41768 index 0d84b1f..c2da6ac 100644
41769 --- a/drivers/regulator/mc13892-regulator.c
41770 +++ b/drivers/regulator/mc13892-regulator.c
41771 @@ -540,10 +540,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41772 }
41773 mc13xxx_unlock(mc13892);
41774
41775 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41776 + pax_open_kernel();
41777 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41778 = mc13892_vcam_set_mode;
41779 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41780 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41781 = mc13892_vcam_get_mode;
41782 + pax_close_kernel();
41783
41784 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41785 ARRAY_SIZE(mc13892_regulators));
41786 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41787 index 16630aa..6afc992 100644
41788 --- a/drivers/rtc/rtc-cmos.c
41789 +++ b/drivers/rtc/rtc-cmos.c
41790 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41791 hpet_rtc_timer_init();
41792
41793 /* export at least the first block of NVRAM */
41794 - nvram.size = address_space - NVRAM_OFFSET;
41795 + pax_open_kernel();
41796 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41797 + pax_close_kernel();
41798 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41799 if (retval < 0) {
41800 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41801 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41802 index 9a86b4b..3a383dc 100644
41803 --- a/drivers/rtc/rtc-dev.c
41804 +++ b/drivers/rtc/rtc-dev.c
41805 @@ -14,6 +14,7 @@
41806 #include <linux/module.h>
41807 #include <linux/rtc.h>
41808 #include <linux/sched.h>
41809 +#include <linux/grsecurity.h>
41810 #include "rtc-core.h"
41811
41812 static dev_t rtc_devt;
41813 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
41814 if (copy_from_user(&tm, uarg, sizeof(tm)))
41815 return -EFAULT;
41816
41817 + gr_log_timechange();
41818 +
41819 return rtc_set_time(rtc, &tm);
41820
41821 case RTC_PIE_ON:
41822 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41823 index e0d0ba4..3c65868 100644
41824 --- a/drivers/rtc/rtc-ds1307.c
41825 +++ b/drivers/rtc/rtc-ds1307.c
41826 @@ -106,7 +106,7 @@ struct ds1307 {
41827 u8 offset; /* register's offset */
41828 u8 regs[11];
41829 u16 nvram_offset;
41830 - struct bin_attribute *nvram;
41831 + bin_attribute_no_const *nvram;
41832 enum ds_type type;
41833 unsigned long flags;
41834 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41835 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41836 index 130f29a..6179d03 100644
41837 --- a/drivers/rtc/rtc-m48t59.c
41838 +++ b/drivers/rtc/rtc-m48t59.c
41839 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41840 goto out;
41841 }
41842
41843 - m48t59_nvram_attr.size = pdata->offset;
41844 + pax_open_kernel();
41845 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41846 + pax_close_kernel();
41847
41848 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41849 if (ret) {
41850 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41851 index e693af6..2e525b6 100644
41852 --- a/drivers/scsi/bfa/bfa_fcpim.h
41853 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41854 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41855
41856 struct bfa_itn_s {
41857 bfa_isr_func_t isr;
41858 -};
41859 +} __no_const;
41860
41861 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41862 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41863 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41864 index 23a90e7..9cf04ee 100644
41865 --- a/drivers/scsi/bfa/bfa_ioc.h
41866 +++ b/drivers/scsi/bfa/bfa_ioc.h
41867 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41868 bfa_ioc_disable_cbfn_t disable_cbfn;
41869 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41870 bfa_ioc_reset_cbfn_t reset_cbfn;
41871 -};
41872 +} __no_const;
41873
41874 /*
41875 * IOC event notification mechanism.
41876 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41877 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41878 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41879 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41880 -};
41881 +} __no_const;
41882
41883 /*
41884 * Queue element to wait for room in request queue. FIFO order is
41885 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41886 index 593085a..47aa999 100644
41887 --- a/drivers/scsi/hosts.c
41888 +++ b/drivers/scsi/hosts.c
41889 @@ -42,7 +42,7 @@
41890 #include "scsi_logging.h"
41891
41892
41893 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41894 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41895
41896
41897 static void scsi_host_cls_release(struct device *dev)
41898 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41899 * subtract one because we increment first then return, but we need to
41900 * know what the next host number was before increment
41901 */
41902 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41903 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41904 shost->dma_channel = 0xff;
41905
41906 /* These three are default values which can be overridden */
41907 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41908 index 4f33806..afd6f60 100644
41909 --- a/drivers/scsi/hpsa.c
41910 +++ b/drivers/scsi/hpsa.c
41911 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41912 unsigned long flags;
41913
41914 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41915 - return h->access.command_completed(h, q);
41916 + return h->access->command_completed(h, q);
41917
41918 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41919 a = rq->head[rq->current_entry];
41920 @@ -3374,7 +3374,7 @@ static void start_io(struct ctlr_info *h)
41921 while (!list_empty(&h->reqQ)) {
41922 c = list_entry(h->reqQ.next, struct CommandList, list);
41923 /* can't do anything if fifo is full */
41924 - if ((h->access.fifo_full(h))) {
41925 + if ((h->access->fifo_full(h))) {
41926 dev_warn(&h->pdev->dev, "fifo full\n");
41927 break;
41928 }
41929 @@ -3396,7 +3396,7 @@ static void start_io(struct ctlr_info *h)
41930
41931 /* Tell the controller execute command */
41932 spin_unlock_irqrestore(&h->lock, flags);
41933 - h->access.submit_command(h, c);
41934 + h->access->submit_command(h, c);
41935 spin_lock_irqsave(&h->lock, flags);
41936 }
41937 spin_unlock_irqrestore(&h->lock, flags);
41938 @@ -3404,17 +3404,17 @@ static void start_io(struct ctlr_info *h)
41939
41940 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41941 {
41942 - return h->access.command_completed(h, q);
41943 + return h->access->command_completed(h, q);
41944 }
41945
41946 static inline bool interrupt_pending(struct ctlr_info *h)
41947 {
41948 - return h->access.intr_pending(h);
41949 + return h->access->intr_pending(h);
41950 }
41951
41952 static inline long interrupt_not_for_us(struct ctlr_info *h)
41953 {
41954 - return (h->access.intr_pending(h) == 0) ||
41955 + return (h->access->intr_pending(h) == 0) ||
41956 (h->interrupts_enabled == 0);
41957 }
41958
41959 @@ -4316,7 +4316,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
41960 if (prod_index < 0)
41961 return -ENODEV;
41962 h->product_name = products[prod_index].product_name;
41963 - h->access = *(products[prod_index].access);
41964 + h->access = products[prod_index].access;
41965
41966 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
41967 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
41968 @@ -4598,7 +4598,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
41969
41970 assert_spin_locked(&lockup_detector_lock);
41971 remove_ctlr_from_lockup_detector_list(h);
41972 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41973 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41974 spin_lock_irqsave(&h->lock, flags);
41975 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
41976 spin_unlock_irqrestore(&h->lock, flags);
41977 @@ -4775,7 +4775,7 @@ reinit_after_soft_reset:
41978 }
41979
41980 /* make sure the board interrupts are off */
41981 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41982 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41983
41984 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
41985 goto clean2;
41986 @@ -4809,7 +4809,7 @@ reinit_after_soft_reset:
41987 * fake ones to scoop up any residual completions.
41988 */
41989 spin_lock_irqsave(&h->lock, flags);
41990 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
41991 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
41992 spin_unlock_irqrestore(&h->lock, flags);
41993 free_irqs(h);
41994 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
41995 @@ -4828,9 +4828,9 @@ reinit_after_soft_reset:
41996 dev_info(&h->pdev->dev, "Board READY.\n");
41997 dev_info(&h->pdev->dev,
41998 "Waiting for stale completions to drain.\n");
41999 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42000 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42001 msleep(10000);
42002 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42003 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42004
42005 rc = controller_reset_failed(h->cfgtable);
42006 if (rc)
42007 @@ -4851,7 +4851,7 @@ reinit_after_soft_reset:
42008 }
42009
42010 /* Turn the interrupts on so we can service requests */
42011 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42012 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42013
42014 hpsa_hba_inquiry(h);
42015 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42016 @@ -4903,7 +4903,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42017 * To write all data in the battery backed cache to disks
42018 */
42019 hpsa_flush_cache(h);
42020 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42021 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42022 hpsa_free_irqs_and_disable_msix(h);
42023 }
42024
42025 @@ -5071,7 +5071,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42026 return;
42027 }
42028 /* Change the access methods to the performant access methods */
42029 - h->access = SA5_performant_access;
42030 + h->access = &SA5_performant_access;
42031 h->transMethod = CFGTBL_Trans_Performant;
42032 }
42033
42034 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42035 index 9816479..c5d4e97 100644
42036 --- a/drivers/scsi/hpsa.h
42037 +++ b/drivers/scsi/hpsa.h
42038 @@ -79,7 +79,7 @@ struct ctlr_info {
42039 unsigned int msix_vector;
42040 unsigned int msi_vector;
42041 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42042 - struct access_method access;
42043 + struct access_method *access;
42044
42045 /* queue and queue Info */
42046 struct list_head reqQ;
42047 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42048 index c772d8d..35c362c 100644
42049 --- a/drivers/scsi/libfc/fc_exch.c
42050 +++ b/drivers/scsi/libfc/fc_exch.c
42051 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42052 u16 pool_max_index;
42053
42054 struct {
42055 - atomic_t no_free_exch;
42056 - atomic_t no_free_exch_xid;
42057 - atomic_t xid_not_found;
42058 - atomic_t xid_busy;
42059 - atomic_t seq_not_found;
42060 - atomic_t non_bls_resp;
42061 + atomic_unchecked_t no_free_exch;
42062 + atomic_unchecked_t no_free_exch_xid;
42063 + atomic_unchecked_t xid_not_found;
42064 + atomic_unchecked_t xid_busy;
42065 + atomic_unchecked_t seq_not_found;
42066 + atomic_unchecked_t non_bls_resp;
42067 } stats;
42068 };
42069
42070 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42071 /* allocate memory for exchange */
42072 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42073 if (!ep) {
42074 - atomic_inc(&mp->stats.no_free_exch);
42075 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42076 goto out;
42077 }
42078 memset(ep, 0, sizeof(*ep));
42079 @@ -786,7 +786,7 @@ out:
42080 return ep;
42081 err:
42082 spin_unlock_bh(&pool->lock);
42083 - atomic_inc(&mp->stats.no_free_exch_xid);
42084 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42085 mempool_free(ep, mp->ep_pool);
42086 return NULL;
42087 }
42088 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42089 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42090 ep = fc_exch_find(mp, xid);
42091 if (!ep) {
42092 - atomic_inc(&mp->stats.xid_not_found);
42093 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42094 reject = FC_RJT_OX_ID;
42095 goto out;
42096 }
42097 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42098 ep = fc_exch_find(mp, xid);
42099 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42100 if (ep) {
42101 - atomic_inc(&mp->stats.xid_busy);
42102 + atomic_inc_unchecked(&mp->stats.xid_busy);
42103 reject = FC_RJT_RX_ID;
42104 goto rel;
42105 }
42106 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42107 }
42108 xid = ep->xid; /* get our XID */
42109 } else if (!ep) {
42110 - atomic_inc(&mp->stats.xid_not_found);
42111 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42112 reject = FC_RJT_RX_ID; /* XID not found */
42113 goto out;
42114 }
42115 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42116 } else {
42117 sp = &ep->seq;
42118 if (sp->id != fh->fh_seq_id) {
42119 - atomic_inc(&mp->stats.seq_not_found);
42120 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42121 if (f_ctl & FC_FC_END_SEQ) {
42122 /*
42123 * Update sequence_id based on incoming last
42124 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42125
42126 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42127 if (!ep) {
42128 - atomic_inc(&mp->stats.xid_not_found);
42129 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42130 goto out;
42131 }
42132 if (ep->esb_stat & ESB_ST_COMPLETE) {
42133 - atomic_inc(&mp->stats.xid_not_found);
42134 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42135 goto rel;
42136 }
42137 if (ep->rxid == FC_XID_UNKNOWN)
42138 ep->rxid = ntohs(fh->fh_rx_id);
42139 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42140 - atomic_inc(&mp->stats.xid_not_found);
42141 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42142 goto rel;
42143 }
42144 if (ep->did != ntoh24(fh->fh_s_id) &&
42145 ep->did != FC_FID_FLOGI) {
42146 - atomic_inc(&mp->stats.xid_not_found);
42147 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42148 goto rel;
42149 }
42150 sof = fr_sof(fp);
42151 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42152 sp->ssb_stat |= SSB_ST_RESP;
42153 sp->id = fh->fh_seq_id;
42154 } else if (sp->id != fh->fh_seq_id) {
42155 - atomic_inc(&mp->stats.seq_not_found);
42156 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42157 goto rel;
42158 }
42159
42160 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42161 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42162
42163 if (!sp)
42164 - atomic_inc(&mp->stats.xid_not_found);
42165 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42166 else
42167 - atomic_inc(&mp->stats.non_bls_resp);
42168 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42169
42170 fc_frame_free(fp);
42171 }
42172 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42173
42174 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42175 mp = ema->mp;
42176 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42177 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42178 st->fc_no_free_exch_xid +=
42179 - atomic_read(&mp->stats.no_free_exch_xid);
42180 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42181 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42182 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42183 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42184 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42185 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42186 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42187 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42188 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42189 }
42190 }
42191 EXPORT_SYMBOL(fc_exch_update_stats);
42192 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42193 index bdb81cd..d3c7c2c 100644
42194 --- a/drivers/scsi/libsas/sas_ata.c
42195 +++ b/drivers/scsi/libsas/sas_ata.c
42196 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42197 .postreset = ata_std_postreset,
42198 .error_handler = ata_std_error_handler,
42199 .post_internal_cmd = sas_ata_post_internal,
42200 - .qc_defer = ata_std_qc_defer,
42201 + .qc_defer = ata_std_qc_defer,
42202 .qc_prep = ata_noop_qc_prep,
42203 .qc_issue = sas_ata_qc_issue,
42204 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42205 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42206 index df4c13a..a51e90c 100644
42207 --- a/drivers/scsi/lpfc/lpfc.h
42208 +++ b/drivers/scsi/lpfc/lpfc.h
42209 @@ -424,7 +424,7 @@ struct lpfc_vport {
42210 struct dentry *debug_nodelist;
42211 struct dentry *vport_debugfs_root;
42212 struct lpfc_debugfs_trc *disc_trc;
42213 - atomic_t disc_trc_cnt;
42214 + atomic_unchecked_t disc_trc_cnt;
42215 #endif
42216 uint8_t stat_data_enabled;
42217 uint8_t stat_data_blocked;
42218 @@ -842,8 +842,8 @@ struct lpfc_hba {
42219 struct timer_list fabric_block_timer;
42220 unsigned long bit_flags;
42221 #define FABRIC_COMANDS_BLOCKED 0
42222 - atomic_t num_rsrc_err;
42223 - atomic_t num_cmd_success;
42224 + atomic_unchecked_t num_rsrc_err;
42225 + atomic_unchecked_t num_cmd_success;
42226 unsigned long last_rsrc_error_time;
42227 unsigned long last_ramp_down_time;
42228 unsigned long last_ramp_up_time;
42229 @@ -879,7 +879,7 @@ struct lpfc_hba {
42230
42231 struct dentry *debug_slow_ring_trc;
42232 struct lpfc_debugfs_trc *slow_ring_trc;
42233 - atomic_t slow_ring_trc_cnt;
42234 + atomic_unchecked_t slow_ring_trc_cnt;
42235 /* iDiag debugfs sub-directory */
42236 struct dentry *idiag_root;
42237 struct dentry *idiag_pci_cfg;
42238 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42239 index f63f5ff..de29189 100644
42240 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42241 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42242 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42243
42244 #include <linux/debugfs.h>
42245
42246 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42247 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42248 static unsigned long lpfc_debugfs_start_time = 0L;
42249
42250 /* iDiag */
42251 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42252 lpfc_debugfs_enable = 0;
42253
42254 len = 0;
42255 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42256 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42257 (lpfc_debugfs_max_disc_trc - 1);
42258 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42259 dtp = vport->disc_trc + i;
42260 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42261 lpfc_debugfs_enable = 0;
42262
42263 len = 0;
42264 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42265 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42266 (lpfc_debugfs_max_slow_ring_trc - 1);
42267 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42268 dtp = phba->slow_ring_trc + i;
42269 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42270 !vport || !vport->disc_trc)
42271 return;
42272
42273 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42274 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42275 (lpfc_debugfs_max_disc_trc - 1);
42276 dtp = vport->disc_trc + index;
42277 dtp->fmt = fmt;
42278 dtp->data1 = data1;
42279 dtp->data2 = data2;
42280 dtp->data3 = data3;
42281 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42282 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42283 dtp->jif = jiffies;
42284 #endif
42285 return;
42286 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42287 !phba || !phba->slow_ring_trc)
42288 return;
42289
42290 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42291 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42292 (lpfc_debugfs_max_slow_ring_trc - 1);
42293 dtp = phba->slow_ring_trc + index;
42294 dtp->fmt = fmt;
42295 dtp->data1 = data1;
42296 dtp->data2 = data2;
42297 dtp->data3 = data3;
42298 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42299 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42300 dtp->jif = jiffies;
42301 #endif
42302 return;
42303 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42304 "slow_ring buffer\n");
42305 goto debug_failed;
42306 }
42307 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42308 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42309 memset(phba->slow_ring_trc, 0,
42310 (sizeof(struct lpfc_debugfs_trc) *
42311 lpfc_debugfs_max_slow_ring_trc));
42312 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42313 "buffer\n");
42314 goto debug_failed;
42315 }
42316 - atomic_set(&vport->disc_trc_cnt, 0);
42317 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42318
42319 snprintf(name, sizeof(name), "discovery_trace");
42320 vport->debug_disc_trc =
42321 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42322 index 89ad558..76956c4 100644
42323 --- a/drivers/scsi/lpfc/lpfc_init.c
42324 +++ b/drivers/scsi/lpfc/lpfc_init.c
42325 @@ -10618,8 +10618,10 @@ lpfc_init(void)
42326 "misc_register returned with status %d", error);
42327
42328 if (lpfc_enable_npiv) {
42329 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42330 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42331 + pax_open_kernel();
42332 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42333 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42334 + pax_close_kernel();
42335 }
42336 lpfc_transport_template =
42337 fc_attach_transport(&lpfc_transport_functions);
42338 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42339 index 60e5a17..ff7a793 100644
42340 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42341 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42342 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42343 uint32_t evt_posted;
42344
42345 spin_lock_irqsave(&phba->hbalock, flags);
42346 - atomic_inc(&phba->num_rsrc_err);
42347 + atomic_inc_unchecked(&phba->num_rsrc_err);
42348 phba->last_rsrc_error_time = jiffies;
42349
42350 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42351 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42352 unsigned long flags;
42353 struct lpfc_hba *phba = vport->phba;
42354 uint32_t evt_posted;
42355 - atomic_inc(&phba->num_cmd_success);
42356 + atomic_inc_unchecked(&phba->num_cmd_success);
42357
42358 if (vport->cfg_lun_queue_depth <= queue_depth)
42359 return;
42360 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42361 unsigned long num_rsrc_err, num_cmd_success;
42362 int i;
42363
42364 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42365 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42366 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42367 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42368
42369 /*
42370 * The error and success command counters are global per
42371 @@ -419,8 +419,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42372 }
42373 }
42374 lpfc_destroy_vport_work_array(phba, vports);
42375 - atomic_set(&phba->num_rsrc_err, 0);
42376 - atomic_set(&phba->num_cmd_success, 0);
42377 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42378 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42379 }
42380
42381 /**
42382 @@ -454,8 +454,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42383 }
42384 }
42385 lpfc_destroy_vport_work_array(phba, vports);
42386 - atomic_set(&phba->num_rsrc_err, 0);
42387 - atomic_set(&phba->num_cmd_success, 0);
42388 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42389 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42390 }
42391
42392 /**
42393 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42394 index b46f5e9..c4c4ccb 100644
42395 --- a/drivers/scsi/pmcraid.c
42396 +++ b/drivers/scsi/pmcraid.c
42397 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42398 res->scsi_dev = scsi_dev;
42399 scsi_dev->hostdata = res;
42400 res->change_detected = 0;
42401 - atomic_set(&res->read_failures, 0);
42402 - atomic_set(&res->write_failures, 0);
42403 + atomic_set_unchecked(&res->read_failures, 0);
42404 + atomic_set_unchecked(&res->write_failures, 0);
42405 rc = 0;
42406 }
42407 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42408 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42409
42410 /* If this was a SCSI read/write command keep count of errors */
42411 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42412 - atomic_inc(&res->read_failures);
42413 + atomic_inc_unchecked(&res->read_failures);
42414 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42415 - atomic_inc(&res->write_failures);
42416 + atomic_inc_unchecked(&res->write_failures);
42417
42418 if (!RES_IS_GSCSI(res->cfg_entry) &&
42419 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42420 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42421 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42422 * hrrq_id assigned here in queuecommand
42423 */
42424 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42425 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42426 pinstance->num_hrrq;
42427 cmd->cmd_done = pmcraid_io_done;
42428
42429 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42430 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42431 * hrrq_id assigned here in queuecommand
42432 */
42433 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42434 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42435 pinstance->num_hrrq;
42436
42437 if (request_size) {
42438 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42439
42440 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42441 /* add resources only after host is added into system */
42442 - if (!atomic_read(&pinstance->expose_resources))
42443 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42444 return;
42445
42446 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42447 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42448 init_waitqueue_head(&pinstance->reset_wait_q);
42449
42450 atomic_set(&pinstance->outstanding_cmds, 0);
42451 - atomic_set(&pinstance->last_message_id, 0);
42452 - atomic_set(&pinstance->expose_resources, 0);
42453 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42454 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42455
42456 INIT_LIST_HEAD(&pinstance->free_res_q);
42457 INIT_LIST_HEAD(&pinstance->used_res_q);
42458 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42459 /* Schedule worker thread to handle CCN and take care of adding and
42460 * removing devices to OS
42461 */
42462 - atomic_set(&pinstance->expose_resources, 1);
42463 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42464 schedule_work(&pinstance->worker_q);
42465 return rc;
42466
42467 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42468 index e1d150f..6c6df44 100644
42469 --- a/drivers/scsi/pmcraid.h
42470 +++ b/drivers/scsi/pmcraid.h
42471 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42472 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42473
42474 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42475 - atomic_t last_message_id;
42476 + atomic_unchecked_t last_message_id;
42477
42478 /* configuration table */
42479 struct pmcraid_config_table *cfg_table;
42480 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42481 atomic_t outstanding_cmds;
42482
42483 /* should add/delete resources to mid-layer now ?*/
42484 - atomic_t expose_resources;
42485 + atomic_unchecked_t expose_resources;
42486
42487
42488
42489 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42490 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42491 };
42492 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42493 - atomic_t read_failures; /* count of failed READ commands */
42494 - atomic_t write_failures; /* count of failed WRITE commands */
42495 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42496 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42497
42498 /* To indicate add/delete/modify during CCN */
42499 u8 change_detected;
42500 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42501 index 83d7984..a27d947 100644
42502 --- a/drivers/scsi/qla2xxx/qla_attr.c
42503 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42504 @@ -1969,7 +1969,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42505 return 0;
42506 }
42507
42508 -struct fc_function_template qla2xxx_transport_functions = {
42509 +fc_function_template_no_const qla2xxx_transport_functions = {
42510
42511 .show_host_node_name = 1,
42512 .show_host_port_name = 1,
42513 @@ -2016,7 +2016,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42514 .bsg_timeout = qla24xx_bsg_timeout,
42515 };
42516
42517 -struct fc_function_template qla2xxx_transport_vport_functions = {
42518 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42519
42520 .show_host_node_name = 1,
42521 .show_host_port_name = 1,
42522 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42523 index 2411d1a..4673766 100644
42524 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42525 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42526 @@ -515,8 +515,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42527 struct device_attribute;
42528 extern struct device_attribute *qla2x00_host_attrs[];
42529 struct fc_function_template;
42530 -extern struct fc_function_template qla2xxx_transport_functions;
42531 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42532 +extern fc_function_template_no_const qla2xxx_transport_functions;
42533 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42534 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42535 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42536 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42537 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42538 index 10d23f8..a7d5d4c 100644
42539 --- a/drivers/scsi/qla2xxx/qla_os.c
42540 +++ b/drivers/scsi/qla2xxx/qla_os.c
42541 @@ -1472,8 +1472,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42542 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42543 /* Ok, a 64bit DMA mask is applicable. */
42544 ha->flags.enable_64bit_addressing = 1;
42545 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42546 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42547 + pax_open_kernel();
42548 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42549 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42550 + pax_close_kernel();
42551 return;
42552 }
42553 }
42554 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42555 index 329d553..f20d31d 100644
42556 --- a/drivers/scsi/qla4xxx/ql4_def.h
42557 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42558 @@ -273,7 +273,7 @@ struct ddb_entry {
42559 * (4000 only) */
42560 atomic_t relogin_timer; /* Max Time to wait for
42561 * relogin to complete */
42562 - atomic_t relogin_retry_count; /* Num of times relogin has been
42563 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42564 * retried */
42565 uint32_t default_time2wait; /* Default Min time between
42566 * relogins (+aens) */
42567 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42568 index 4cec123..7c1329f 100644
42569 --- a/drivers/scsi/qla4xxx/ql4_os.c
42570 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42571 @@ -2621,12 +2621,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42572 */
42573 if (!iscsi_is_session_online(cls_sess)) {
42574 /* Reset retry relogin timer */
42575 - atomic_inc(&ddb_entry->relogin_retry_count);
42576 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42577 DEBUG2(ql4_printk(KERN_INFO, ha,
42578 "%s: index[%d] relogin timed out-retrying"
42579 " relogin (%d), retry (%d)\n", __func__,
42580 ddb_entry->fw_ddb_index,
42581 - atomic_read(&ddb_entry->relogin_retry_count),
42582 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42583 ddb_entry->default_time2wait + 4));
42584 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42585 atomic_set(&ddb_entry->retry_relogin_timer,
42586 @@ -4738,7 +4738,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42587
42588 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42589 atomic_set(&ddb_entry->relogin_timer, 0);
42590 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42591 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42592 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42593 ddb_entry->default_relogin_timeout =
42594 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42595 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42596 index 2c0d0ec..4e8681a 100644
42597 --- a/drivers/scsi/scsi.c
42598 +++ b/drivers/scsi/scsi.c
42599 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42600 unsigned long timeout;
42601 int rtn = 0;
42602
42603 - atomic_inc(&cmd->device->iorequest_cnt);
42604 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42605
42606 /* check if the device is still usable */
42607 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42608 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42609 index f1bf5af..f67e943 100644
42610 --- a/drivers/scsi/scsi_lib.c
42611 +++ b/drivers/scsi/scsi_lib.c
42612 @@ -1454,7 +1454,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42613 shost = sdev->host;
42614 scsi_init_cmd_errh(cmd);
42615 cmd->result = DID_NO_CONNECT << 16;
42616 - atomic_inc(&cmd->device->iorequest_cnt);
42617 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42618
42619 /*
42620 * SCSI request completion path will do scsi_device_unbusy(),
42621 @@ -1480,9 +1480,9 @@ static void scsi_softirq_done(struct request *rq)
42622
42623 INIT_LIST_HEAD(&cmd->eh_entry);
42624
42625 - atomic_inc(&cmd->device->iodone_cnt);
42626 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42627 if (cmd->result)
42628 - atomic_inc(&cmd->device->ioerr_cnt);
42629 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42630
42631 disposition = scsi_decide_disposition(cmd);
42632 if (disposition != SUCCESS &&
42633 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42634 index 931a7d9..0c2a754 100644
42635 --- a/drivers/scsi/scsi_sysfs.c
42636 +++ b/drivers/scsi/scsi_sysfs.c
42637 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42638 char *buf) \
42639 { \
42640 struct scsi_device *sdev = to_scsi_device(dev); \
42641 - unsigned long long count = atomic_read(&sdev->field); \
42642 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42643 return snprintf(buf, 20, "0x%llx\n", count); \
42644 } \
42645 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42646 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42647 index 84a1fdf..693b0d6 100644
42648 --- a/drivers/scsi/scsi_tgt_lib.c
42649 +++ b/drivers/scsi/scsi_tgt_lib.c
42650 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42651 int err;
42652
42653 dprintk("%lx %u\n", uaddr, len);
42654 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42655 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42656 if (err) {
42657 /*
42658 * TODO: need to fixup sg_tablesize, max_segment_size,
42659 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42660 index e894ca7..de9d7660 100644
42661 --- a/drivers/scsi/scsi_transport_fc.c
42662 +++ b/drivers/scsi/scsi_transport_fc.c
42663 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42664 * Netlink Infrastructure
42665 */
42666
42667 -static atomic_t fc_event_seq;
42668 +static atomic_unchecked_t fc_event_seq;
42669
42670 /**
42671 * fc_get_event_number - Obtain the next sequential FC event number
42672 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42673 u32
42674 fc_get_event_number(void)
42675 {
42676 - return atomic_add_return(1, &fc_event_seq);
42677 + return atomic_add_return_unchecked(1, &fc_event_seq);
42678 }
42679 EXPORT_SYMBOL(fc_get_event_number);
42680
42681 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42682 {
42683 int error;
42684
42685 - atomic_set(&fc_event_seq, 0);
42686 + atomic_set_unchecked(&fc_event_seq, 0);
42687
42688 error = transport_class_register(&fc_host_class);
42689 if (error)
42690 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42691 char *cp;
42692
42693 *val = simple_strtoul(buf, &cp, 0);
42694 - if ((*cp && (*cp != '\n')) || (*val < 0))
42695 + if (*cp && (*cp != '\n'))
42696 return -EINVAL;
42697 /*
42698 * Check for overflow; dev_loss_tmo is u32
42699 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42700 index 31969f2..2b348f0 100644
42701 --- a/drivers/scsi/scsi_transport_iscsi.c
42702 +++ b/drivers/scsi/scsi_transport_iscsi.c
42703 @@ -79,7 +79,7 @@ struct iscsi_internal {
42704 struct transport_container session_cont;
42705 };
42706
42707 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42708 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42709 static struct workqueue_struct *iscsi_eh_timer_workq;
42710
42711 static DEFINE_IDA(iscsi_sess_ida);
42712 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42713 int err;
42714
42715 ihost = shost->shost_data;
42716 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42717 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42718
42719 if (target_id == ISCSI_MAX_TARGET) {
42720 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42721 @@ -2943,7 +2943,7 @@ static __init int iscsi_transport_init(void)
42722 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42723 ISCSI_TRANSPORT_VERSION);
42724
42725 - atomic_set(&iscsi_session_nr, 0);
42726 + atomic_set_unchecked(&iscsi_session_nr, 0);
42727
42728 err = class_register(&iscsi_transport_class);
42729 if (err)
42730 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42731 index f379c7f..e8fc69c 100644
42732 --- a/drivers/scsi/scsi_transport_srp.c
42733 +++ b/drivers/scsi/scsi_transport_srp.c
42734 @@ -33,7 +33,7 @@
42735 #include "scsi_transport_srp_internal.h"
42736
42737 struct srp_host_attrs {
42738 - atomic_t next_port_id;
42739 + atomic_unchecked_t next_port_id;
42740 };
42741 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42742
42743 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42744 struct Scsi_Host *shost = dev_to_shost(dev);
42745 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42746
42747 - atomic_set(&srp_host->next_port_id, 0);
42748 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42749 return 0;
42750 }
42751
42752 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42753 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42754 rport->roles = ids->roles;
42755
42756 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42757 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42758 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42759
42760 transport_setup_device(&rport->dev);
42761 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42762 index 7992635..609faf8 100644
42763 --- a/drivers/scsi/sd.c
42764 +++ b/drivers/scsi/sd.c
42765 @@ -2909,7 +2909,7 @@ static int sd_probe(struct device *dev)
42766 sdkp->disk = gd;
42767 sdkp->index = index;
42768 atomic_set(&sdkp->openers, 0);
42769 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42770 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42771
42772 if (!sdp->request_queue->rq_timeout) {
42773 if (sdp->type != TYPE_MOD)
42774 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42775 index be2c9a6..275525c 100644
42776 --- a/drivers/scsi/sg.c
42777 +++ b/drivers/scsi/sg.c
42778 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42779 sdp->disk->disk_name,
42780 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42781 NULL,
42782 - (char *)arg);
42783 + (char __user *)arg);
42784 case BLKTRACESTART:
42785 return blk_trace_startstop(sdp->device->request_queue, 1);
42786 case BLKTRACESTOP:
42787 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42788 index 19ee901..6e8c2ef 100644
42789 --- a/drivers/spi/spi.c
42790 +++ b/drivers/spi/spi.c
42791 @@ -1616,7 +1616,7 @@ int spi_bus_unlock(struct spi_master *master)
42792 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42793
42794 /* portable code must never pass more than 32 bytes */
42795 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42796 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42797
42798 static u8 *buf;
42799
42800 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42801 index c7a5f97..71ecd35 100644
42802 --- a/drivers/staging/iio/iio_hwmon.c
42803 +++ b/drivers/staging/iio/iio_hwmon.c
42804 @@ -72,7 +72,7 @@ static void iio_hwmon_free_attrs(struct iio_hwmon_state *st)
42805 static int iio_hwmon_probe(struct platform_device *pdev)
42806 {
42807 struct iio_hwmon_state *st;
42808 - struct sensor_device_attribute *a;
42809 + sensor_device_attribute_no_const *a;
42810 int ret, i;
42811 int in_i = 1, temp_i = 1, curr_i = 1;
42812 enum iio_chan_type type;
42813 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42814 index 34afc16..ffe44dd 100644
42815 --- a/drivers/staging/octeon/ethernet-rx.c
42816 +++ b/drivers/staging/octeon/ethernet-rx.c
42817 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42818 /* Increment RX stats for virtual ports */
42819 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42820 #ifdef CONFIG_64BIT
42821 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42822 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42823 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42824 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42825 #else
42826 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42827 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42828 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42829 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42830 #endif
42831 }
42832 netif_receive_skb(skb);
42833 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42834 dev->name);
42835 */
42836 #ifdef CONFIG_64BIT
42837 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42838 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42839 #else
42840 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42841 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42842 #endif
42843 dev_kfree_skb_irq(skb);
42844 }
42845 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42846 index ef32dc1..a159d68 100644
42847 --- a/drivers/staging/octeon/ethernet.c
42848 +++ b/drivers/staging/octeon/ethernet.c
42849 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42850 * since the RX tasklet also increments it.
42851 */
42852 #ifdef CONFIG_64BIT
42853 - atomic64_add(rx_status.dropped_packets,
42854 - (atomic64_t *)&priv->stats.rx_dropped);
42855 + atomic64_add_unchecked(rx_status.dropped_packets,
42856 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42857 #else
42858 - atomic_add(rx_status.dropped_packets,
42859 - (atomic_t *)&priv->stats.rx_dropped);
42860 + atomic_add_unchecked(rx_status.dropped_packets,
42861 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42862 #endif
42863 }
42864
42865 diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c
42866 index a2b7e03..aaf3630 100644
42867 --- a/drivers/staging/ramster/tmem.c
42868 +++ b/drivers/staging/ramster/tmem.c
42869 @@ -50,25 +50,25 @@
42870 * A tmem host implementation must use this function to register callbacks
42871 * for memory allocation.
42872 */
42873 -static struct tmem_hostops tmem_hostops;
42874 +static struct tmem_hostops *tmem_hostops;
42875
42876 static void tmem_objnode_tree_init(void);
42877
42878 void tmem_register_hostops(struct tmem_hostops *m)
42879 {
42880 tmem_objnode_tree_init();
42881 - tmem_hostops = *m;
42882 + tmem_hostops = m;
42883 }
42884
42885 /*
42886 * A tmem host implementation must use this function to register
42887 * callbacks for a page-accessible memory (PAM) implementation.
42888 */
42889 -static struct tmem_pamops tmem_pamops;
42890 +static struct tmem_pamops *tmem_pamops;
42891
42892 void tmem_register_pamops(struct tmem_pamops *m)
42893 {
42894 - tmem_pamops = *m;
42895 + tmem_pamops = m;
42896 }
42897
42898 /*
42899 @@ -174,7 +174,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
42900 obj->pampd_count = 0;
42901 #ifdef CONFIG_RAMSTER
42902 if (tmem_pamops.new_obj != NULL)
42903 - (*tmem_pamops.new_obj)(obj);
42904 + (tmem_pamops->new_obj)(obj);
42905 #endif
42906 SET_SENTINEL(obj, OBJ);
42907
42908 @@ -210,7 +210,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
42909 rbnode = rb_next(rbnode);
42910 tmem_pampd_destroy_all_in_obj(obj, true);
42911 tmem_obj_free(obj, hb);
42912 - (*tmem_hostops.obj_free)(obj, pool);
42913 + (tmem_hostops->obj_free)(obj, pool);
42914 }
42915 spin_unlock(&hb->lock);
42916 }
42917 @@ -261,7 +261,7 @@ static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj)
42918 ASSERT_SENTINEL(obj, OBJ);
42919 BUG_ON(obj->pool == NULL);
42920 ASSERT_SENTINEL(obj->pool, POOL);
42921 - objnode = (*tmem_hostops.objnode_alloc)(obj->pool);
42922 + objnode = (tmem_hostops->objnode_alloc)(obj->pool);
42923 if (unlikely(objnode == NULL))
42924 goto out;
42925 objnode->obj = obj;
42926 @@ -290,7 +290,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode)
42927 ASSERT_SENTINEL(pool, POOL);
42928 objnode->obj->objnode_count--;
42929 objnode->obj = NULL;
42930 - (*tmem_hostops.objnode_free)(objnode, pool);
42931 + (tmem_hostops->objnode_free)(objnode, pool);
42932 }
42933
42934 /*
42935 @@ -348,7 +348,7 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
42936 void *old_pampd = *(void **)slot;
42937 *(void **)slot = new_pampd;
42938 if (!no_free)
42939 - (*tmem_pamops.free)(old_pampd, obj->pool,
42940 + (tmem_pamops->free)(old_pampd, obj->pool,
42941 NULL, 0, false);
42942 ret = new_pampd;
42943 }
42944 @@ -505,7 +505,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
42945 if (objnode->slots[i]) {
42946 if (ht == 1) {
42947 obj->pampd_count--;
42948 - (*tmem_pamops.free)(objnode->slots[i],
42949 + (tmem_pamops->free)(objnode->slots[i],
42950 obj->pool, NULL, 0, true);
42951 objnode->slots[i] = NULL;
42952 continue;
42953 @@ -524,7 +524,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
42954 return;
42955 if (obj->objnode_tree_height == 0) {
42956 obj->pampd_count--;
42957 - (*tmem_pamops.free)(obj->objnode_tree_root,
42958 + (tmem_pamops->free)(obj->objnode_tree_root,
42959 obj->pool, NULL, 0, true);
42960 } else {
42961 tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
42962 @@ -535,7 +535,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
42963 obj->objnode_tree_root = NULL;
42964 #ifdef CONFIG_RAMSTER
42965 if (tmem_pamops.free_obj != NULL)
42966 - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
42967 + (tmem_pamops->free_obj)(obj->pool, obj, pool_destroy);
42968 #endif
42969 }
42970
42971 @@ -574,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42972 /* if found, is a dup put, flush the old one */
42973 pampd_del = tmem_pampd_delete_from_obj(obj, index);
42974 BUG_ON(pampd_del != pampd);
42975 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
42976 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
42977 if (obj->pampd_count == 0) {
42978 objnew = obj;
42979 objfound = NULL;
42980 @@ -582,7 +582,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42981 pampd = NULL;
42982 }
42983 } else {
42984 - obj = objnew = (*tmem_hostops.obj_alloc)(pool);
42985 + obj = objnew = (tmem_hostops->obj_alloc)(pool);
42986 if (unlikely(obj == NULL)) {
42987 ret = -ENOMEM;
42988 goto out;
42989 @@ -597,16 +597,16 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
42990 if (unlikely(ret == -ENOMEM))
42991 /* may have partially built objnode tree ("stump") */
42992 goto delete_and_free;
42993 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
42994 + (tmem_pamops->create_finish)(pampd, is_ephemeral(pool));
42995 goto out;
42996
42997 delete_and_free:
42998 (void)tmem_pampd_delete_from_obj(obj, index);
42999 if (pampd)
43000 - (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
43001 + (tmem_pamops->free)(pampd, pool, NULL, 0, true);
43002 if (objnew) {
43003 tmem_obj_free(objnew, hb);
43004 - (*tmem_hostops.obj_free)(objnew, pool);
43005 + (tmem_hostops->obj_free)(objnew, pool);
43006 }
43007 out:
43008 spin_unlock(&hb->lock);
43009 @@ -651,7 +651,7 @@ void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
43010 if (pampd != NULL) {
43011 BUG_ON(obj == NULL);
43012 (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
43013 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
43014 + (tmem_pamops->create_finish)(pampd, is_ephemeral(obj->pool));
43015 } else if (delete) {
43016 BUG_ON(obj == NULL);
43017 (void)tmem_pampd_delete_from_obj(obj, index);
43018 @@ -671,7 +671,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43019 int ret = 0;
43020
43021 if (!is_ephemeral(pool))
43022 - new_pampd = (*tmem_pamops.repatriate_preload)(
43023 + new_pampd = (tmem_pamops->repatriate_preload)(
43024 old_pampd, pool, oidp, index, &intransit);
43025 if (intransit)
43026 ret = -EAGAIN;
43027 @@ -680,7 +680,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43028 /* must release the hb->lock else repatriate can't sleep */
43029 spin_unlock(&hb->lock);
43030 if (!intransit)
43031 - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
43032 + ret = (tmem_pamops->repatriate)(old_pampd, new_pampd, pool,
43033 oidp, index, free, data);
43034 if (ret == -EAGAIN) {
43035 /* rare I think, but should cond_resched()??? */
43036 @@ -714,7 +714,7 @@ int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
43037 new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
43038 /* if we bug here, pamops wasn't properly set up for ramster */
43039 BUG_ON(tmem_pamops.replace_in_obj == NULL);
43040 - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
43041 + ret = (tmem_pamops->replace_in_obj)(new_pampd, obj);
43042 out:
43043 spin_unlock(&hb->lock);
43044 return ret;
43045 @@ -776,15 +776,15 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43046 if (free) {
43047 if (obj->pampd_count == 0) {
43048 tmem_obj_free(obj, hb);
43049 - (*tmem_hostops.obj_free)(obj, pool);
43050 + (tmem_hostops->obj_free)(obj, pool);
43051 obj = NULL;
43052 }
43053 }
43054 if (free)
43055 - ret = (*tmem_pamops.get_data_and_free)(
43056 + ret = (tmem_pamops->get_data_and_free)(
43057 data, sizep, raw, pampd, pool, oidp, index);
43058 else
43059 - ret = (*tmem_pamops.get_data)(
43060 + ret = (tmem_pamops->get_data)(
43061 data, sizep, raw, pampd, pool, oidp, index);
43062 if (ret < 0)
43063 goto out;
43064 @@ -816,10 +816,10 @@ int tmem_flush_page(struct tmem_pool *pool,
43065 pampd = tmem_pampd_delete_from_obj(obj, index);
43066 if (pampd == NULL)
43067 goto out;
43068 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43069 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43070 if (obj->pampd_count == 0) {
43071 tmem_obj_free(obj, hb);
43072 - (*tmem_hostops.obj_free)(obj, pool);
43073 + (tmem_hostops->obj_free)(obj, pool);
43074 }
43075 ret = 0;
43076
43077 @@ -844,7 +844,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
43078 goto out;
43079 tmem_pampd_destroy_all_in_obj(obj, false);
43080 tmem_obj_free(obj, hb);
43081 - (*tmem_hostops.obj_free)(obj, pool);
43082 + (tmem_hostops->obj_free)(obj, pool);
43083 ret = 0;
43084
43085 out:
43086 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
43087 index dc23395..cf7e9b1 100644
43088 --- a/drivers/staging/rtl8712/rtl871x_io.h
43089 +++ b/drivers/staging/rtl8712/rtl871x_io.h
43090 @@ -108,7 +108,7 @@ struct _io_ops {
43091 u8 *pmem);
43092 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
43093 u8 *pmem);
43094 -};
43095 +} __no_const;
43096
43097 struct io_req {
43098 struct list_head list;
43099 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
43100 index 1f5088b..0e59820 100644
43101 --- a/drivers/staging/sbe-2t3e3/netdev.c
43102 +++ b/drivers/staging/sbe-2t3e3/netdev.c
43103 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43104 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43105
43106 if (rlen)
43107 - if (copy_to_user(data, &resp, rlen))
43108 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43109 return -EFAULT;
43110
43111 return 0;
43112 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43113 index 5dddc4d..34fcb2f 100644
43114 --- a/drivers/staging/usbip/vhci.h
43115 +++ b/drivers/staging/usbip/vhci.h
43116 @@ -83,7 +83,7 @@ struct vhci_hcd {
43117 unsigned resuming:1;
43118 unsigned long re_timeout;
43119
43120 - atomic_t seqnum;
43121 + atomic_unchecked_t seqnum;
43122
43123 /*
43124 * NOTE:
43125 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43126 index c3aa219..bf8b3de 100644
43127 --- a/drivers/staging/usbip/vhci_hcd.c
43128 +++ b/drivers/staging/usbip/vhci_hcd.c
43129 @@ -451,7 +451,7 @@ static void vhci_tx_urb(struct urb *urb)
43130 return;
43131 }
43132
43133 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43134 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43135 if (priv->seqnum == 0xffff)
43136 dev_info(&urb->dev->dev, "seqnum max\n");
43137
43138 @@ -703,7 +703,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43139 return -ENOMEM;
43140 }
43141
43142 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43143 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43144 if (unlink->seqnum == 0xffff)
43145 pr_info("seqnum max\n");
43146
43147 @@ -907,7 +907,7 @@ static int vhci_start(struct usb_hcd *hcd)
43148 vdev->rhport = rhport;
43149 }
43150
43151 - atomic_set(&vhci->seqnum, 0);
43152 + atomic_set_unchecked(&vhci->seqnum, 0);
43153 spin_lock_init(&vhci->lock);
43154
43155 hcd->power_budget = 0; /* no limit */
43156 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43157 index ba5f1c0..11d8122 100644
43158 --- a/drivers/staging/usbip/vhci_rx.c
43159 +++ b/drivers/staging/usbip/vhci_rx.c
43160 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43161 if (!urb) {
43162 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43163 pr_info("max seqnum %d\n",
43164 - atomic_read(&the_controller->seqnum));
43165 + atomic_read_unchecked(&the_controller->seqnum));
43166 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43167 return;
43168 }
43169 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43170 index 5f13890..36a044b 100644
43171 --- a/drivers/staging/vt6655/hostap.c
43172 +++ b/drivers/staging/vt6655/hostap.c
43173 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
43174 *
43175 */
43176
43177 +static net_device_ops_no_const apdev_netdev_ops;
43178 +
43179 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43180 {
43181 PSDevice apdev_priv;
43182 struct net_device *dev = pDevice->dev;
43183 int ret;
43184 - const struct net_device_ops apdev_netdev_ops = {
43185 - .ndo_start_xmit = pDevice->tx_80211,
43186 - };
43187
43188 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43189
43190 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43191 *apdev_priv = *pDevice;
43192 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43193
43194 + /* only half broken now */
43195 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43196 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43197
43198 pDevice->apdev->type = ARPHRD_IEEE80211;
43199 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43200 index 26a7d0e..897b083 100644
43201 --- a/drivers/staging/vt6656/hostap.c
43202 +++ b/drivers/staging/vt6656/hostap.c
43203 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43204 *
43205 */
43206
43207 +static net_device_ops_no_const apdev_netdev_ops;
43208 +
43209 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43210 {
43211 PSDevice apdev_priv;
43212 struct net_device *dev = pDevice->dev;
43213 int ret;
43214 - const struct net_device_ops apdev_netdev_ops = {
43215 - .ndo_start_xmit = pDevice->tx_80211,
43216 - };
43217
43218 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43219
43220 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43221 *apdev_priv = *pDevice;
43222 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43223
43224 + /* only half broken now */
43225 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43226 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43227
43228 pDevice->apdev->type = ARPHRD_IEEE80211;
43229 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43230 index 56c8e60..1920c63 100644
43231 --- a/drivers/staging/zcache/tmem.c
43232 +++ b/drivers/staging/zcache/tmem.c
43233 @@ -39,7 +39,7 @@
43234 * A tmem host implementation must use this function to register callbacks
43235 * for memory allocation.
43236 */
43237 -static struct tmem_hostops tmem_hostops;
43238 +static tmem_hostops_no_const tmem_hostops;
43239
43240 static void tmem_objnode_tree_init(void);
43241
43242 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43243 * A tmem host implementation must use this function to register
43244 * callbacks for a page-accessible memory (PAM) implementation
43245 */
43246 -static struct tmem_pamops tmem_pamops;
43247 +static tmem_pamops_no_const tmem_pamops;
43248
43249 void tmem_register_pamops(struct tmem_pamops *m)
43250 {
43251 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43252 index 0d4aa82..f7832d4 100644
43253 --- a/drivers/staging/zcache/tmem.h
43254 +++ b/drivers/staging/zcache/tmem.h
43255 @@ -180,6 +180,7 @@ struct tmem_pamops {
43256 void (*new_obj)(struct tmem_obj *);
43257 int (*replace_in_obj)(void *, struct tmem_obj *);
43258 };
43259 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43260 extern void tmem_register_pamops(struct tmem_pamops *m);
43261
43262 /* memory allocation methods provided by the host implementation */
43263 @@ -189,6 +190,7 @@ struct tmem_hostops {
43264 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43265 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43266 };
43267 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43268 extern void tmem_register_hostops(struct tmem_hostops *m);
43269
43270 /* core tmem accessor functions */
43271 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43272 index 96f4981..4daaa7e 100644
43273 --- a/drivers/target/target_core_device.c
43274 +++ b/drivers/target/target_core_device.c
43275 @@ -1370,7 +1370,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43276 spin_lock_init(&dev->se_port_lock);
43277 spin_lock_init(&dev->se_tmr_lock);
43278 spin_lock_init(&dev->qf_cmd_lock);
43279 - atomic_set(&dev->dev_ordered_id, 0);
43280 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43281 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43282 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43283 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43284 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43285 index fcf880f..a4d1e8f 100644
43286 --- a/drivers/target/target_core_transport.c
43287 +++ b/drivers/target/target_core_transport.c
43288 @@ -1077,7 +1077,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43289 * Used to determine when ORDERED commands should go from
43290 * Dormant to Active status.
43291 */
43292 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43293 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43294 smp_mb__after_atomic_inc();
43295 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43296 cmd->se_ordered_id, cmd->sam_task_attr,
43297 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43298 index b09c8d1f..c4225c0 100644
43299 --- a/drivers/tty/cyclades.c
43300 +++ b/drivers/tty/cyclades.c
43301 @@ -1589,10 +1589,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43302 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43303 info->port.count);
43304 #endif
43305 - info->port.count++;
43306 + atomic_inc(&info->port.count);
43307 #ifdef CY_DEBUG_COUNT
43308 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43309 - current->pid, info->port.count);
43310 + current->pid, atomic_read(&info->port.count));
43311 #endif
43312
43313 /*
43314 @@ -3991,7 +3991,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43315 for (j = 0; j < cy_card[i].nports; j++) {
43316 info = &cy_card[i].ports[j];
43317
43318 - if (info->port.count) {
43319 + if (atomic_read(&info->port.count)) {
43320 /* XXX is the ldisc num worth this? */
43321 struct tty_struct *tty;
43322 struct tty_ldisc *ld;
43323 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43324 index 13ee53b..418d164 100644
43325 --- a/drivers/tty/hvc/hvc_console.c
43326 +++ b/drivers/tty/hvc/hvc_console.c
43327 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43328
43329 spin_lock_irqsave(&hp->port.lock, flags);
43330 /* Check and then increment for fast path open. */
43331 - if (hp->port.count++ > 0) {
43332 + if (atomic_inc_return(&hp->port.count) > 1) {
43333 spin_unlock_irqrestore(&hp->port.lock, flags);
43334 hvc_kick();
43335 return 0;
43336 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43337
43338 spin_lock_irqsave(&hp->port.lock, flags);
43339
43340 - if (--hp->port.count == 0) {
43341 + if (atomic_dec_return(&hp->port.count) == 0) {
43342 spin_unlock_irqrestore(&hp->port.lock, flags);
43343 /* We are done with the tty pointer now. */
43344 tty_port_tty_set(&hp->port, NULL);
43345 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43346 */
43347 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43348 } else {
43349 - if (hp->port.count < 0)
43350 + if (atomic_read(&hp->port.count) < 0)
43351 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43352 - hp->vtermno, hp->port.count);
43353 + hp->vtermno, atomic_read(&hp->port.count));
43354 spin_unlock_irqrestore(&hp->port.lock, flags);
43355 }
43356 }
43357 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43358 * open->hangup case this can be called after the final close so prevent
43359 * that from happening for now.
43360 */
43361 - if (hp->port.count <= 0) {
43362 + if (atomic_read(&hp->port.count) <= 0) {
43363 spin_unlock_irqrestore(&hp->port.lock, flags);
43364 return;
43365 }
43366
43367 - hp->port.count = 0;
43368 + atomic_set(&hp->port.count, 0);
43369 spin_unlock_irqrestore(&hp->port.lock, flags);
43370 tty_port_tty_set(&hp->port, NULL);
43371
43372 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43373 return -EPIPE;
43374
43375 /* FIXME what's this (unprotected) check for? */
43376 - if (hp->port.count <= 0)
43377 + if (atomic_read(&hp->port.count) <= 0)
43378 return -EIO;
43379
43380 spin_lock_irqsave(&hp->lock, flags);
43381 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43382 index 8776357..b2d4afd 100644
43383 --- a/drivers/tty/hvc/hvcs.c
43384 +++ b/drivers/tty/hvc/hvcs.c
43385 @@ -83,6 +83,7 @@
43386 #include <asm/hvcserver.h>
43387 #include <asm/uaccess.h>
43388 #include <asm/vio.h>
43389 +#include <asm/local.h>
43390
43391 /*
43392 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43393 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43394
43395 spin_lock_irqsave(&hvcsd->lock, flags);
43396
43397 - if (hvcsd->port.count > 0) {
43398 + if (atomic_read(&hvcsd->port.count) > 0) {
43399 spin_unlock_irqrestore(&hvcsd->lock, flags);
43400 printk(KERN_INFO "HVCS: vterm state unchanged. "
43401 "The hvcs device node is still in use.\n");
43402 @@ -1132,7 +1133,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43403 }
43404 }
43405
43406 - hvcsd->port.count = 0;
43407 + atomic_set(&hvcsd->port.count, 0);
43408 hvcsd->port.tty = tty;
43409 tty->driver_data = hvcsd;
43410
43411 @@ -1185,7 +1186,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43412 unsigned long flags;
43413
43414 spin_lock_irqsave(&hvcsd->lock, flags);
43415 - hvcsd->port.count++;
43416 + atomic_inc(&hvcsd->port.count);
43417 hvcsd->todo_mask |= HVCS_SCHED_READ;
43418 spin_unlock_irqrestore(&hvcsd->lock, flags);
43419
43420 @@ -1221,7 +1222,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43421 hvcsd = tty->driver_data;
43422
43423 spin_lock_irqsave(&hvcsd->lock, flags);
43424 - if (--hvcsd->port.count == 0) {
43425 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43426
43427 vio_disable_interrupts(hvcsd->vdev);
43428
43429 @@ -1246,10 +1247,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43430
43431 free_irq(irq, hvcsd);
43432 return;
43433 - } else if (hvcsd->port.count < 0) {
43434 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43435 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43436 " is missmanaged.\n",
43437 - hvcsd->vdev->unit_address, hvcsd->port.count);
43438 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43439 }
43440
43441 spin_unlock_irqrestore(&hvcsd->lock, flags);
43442 @@ -1271,7 +1272,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43443
43444 spin_lock_irqsave(&hvcsd->lock, flags);
43445 /* Preserve this so that we know how many kref refs to put */
43446 - temp_open_count = hvcsd->port.count;
43447 + temp_open_count = atomic_read(&hvcsd->port.count);
43448
43449 /*
43450 * Don't kref put inside the spinlock because the destruction
43451 @@ -1286,7 +1287,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43452 tty->driver_data = NULL;
43453 hvcsd->port.tty = NULL;
43454
43455 - hvcsd->port.count = 0;
43456 + atomic_set(&hvcsd->port.count, 0);
43457
43458 /* This will drop any buffered data on the floor which is OK in a hangup
43459 * scenario. */
43460 @@ -1357,7 +1358,7 @@ static int hvcs_write(struct tty_struct *tty,
43461 * the middle of a write operation? This is a crummy place to do this
43462 * but we want to keep it all in the spinlock.
43463 */
43464 - if (hvcsd->port.count <= 0) {
43465 + if (atomic_read(&hvcsd->port.count) <= 0) {
43466 spin_unlock_irqrestore(&hvcsd->lock, flags);
43467 return -ENODEV;
43468 }
43469 @@ -1431,7 +1432,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43470 {
43471 struct hvcs_struct *hvcsd = tty->driver_data;
43472
43473 - if (!hvcsd || hvcsd->port.count <= 0)
43474 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43475 return 0;
43476
43477 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43478 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43479 index 2cde13d..645d78f 100644
43480 --- a/drivers/tty/ipwireless/tty.c
43481 +++ b/drivers/tty/ipwireless/tty.c
43482 @@ -29,6 +29,7 @@
43483 #include <linux/tty_driver.h>
43484 #include <linux/tty_flip.h>
43485 #include <linux/uaccess.h>
43486 +#include <asm/local.h>
43487
43488 #include "tty.h"
43489 #include "network.h"
43490 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43491 mutex_unlock(&tty->ipw_tty_mutex);
43492 return -ENODEV;
43493 }
43494 - if (tty->port.count == 0)
43495 + if (atomic_read(&tty->port.count) == 0)
43496 tty->tx_bytes_queued = 0;
43497
43498 - tty->port.count++;
43499 + atomic_inc(&tty->port.count);
43500
43501 tty->port.tty = linux_tty;
43502 linux_tty->driver_data = tty;
43503 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43504
43505 static void do_ipw_close(struct ipw_tty *tty)
43506 {
43507 - tty->port.count--;
43508 -
43509 - if (tty->port.count == 0) {
43510 + if (atomic_dec_return(&tty->port.count) == 0) {
43511 struct tty_struct *linux_tty = tty->port.tty;
43512
43513 if (linux_tty != NULL) {
43514 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43515 return;
43516
43517 mutex_lock(&tty->ipw_tty_mutex);
43518 - if (tty->port.count == 0) {
43519 + if (atomic_read(&tty->port.count) == 0) {
43520 mutex_unlock(&tty->ipw_tty_mutex);
43521 return;
43522 }
43523 @@ -170,7 +169,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43524 return;
43525 }
43526
43527 - if (!tty->port.count) {
43528 + if (!atomic_read(&tty->port.count)) {
43529 mutex_unlock(&tty->ipw_tty_mutex);
43530 return;
43531 }
43532 @@ -212,7 +211,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43533 return -ENODEV;
43534
43535 mutex_lock(&tty->ipw_tty_mutex);
43536 - if (!tty->port.count) {
43537 + if (!atomic_read(&tty->port.count)) {
43538 mutex_unlock(&tty->ipw_tty_mutex);
43539 return -EINVAL;
43540 }
43541 @@ -252,7 +251,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43542 if (!tty)
43543 return -ENODEV;
43544
43545 - if (!tty->port.count)
43546 + if (!atomic_read(&tty->port.count))
43547 return -EINVAL;
43548
43549 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43550 @@ -294,7 +293,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43551 if (!tty)
43552 return 0;
43553
43554 - if (!tty->port.count)
43555 + if (!atomic_read(&tty->port.count))
43556 return 0;
43557
43558 return tty->tx_bytes_queued;
43559 @@ -375,7 +374,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43560 if (!tty)
43561 return -ENODEV;
43562
43563 - if (!tty->port.count)
43564 + if (!atomic_read(&tty->port.count))
43565 return -EINVAL;
43566
43567 return get_control_lines(tty);
43568 @@ -391,7 +390,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43569 if (!tty)
43570 return -ENODEV;
43571
43572 - if (!tty->port.count)
43573 + if (!atomic_read(&tty->port.count))
43574 return -EINVAL;
43575
43576 return set_control_lines(tty, set, clear);
43577 @@ -405,7 +404,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43578 if (!tty)
43579 return -ENODEV;
43580
43581 - if (!tty->port.count)
43582 + if (!atomic_read(&tty->port.count))
43583 return -EINVAL;
43584
43585 /* FIXME: Exactly how is the tty object locked here .. */
43586 @@ -561,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43587 * are gone */
43588 mutex_lock(&ttyj->ipw_tty_mutex);
43589 }
43590 - while (ttyj->port.count)
43591 + while (atomic_read(&ttyj->port.count))
43592 do_ipw_close(ttyj);
43593 ipwireless_disassociate_network_ttys(network,
43594 ttyj->channel_idx);
43595 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43596 index f9d2850..b006f04 100644
43597 --- a/drivers/tty/moxa.c
43598 +++ b/drivers/tty/moxa.c
43599 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43600 }
43601
43602 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43603 - ch->port.count++;
43604 + atomic_inc(&ch->port.count);
43605 tty->driver_data = ch;
43606 tty_port_tty_set(&ch->port, tty);
43607 mutex_lock(&ch->port.mutex);
43608 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43609 index bfd6771..e0d93c4 100644
43610 --- a/drivers/tty/n_gsm.c
43611 +++ b/drivers/tty/n_gsm.c
43612 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43613 spin_lock_init(&dlci->lock);
43614 mutex_init(&dlci->mutex);
43615 dlci->fifo = &dlci->_fifo;
43616 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43617 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43618 kfree(dlci);
43619 return NULL;
43620 }
43621 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43622 struct gsm_dlci *dlci = tty->driver_data;
43623 struct tty_port *port = &dlci->port;
43624
43625 - port->count++;
43626 + atomic_inc(&port->count);
43627 dlci_get(dlci);
43628 dlci_get(dlci->gsm->dlci[0]);
43629 mux_get(dlci->gsm);
43630 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43631 index 19083ef..6e34e97 100644
43632 --- a/drivers/tty/n_tty.c
43633 +++ b/drivers/tty/n_tty.c
43634 @@ -2196,6 +2196,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43635 {
43636 *ops = tty_ldisc_N_TTY;
43637 ops->owner = NULL;
43638 - ops->refcount = ops->flags = 0;
43639 + atomic_set(&ops->refcount, 0);
43640 + ops->flags = 0;
43641 }
43642 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43643 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43644 index ac35c90..c47deac 100644
43645 --- a/drivers/tty/pty.c
43646 +++ b/drivers/tty/pty.c
43647 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
43648 panic("Couldn't register Unix98 pts driver");
43649
43650 /* Now create the /dev/ptmx special device */
43651 + pax_open_kernel();
43652 tty_default_fops(&ptmx_fops);
43653 - ptmx_fops.open = ptmx_open;
43654 + *(void **)&ptmx_fops.open = ptmx_open;
43655 + pax_close_kernel();
43656
43657 cdev_init(&ptmx_cdev, &ptmx_fops);
43658 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43659 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43660 index e42009a..566a036 100644
43661 --- a/drivers/tty/rocket.c
43662 +++ b/drivers/tty/rocket.c
43663 @@ -925,7 +925,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43664 tty->driver_data = info;
43665 tty_port_tty_set(port, tty);
43666
43667 - if (port->count++ == 0) {
43668 + if (atomic_inc_return(&port->count) == 1) {
43669 atomic_inc(&rp_num_ports_open);
43670
43671 #ifdef ROCKET_DEBUG_OPEN
43672 @@ -934,7 +934,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43673 #endif
43674 }
43675 #ifdef ROCKET_DEBUG_OPEN
43676 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43677 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43678 #endif
43679
43680 /*
43681 @@ -1529,7 +1529,7 @@ static void rp_hangup(struct tty_struct *tty)
43682 spin_unlock_irqrestore(&info->port.lock, flags);
43683 return;
43684 }
43685 - if (info->port.count)
43686 + if (atomic_read(&info->port.count))
43687 atomic_dec(&rp_num_ports_open);
43688 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43689 spin_unlock_irqrestore(&info->port.lock, flags);
43690 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43691 index 1002054..dd644a8 100644
43692 --- a/drivers/tty/serial/kgdboc.c
43693 +++ b/drivers/tty/serial/kgdboc.c
43694 @@ -24,8 +24,9 @@
43695 #define MAX_CONFIG_LEN 40
43696
43697 static struct kgdb_io kgdboc_io_ops;
43698 +static struct kgdb_io kgdboc_io_ops_console;
43699
43700 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43701 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43702 static int configured = -1;
43703
43704 static char config[MAX_CONFIG_LEN];
43705 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43706 kgdboc_unregister_kbd();
43707 if (configured == 1)
43708 kgdb_unregister_io_module(&kgdboc_io_ops);
43709 + else if (configured == 2)
43710 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43711 }
43712
43713 static int configure_kgdboc(void)
43714 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43715 int err;
43716 char *cptr = config;
43717 struct console *cons;
43718 + int is_console = 0;
43719
43720 err = kgdboc_option_setup(config);
43721 if (err || !strlen(config) || isspace(config[0]))
43722 goto noconfig;
43723
43724 err = -ENODEV;
43725 - kgdboc_io_ops.is_console = 0;
43726 kgdb_tty_driver = NULL;
43727
43728 kgdboc_use_kms = 0;
43729 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43730 int idx;
43731 if (cons->device && cons->device(cons, &idx) == p &&
43732 idx == tty_line) {
43733 - kgdboc_io_ops.is_console = 1;
43734 + is_console = 1;
43735 break;
43736 }
43737 cons = cons->next;
43738 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43739 kgdb_tty_line = tty_line;
43740
43741 do_register:
43742 - err = kgdb_register_io_module(&kgdboc_io_ops);
43743 + if (is_console) {
43744 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43745 + configured = 2;
43746 + } else {
43747 + err = kgdb_register_io_module(&kgdboc_io_ops);
43748 + configured = 1;
43749 + }
43750 if (err)
43751 goto noconfig;
43752
43753 @@ -205,8 +214,6 @@ do_register:
43754 if (err)
43755 goto nmi_con_failed;
43756
43757 - configured = 1;
43758 -
43759 return 0;
43760
43761 nmi_con_failed:
43762 @@ -223,7 +230,7 @@ noconfig:
43763 static int __init init_kgdboc(void)
43764 {
43765 /* Already configured? */
43766 - if (configured == 1)
43767 + if (configured >= 1)
43768 return 0;
43769
43770 return configure_kgdboc();
43771 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43772 if (config[len - 1] == '\n')
43773 config[len - 1] = '\0';
43774
43775 - if (configured == 1)
43776 + if (configured >= 1)
43777 cleanup_kgdboc();
43778
43779 /* Go and configure with the new params. */
43780 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43781 .post_exception = kgdboc_post_exp_handler,
43782 };
43783
43784 +static struct kgdb_io kgdboc_io_ops_console = {
43785 + .name = "kgdboc",
43786 + .read_char = kgdboc_get_char,
43787 + .write_char = kgdboc_put_char,
43788 + .pre_exception = kgdboc_pre_exp_handler,
43789 + .post_exception = kgdboc_post_exp_handler,
43790 + .is_console = 1
43791 +};
43792 +
43793 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43794 /* This is only available if kgdboc is a built in for early debugging */
43795 static int __init kgdboc_early_init(char *opt)
43796 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43797 index e514b3a..c73d614 100644
43798 --- a/drivers/tty/serial/samsung.c
43799 +++ b/drivers/tty/serial/samsung.c
43800 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43801 }
43802 }
43803
43804 +static int s3c64xx_serial_startup(struct uart_port *port);
43805 static int s3c24xx_serial_startup(struct uart_port *port)
43806 {
43807 struct s3c24xx_uart_port *ourport = to_ourport(port);
43808 int ret;
43809
43810 + /* Startup sequence is different for s3c64xx and higher SoC's */
43811 + if (s3c24xx_serial_has_interrupt_mask(port))
43812 + return s3c64xx_serial_startup(port);
43813 +
43814 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43815 port->mapbase, port->membase);
43816
43817 @@ -1122,10 +1127,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43818 /* setup info for port */
43819 port->dev = &platdev->dev;
43820
43821 - /* Startup sequence is different for s3c64xx and higher SoC's */
43822 - if (s3c24xx_serial_has_interrupt_mask(port))
43823 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43824 -
43825 port->uartclk = 1;
43826
43827 if (cfg->uart_flags & UPF_CONS_FLOW) {
43828 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43829 index 2c7230a..2104f16 100644
43830 --- a/drivers/tty/serial/serial_core.c
43831 +++ b/drivers/tty/serial/serial_core.c
43832 @@ -1455,7 +1455,7 @@ static void uart_hangup(struct tty_struct *tty)
43833 uart_flush_buffer(tty);
43834 uart_shutdown(tty, state);
43835 spin_lock_irqsave(&port->lock, flags);
43836 - port->count = 0;
43837 + atomic_set(&port->count, 0);
43838 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43839 spin_unlock_irqrestore(&port->lock, flags);
43840 tty_port_tty_set(port, NULL);
43841 @@ -1551,7 +1551,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43842 goto end;
43843 }
43844
43845 - port->count++;
43846 + atomic_inc(&port->count);
43847 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43848 retval = -ENXIO;
43849 goto err_dec_count;
43850 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43851 /*
43852 * Make sure the device is in D0 state.
43853 */
43854 - if (port->count == 1)
43855 + if (atomic_read(&port->count) == 1)
43856 uart_change_pm(state, 0);
43857
43858 /*
43859 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43860 end:
43861 return retval;
43862 err_dec_count:
43863 - port->count--;
43864 + atomic_inc(&port->count);
43865 mutex_unlock(&port->mutex);
43866 goto end;
43867 }
43868 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43869 index 9e071f6..f30ae69 100644
43870 --- a/drivers/tty/synclink.c
43871 +++ b/drivers/tty/synclink.c
43872 @@ -3095,7 +3095,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43873
43874 if (debug_level >= DEBUG_LEVEL_INFO)
43875 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43876 - __FILE__,__LINE__, info->device_name, info->port.count);
43877 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43878
43879 if (tty_port_close_start(&info->port, tty, filp) == 0)
43880 goto cleanup;
43881 @@ -3113,7 +3113,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43882 cleanup:
43883 if (debug_level >= DEBUG_LEVEL_INFO)
43884 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43885 - tty->driver->name, info->port.count);
43886 + tty->driver->name, atomic_read(&info->port.count));
43887
43888 } /* end of mgsl_close() */
43889
43890 @@ -3212,8 +3212,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43891
43892 mgsl_flush_buffer(tty);
43893 shutdown(info);
43894 -
43895 - info->port.count = 0;
43896 +
43897 + atomic_set(&info->port.count, 0);
43898 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43899 info->port.tty = NULL;
43900
43901 @@ -3302,12 +3302,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43902
43903 if (debug_level >= DEBUG_LEVEL_INFO)
43904 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43905 - __FILE__,__LINE__, tty->driver->name, port->count );
43906 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43907
43908 spin_lock_irqsave(&info->irq_spinlock, flags);
43909 if (!tty_hung_up_p(filp)) {
43910 extra_count = true;
43911 - port->count--;
43912 + atomic_dec(&port->count);
43913 }
43914 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43915 port->blocked_open++;
43916 @@ -3336,7 +3336,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43917
43918 if (debug_level >= DEBUG_LEVEL_INFO)
43919 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43920 - __FILE__,__LINE__, tty->driver->name, port->count );
43921 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43922
43923 tty_unlock(tty);
43924 schedule();
43925 @@ -3348,12 +3348,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43926
43927 /* FIXME: Racy on hangup during close wait */
43928 if (extra_count)
43929 - port->count++;
43930 + atomic_inc(&port->count);
43931 port->blocked_open--;
43932
43933 if (debug_level >= DEBUG_LEVEL_INFO)
43934 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43935 - __FILE__,__LINE__, tty->driver->name, port->count );
43936 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43937
43938 if (!retval)
43939 port->flags |= ASYNC_NORMAL_ACTIVE;
43940 @@ -3405,7 +3405,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43941
43942 if (debug_level >= DEBUG_LEVEL_INFO)
43943 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43944 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43945 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43946
43947 /* If port is closing, signal caller to try again */
43948 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43949 @@ -3424,10 +3424,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43950 spin_unlock_irqrestore(&info->netlock, flags);
43951 goto cleanup;
43952 }
43953 - info->port.count++;
43954 + atomic_inc(&info->port.count);
43955 spin_unlock_irqrestore(&info->netlock, flags);
43956
43957 - if (info->port.count == 1) {
43958 + if (atomic_read(&info->port.count) == 1) {
43959 /* 1st open on this device, init hardware */
43960 retval = startup(info);
43961 if (retval < 0)
43962 @@ -3451,8 +3451,8 @@ cleanup:
43963 if (retval) {
43964 if (tty->count == 1)
43965 info->port.tty = NULL; /* tty layer will release tty struct */
43966 - if(info->port.count)
43967 - info->port.count--;
43968 + if (atomic_read(&info->port.count))
43969 + atomic_dec(&info->port.count);
43970 }
43971
43972 return retval;
43973 @@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43974 unsigned short new_crctype;
43975
43976 /* return error if TTY interface open */
43977 - if (info->port.count)
43978 + if (atomic_read(&info->port.count))
43979 return -EBUSY;
43980
43981 switch (encoding)
43982 @@ -7757,7 +7757,7 @@ static int hdlcdev_open(struct net_device *dev)
43983
43984 /* arbitrate between network and tty opens */
43985 spin_lock_irqsave(&info->netlock, flags);
43986 - if (info->port.count != 0 || info->netcount != 0) {
43987 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43988 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43989 spin_unlock_irqrestore(&info->netlock, flags);
43990 return -EBUSY;
43991 @@ -7843,7 +7843,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43992 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43993
43994 /* return error if TTY interface open */
43995 - if (info->port.count)
43996 + if (atomic_read(&info->port.count))
43997 return -EBUSY;
43998
43999 if (cmd != SIOCWANDEV)
44000 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
44001 index aba1e59..877ac33 100644
44002 --- a/drivers/tty/synclink_gt.c
44003 +++ b/drivers/tty/synclink_gt.c
44004 @@ -671,7 +671,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44005 tty->driver_data = info;
44006 info->port.tty = tty;
44007
44008 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
44009 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
44010
44011 /* If port is closing, signal caller to try again */
44012 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44013 @@ -692,10 +692,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44014 mutex_unlock(&info->port.mutex);
44015 goto cleanup;
44016 }
44017 - info->port.count++;
44018 + atomic_inc(&info->port.count);
44019 spin_unlock_irqrestore(&info->netlock, flags);
44020
44021 - if (info->port.count == 1) {
44022 + if (atomic_read(&info->port.count) == 1) {
44023 /* 1st open on this device, init hardware */
44024 retval = startup(info);
44025 if (retval < 0) {
44026 @@ -716,8 +716,8 @@ cleanup:
44027 if (retval) {
44028 if (tty->count == 1)
44029 info->port.tty = NULL; /* tty layer will release tty struct */
44030 - if(info->port.count)
44031 - info->port.count--;
44032 + if(atomic_read(&info->port.count))
44033 + atomic_dec(&info->port.count);
44034 }
44035
44036 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
44037 @@ -730,7 +730,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44038
44039 if (sanity_check(info, tty->name, "close"))
44040 return;
44041 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
44042 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
44043
44044 if (tty_port_close_start(&info->port, tty, filp) == 0)
44045 goto cleanup;
44046 @@ -747,7 +747,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44047 tty_port_close_end(&info->port, tty);
44048 info->port.tty = NULL;
44049 cleanup:
44050 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
44051 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
44052 }
44053
44054 static void hangup(struct tty_struct *tty)
44055 @@ -765,7 +765,7 @@ static void hangup(struct tty_struct *tty)
44056 shutdown(info);
44057
44058 spin_lock_irqsave(&info->port.lock, flags);
44059 - info->port.count = 0;
44060 + atomic_set(&info->port.count, 0);
44061 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44062 info->port.tty = NULL;
44063 spin_unlock_irqrestore(&info->port.lock, flags);
44064 @@ -1450,7 +1450,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44065 unsigned short new_crctype;
44066
44067 /* return error if TTY interface open */
44068 - if (info->port.count)
44069 + if (atomic_read(&info->port.count))
44070 return -EBUSY;
44071
44072 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
44073 @@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
44074
44075 /* arbitrate between network and tty opens */
44076 spin_lock_irqsave(&info->netlock, flags);
44077 - if (info->port.count != 0 || info->netcount != 0) {
44078 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44079 DBGINFO(("%s hdlc_open busy\n", dev->name));
44080 spin_unlock_irqrestore(&info->netlock, flags);
44081 return -EBUSY;
44082 @@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44083 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
44084
44085 /* return error if TTY interface open */
44086 - if (info->port.count)
44087 + if (atomic_read(&info->port.count))
44088 return -EBUSY;
44089
44090 if (cmd != SIOCWANDEV)
44091 @@ -2419,7 +2419,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
44092 if (port == NULL)
44093 continue;
44094 spin_lock(&port->lock);
44095 - if ((port->port.count || port->netcount) &&
44096 + if ((atomic_read(&port->port.count) || port->netcount) &&
44097 port->pending_bh && !port->bh_running &&
44098 !port->bh_requested) {
44099 DBGISR(("%s bh queued\n", port->device_name));
44100 @@ -3308,7 +3308,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44101 spin_lock_irqsave(&info->lock, flags);
44102 if (!tty_hung_up_p(filp)) {
44103 extra_count = true;
44104 - port->count--;
44105 + atomic_dec(&port->count);
44106 }
44107 spin_unlock_irqrestore(&info->lock, flags);
44108 port->blocked_open++;
44109 @@ -3345,7 +3345,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44110 remove_wait_queue(&port->open_wait, &wait);
44111
44112 if (extra_count)
44113 - port->count++;
44114 + atomic_inc(&port->count);
44115 port->blocked_open--;
44116
44117 if (!retval)
44118 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44119 index fd43fb6..34704ad 100644
44120 --- a/drivers/tty/synclinkmp.c
44121 +++ b/drivers/tty/synclinkmp.c
44122 @@ -751,7 +751,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44123
44124 if (debug_level >= DEBUG_LEVEL_INFO)
44125 printk("%s(%d):%s open(), old ref count = %d\n",
44126 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44127 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44128
44129 /* If port is closing, signal caller to try again */
44130 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44131 @@ -770,10 +770,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44132 spin_unlock_irqrestore(&info->netlock, flags);
44133 goto cleanup;
44134 }
44135 - info->port.count++;
44136 + atomic_inc(&info->port.count);
44137 spin_unlock_irqrestore(&info->netlock, flags);
44138
44139 - if (info->port.count == 1) {
44140 + if (atomic_read(&info->port.count) == 1) {
44141 /* 1st open on this device, init hardware */
44142 retval = startup(info);
44143 if (retval < 0)
44144 @@ -797,8 +797,8 @@ cleanup:
44145 if (retval) {
44146 if (tty->count == 1)
44147 info->port.tty = NULL; /* tty layer will release tty struct */
44148 - if(info->port.count)
44149 - info->port.count--;
44150 + if(atomic_read(&info->port.count))
44151 + atomic_dec(&info->port.count);
44152 }
44153
44154 return retval;
44155 @@ -816,7 +816,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44156
44157 if (debug_level >= DEBUG_LEVEL_INFO)
44158 printk("%s(%d):%s close() entry, count=%d\n",
44159 - __FILE__,__LINE__, info->device_name, info->port.count);
44160 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44161
44162 if (tty_port_close_start(&info->port, tty, filp) == 0)
44163 goto cleanup;
44164 @@ -835,7 +835,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44165 cleanup:
44166 if (debug_level >= DEBUG_LEVEL_INFO)
44167 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44168 - tty->driver->name, info->port.count);
44169 + tty->driver->name, atomic_read(&info->port.count));
44170 }
44171
44172 /* Called by tty_hangup() when a hangup is signaled.
44173 @@ -858,7 +858,7 @@ static void hangup(struct tty_struct *tty)
44174 shutdown(info);
44175
44176 spin_lock_irqsave(&info->port.lock, flags);
44177 - info->port.count = 0;
44178 + atomic_set(&info->port.count, 0);
44179 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44180 info->port.tty = NULL;
44181 spin_unlock_irqrestore(&info->port.lock, flags);
44182 @@ -1566,7 +1566,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44183 unsigned short new_crctype;
44184
44185 /* return error if TTY interface open */
44186 - if (info->port.count)
44187 + if (atomic_read(&info->port.count))
44188 return -EBUSY;
44189
44190 switch (encoding)
44191 @@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
44192
44193 /* arbitrate between network and tty opens */
44194 spin_lock_irqsave(&info->netlock, flags);
44195 - if (info->port.count != 0 || info->netcount != 0) {
44196 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44197 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44198 spin_unlock_irqrestore(&info->netlock, flags);
44199 return -EBUSY;
44200 @@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44201 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44202
44203 /* return error if TTY interface open */
44204 - if (info->port.count)
44205 + if (atomic_read(&info->port.count))
44206 return -EBUSY;
44207
44208 if (cmd != SIOCWANDEV)
44209 @@ -2632,7 +2632,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44210 * do not request bottom half processing if the
44211 * device is not open in a normal mode.
44212 */
44213 - if ( port && (port->port.count || port->netcount) &&
44214 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44215 port->pending_bh && !port->bh_running &&
44216 !port->bh_requested ) {
44217 if ( debug_level >= DEBUG_LEVEL_ISR )
44218 @@ -3330,12 +3330,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44219
44220 if (debug_level >= DEBUG_LEVEL_INFO)
44221 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44222 - __FILE__,__LINE__, tty->driver->name, port->count );
44223 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44224
44225 spin_lock_irqsave(&info->lock, flags);
44226 if (!tty_hung_up_p(filp)) {
44227 extra_count = true;
44228 - port->count--;
44229 + atomic_dec(&port->count);
44230 }
44231 spin_unlock_irqrestore(&info->lock, flags);
44232 port->blocked_open++;
44233 @@ -3364,7 +3364,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44234
44235 if (debug_level >= DEBUG_LEVEL_INFO)
44236 printk("%s(%d):%s block_til_ready() count=%d\n",
44237 - __FILE__,__LINE__, tty->driver->name, port->count );
44238 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44239
44240 tty_unlock(tty);
44241 schedule();
44242 @@ -3375,12 +3375,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44243 remove_wait_queue(&port->open_wait, &wait);
44244
44245 if (extra_count)
44246 - port->count++;
44247 + atomic_inc(&port->count);
44248 port->blocked_open--;
44249
44250 if (debug_level >= DEBUG_LEVEL_INFO)
44251 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44252 - __FILE__,__LINE__, tty->driver->name, port->count );
44253 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44254
44255 if (!retval)
44256 port->flags |= ASYNC_NORMAL_ACTIVE;
44257 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44258 index b3c4a25..723916f 100644
44259 --- a/drivers/tty/sysrq.c
44260 +++ b/drivers/tty/sysrq.c
44261 @@ -867,7 +867,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44262 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44263 size_t count, loff_t *ppos)
44264 {
44265 - if (count) {
44266 + if (count && capable(CAP_SYS_ADMIN)) {
44267 char c;
44268
44269 if (get_user(c, buf))
44270 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44271 index da9fde8..c07975f 100644
44272 --- a/drivers/tty/tty_io.c
44273 +++ b/drivers/tty/tty_io.c
44274 @@ -3391,7 +3391,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44275
44276 void tty_default_fops(struct file_operations *fops)
44277 {
44278 - *fops = tty_fops;
44279 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44280 }
44281
44282 /*
44283 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44284 index c578229..45aa9ee 100644
44285 --- a/drivers/tty/tty_ldisc.c
44286 +++ b/drivers/tty/tty_ldisc.c
44287 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
44288 if (atomic_dec_and_test(&ld->users)) {
44289 struct tty_ldisc_ops *ldo = ld->ops;
44290
44291 - ldo->refcount--;
44292 + atomic_dec(&ldo->refcount);
44293 module_put(ldo->owner);
44294 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44295
44296 @@ -91,7 +91,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44297 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44298 tty_ldiscs[disc] = new_ldisc;
44299 new_ldisc->num = disc;
44300 - new_ldisc->refcount = 0;
44301 + atomic_set(&new_ldisc->refcount, 0);
44302 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44303
44304 return ret;
44305 @@ -119,7 +119,7 @@ int tty_unregister_ldisc(int disc)
44306 return -EINVAL;
44307
44308 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44309 - if (tty_ldiscs[disc]->refcount)
44310 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44311 ret = -EBUSY;
44312 else
44313 tty_ldiscs[disc] = NULL;
44314 @@ -140,7 +140,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44315 if (ldops) {
44316 ret = ERR_PTR(-EAGAIN);
44317 if (try_module_get(ldops->owner)) {
44318 - ldops->refcount++;
44319 + atomic_inc(&ldops->refcount);
44320 ret = ldops;
44321 }
44322 }
44323 @@ -153,7 +153,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44324 unsigned long flags;
44325
44326 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44327 - ldops->refcount--;
44328 + atomic_dec(&ldops->refcount);
44329 module_put(ldops->owner);
44330 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44331 }
44332 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44333 index b7ff59d..7c6105e 100644
44334 --- a/drivers/tty/tty_port.c
44335 +++ b/drivers/tty/tty_port.c
44336 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
44337 unsigned long flags;
44338
44339 spin_lock_irqsave(&port->lock, flags);
44340 - port->count = 0;
44341 + atomic_set(&port->count, 0);
44342 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44343 if (port->tty) {
44344 set_bit(TTY_IO_ERROR, &port->tty->flags);
44345 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44346 /* The port lock protects the port counts */
44347 spin_lock_irqsave(&port->lock, flags);
44348 if (!tty_hung_up_p(filp))
44349 - port->count--;
44350 + atomic_dec(&port->count);
44351 port->blocked_open++;
44352 spin_unlock_irqrestore(&port->lock, flags);
44353
44354 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44355 we must not mess that up further */
44356 spin_lock_irqsave(&port->lock, flags);
44357 if (!tty_hung_up_p(filp))
44358 - port->count++;
44359 + atomic_inc(&port->count);
44360 port->blocked_open--;
44361 if (retval == 0)
44362 port->flags |= ASYNC_NORMAL_ACTIVE;
44363 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
44364 return 0;
44365 }
44366
44367 - if (tty->count == 1 && port->count != 1) {
44368 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44369 printk(KERN_WARNING
44370 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44371 - port->count);
44372 - port->count = 1;
44373 + atomic_read(&port->count));
44374 + atomic_set(&port->count, 1);
44375 }
44376 - if (--port->count < 0) {
44377 + if (atomic_dec_return(&port->count) < 0) {
44378 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44379 - port->count);
44380 - port->count = 0;
44381 + atomic_read(&port->count));
44382 + atomic_set(&port->count, 0);
44383 }
44384
44385 - if (port->count) {
44386 + if (atomic_read(&port->count)) {
44387 spin_unlock_irqrestore(&port->lock, flags);
44388 if (port->ops->drop)
44389 port->ops->drop(port);
44390 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44391 {
44392 spin_lock_irq(&port->lock);
44393 if (!tty_hung_up_p(filp))
44394 - ++port->count;
44395 + atomic_inc(&port->count);
44396 spin_unlock_irq(&port->lock);
44397 tty_port_tty_set(port, tty);
44398
44399 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44400 index 681765b..d3ccdf2 100644
44401 --- a/drivers/tty/vt/keyboard.c
44402 +++ b/drivers/tty/vt/keyboard.c
44403 @@ -660,6 +660,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44404 kbd->kbdmode == VC_OFF) &&
44405 value != KVAL(K_SAK))
44406 return; /* SAK is allowed even in raw mode */
44407 +
44408 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44409 + {
44410 + void *func = fn_handler[value];
44411 + if (func == fn_show_state || func == fn_show_ptregs ||
44412 + func == fn_show_mem)
44413 + return;
44414 + }
44415 +#endif
44416 +
44417 fn_handler[value](vc);
44418 }
44419
44420 @@ -1808,9 +1818,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44421 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44422 return -EFAULT;
44423
44424 - if (!capable(CAP_SYS_TTY_CONFIG))
44425 - perm = 0;
44426 -
44427 switch (cmd) {
44428 case KDGKBENT:
44429 /* Ensure another thread doesn't free it under us */
44430 @@ -1825,6 +1832,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44431 spin_unlock_irqrestore(&kbd_event_lock, flags);
44432 return put_user(val, &user_kbe->kb_value);
44433 case KDSKBENT:
44434 + if (!capable(CAP_SYS_TTY_CONFIG))
44435 + perm = 0;
44436 +
44437 if (!perm)
44438 return -EPERM;
44439 if (!i && v == K_NOSUCHMAP) {
44440 @@ -1915,9 +1925,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44441 int i, j, k;
44442 int ret;
44443
44444 - if (!capable(CAP_SYS_TTY_CONFIG))
44445 - perm = 0;
44446 -
44447 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44448 if (!kbs) {
44449 ret = -ENOMEM;
44450 @@ -1951,6 +1958,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44451 kfree(kbs);
44452 return ((p && *p) ? -EOVERFLOW : 0);
44453 case KDSKBSENT:
44454 + if (!capable(CAP_SYS_TTY_CONFIG))
44455 + perm = 0;
44456 +
44457 if (!perm) {
44458 ret = -EPERM;
44459 goto reterr;
44460 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44461 index 5110f36..8dc0a74 100644
44462 --- a/drivers/uio/uio.c
44463 +++ b/drivers/uio/uio.c
44464 @@ -25,6 +25,7 @@
44465 #include <linux/kobject.h>
44466 #include <linux/cdev.h>
44467 #include <linux/uio_driver.h>
44468 +#include <asm/local.h>
44469
44470 #define UIO_MAX_DEVICES (1U << MINORBITS)
44471
44472 @@ -32,10 +33,10 @@ struct uio_device {
44473 struct module *owner;
44474 struct device *dev;
44475 int minor;
44476 - atomic_t event;
44477 + atomic_unchecked_t event;
44478 struct fasync_struct *async_queue;
44479 wait_queue_head_t wait;
44480 - int vma_count;
44481 + local_t vma_count;
44482 struct uio_info *info;
44483 struct kobject *map_dir;
44484 struct kobject *portio_dir;
44485 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44486 struct device_attribute *attr, char *buf)
44487 {
44488 struct uio_device *idev = dev_get_drvdata(dev);
44489 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44490 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44491 }
44492
44493 static struct device_attribute uio_class_attributes[] = {
44494 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
44495 {
44496 struct uio_device *idev = info->uio_dev;
44497
44498 - atomic_inc(&idev->event);
44499 + atomic_inc_unchecked(&idev->event);
44500 wake_up_interruptible(&idev->wait);
44501 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44502 }
44503 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44504 }
44505
44506 listener->dev = idev;
44507 - listener->event_count = atomic_read(&idev->event);
44508 + listener->event_count = atomic_read_unchecked(&idev->event);
44509 filep->private_data = listener;
44510
44511 if (idev->info->open) {
44512 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44513 return -EIO;
44514
44515 poll_wait(filep, &idev->wait, wait);
44516 - if (listener->event_count != atomic_read(&idev->event))
44517 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44518 return POLLIN | POLLRDNORM;
44519 return 0;
44520 }
44521 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44522 do {
44523 set_current_state(TASK_INTERRUPTIBLE);
44524
44525 - event_count = atomic_read(&idev->event);
44526 + event_count = atomic_read_unchecked(&idev->event);
44527 if (event_count != listener->event_count) {
44528 if (copy_to_user(buf, &event_count, count))
44529 retval = -EFAULT;
44530 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44531 static void uio_vma_open(struct vm_area_struct *vma)
44532 {
44533 struct uio_device *idev = vma->vm_private_data;
44534 - idev->vma_count++;
44535 + local_inc(&idev->vma_count);
44536 }
44537
44538 static void uio_vma_close(struct vm_area_struct *vma)
44539 {
44540 struct uio_device *idev = vma->vm_private_data;
44541 - idev->vma_count--;
44542 + local_dec(&idev->vma_count);
44543 }
44544
44545 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44546 @@ -819,7 +820,7 @@ int __uio_register_device(struct module *owner,
44547 idev->owner = owner;
44548 idev->info = info;
44549 init_waitqueue_head(&idev->wait);
44550 - atomic_set(&idev->event, 0);
44551 + atomic_set_unchecked(&idev->event, 0);
44552
44553 ret = uio_get_minor(idev);
44554 if (ret)
44555 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44556 index b7eb86a..36d28af 100644
44557 --- a/drivers/usb/atm/cxacru.c
44558 +++ b/drivers/usb/atm/cxacru.c
44559 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44560 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44561 if (ret < 2)
44562 return -EINVAL;
44563 - if (index < 0 || index > 0x7f)
44564 + if (index > 0x7f)
44565 return -EINVAL;
44566 pos += tmp;
44567
44568 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44569 index 35f10bf..6a38a0b 100644
44570 --- a/drivers/usb/atm/usbatm.c
44571 +++ b/drivers/usb/atm/usbatm.c
44572 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44573 if (printk_ratelimit())
44574 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44575 __func__, vpi, vci);
44576 - atomic_inc(&vcc->stats->rx_err);
44577 + atomic_inc_unchecked(&vcc->stats->rx_err);
44578 return;
44579 }
44580
44581 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44582 if (length > ATM_MAX_AAL5_PDU) {
44583 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44584 __func__, length, vcc);
44585 - atomic_inc(&vcc->stats->rx_err);
44586 + atomic_inc_unchecked(&vcc->stats->rx_err);
44587 goto out;
44588 }
44589
44590 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44591 if (sarb->len < pdu_length) {
44592 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44593 __func__, pdu_length, sarb->len, vcc);
44594 - atomic_inc(&vcc->stats->rx_err);
44595 + atomic_inc_unchecked(&vcc->stats->rx_err);
44596 goto out;
44597 }
44598
44599 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44600 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44601 __func__, vcc);
44602 - atomic_inc(&vcc->stats->rx_err);
44603 + atomic_inc_unchecked(&vcc->stats->rx_err);
44604 goto out;
44605 }
44606
44607 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44608 if (printk_ratelimit())
44609 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44610 __func__, length);
44611 - atomic_inc(&vcc->stats->rx_drop);
44612 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44613 goto out;
44614 }
44615
44616 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44617
44618 vcc->push(vcc, skb);
44619
44620 - atomic_inc(&vcc->stats->rx);
44621 + atomic_inc_unchecked(&vcc->stats->rx);
44622 out:
44623 skb_trim(sarb, 0);
44624 }
44625 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44626 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44627
44628 usbatm_pop(vcc, skb);
44629 - atomic_inc(&vcc->stats->tx);
44630 + atomic_inc_unchecked(&vcc->stats->tx);
44631
44632 skb = skb_dequeue(&instance->sndqueue);
44633 }
44634 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44635 if (!left--)
44636 return sprintf(page,
44637 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44638 - atomic_read(&atm_dev->stats.aal5.tx),
44639 - atomic_read(&atm_dev->stats.aal5.tx_err),
44640 - atomic_read(&atm_dev->stats.aal5.rx),
44641 - atomic_read(&atm_dev->stats.aal5.rx_err),
44642 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44643 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44644 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44645 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44646 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44647 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44648
44649 if (!left--) {
44650 if (instance->disconnected)
44651 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44652 index cbacea9..246cccd 100644
44653 --- a/drivers/usb/core/devices.c
44654 +++ b/drivers/usb/core/devices.c
44655 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44656 * time it gets called.
44657 */
44658 static struct device_connect_event {
44659 - atomic_t count;
44660 + atomic_unchecked_t count;
44661 wait_queue_head_t wait;
44662 } device_event = {
44663 .count = ATOMIC_INIT(1),
44664 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44665
44666 void usbfs_conn_disc_event(void)
44667 {
44668 - atomic_add(2, &device_event.count);
44669 + atomic_add_unchecked(2, &device_event.count);
44670 wake_up(&device_event.wait);
44671 }
44672
44673 @@ -645,7 +645,7 @@ static unsigned int usb_device_poll(struct file *file,
44674
44675 poll_wait(file, &device_event.wait, wait);
44676
44677 - event_count = atomic_read(&device_event.count);
44678 + event_count = atomic_read_unchecked(&device_event.count);
44679 if (file->f_version != event_count) {
44680 file->f_version = event_count;
44681 return POLLIN | POLLRDNORM;
44682 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44683 index 8e64adf..9a33a3c 100644
44684 --- a/drivers/usb/core/hcd.c
44685 +++ b/drivers/usb/core/hcd.c
44686 @@ -1522,7 +1522,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44687 */
44688 usb_get_urb(urb);
44689 atomic_inc(&urb->use_count);
44690 - atomic_inc(&urb->dev->urbnum);
44691 + atomic_inc_unchecked(&urb->dev->urbnum);
44692 usbmon_urb_submit(&hcd->self, urb);
44693
44694 /* NOTE requirements on root-hub callers (usbfs and the hub
44695 @@ -1549,7 +1549,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44696 urb->hcpriv = NULL;
44697 INIT_LIST_HEAD(&urb->urb_list);
44698 atomic_dec(&urb->use_count);
44699 - atomic_dec(&urb->dev->urbnum);
44700 + atomic_dec_unchecked(&urb->dev->urbnum);
44701 if (atomic_read(&urb->reject))
44702 wake_up(&usb_kill_urb_queue);
44703 usb_put_urb(urb);
44704 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44705 index 131f736..99004c3 100644
44706 --- a/drivers/usb/core/message.c
44707 +++ b/drivers/usb/core/message.c
44708 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44709 * method can wait for it to complete. Since you don't have a handle on the
44710 * URB used, you can't cancel the request.
44711 */
44712 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44713 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44714 __u8 requesttype, __u16 value, __u16 index, void *data,
44715 __u16 size, int timeout)
44716 {
44717 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44718 index 818e4a0..0fc9589 100644
44719 --- a/drivers/usb/core/sysfs.c
44720 +++ b/drivers/usb/core/sysfs.c
44721 @@ -226,7 +226,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44722 struct usb_device *udev;
44723
44724 udev = to_usb_device(dev);
44725 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44726 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44727 }
44728 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44729
44730 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44731 index f81b925..78d22ec 100644
44732 --- a/drivers/usb/core/usb.c
44733 +++ b/drivers/usb/core/usb.c
44734 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44735 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44736 dev->state = USB_STATE_ATTACHED;
44737 dev->lpm_disable_count = 1;
44738 - atomic_set(&dev->urbnum, 0);
44739 + atomic_set_unchecked(&dev->urbnum, 0);
44740
44741 INIT_LIST_HEAD(&dev->ep0.urb_list);
44742 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44743 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44744 index 5e29dde..eca992f 100644
44745 --- a/drivers/usb/early/ehci-dbgp.c
44746 +++ b/drivers/usb/early/ehci-dbgp.c
44747 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44748
44749 #ifdef CONFIG_KGDB
44750 static struct kgdb_io kgdbdbgp_io_ops;
44751 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44752 +static struct kgdb_io kgdbdbgp_io_ops_console;
44753 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44754 #else
44755 #define dbgp_kgdb_mode (0)
44756 #endif
44757 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44758 .write_char = kgdbdbgp_write_char,
44759 };
44760
44761 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44762 + .name = "kgdbdbgp",
44763 + .read_char = kgdbdbgp_read_char,
44764 + .write_char = kgdbdbgp_write_char,
44765 + .is_console = 1
44766 +};
44767 +
44768 static int kgdbdbgp_wait_time;
44769
44770 static int __init kgdbdbgp_parse_config(char *str)
44771 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44772 ptr++;
44773 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44774 }
44775 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44776 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44777 + if (early_dbgp_console.index != -1)
44778 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44779 + else
44780 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44781
44782 return 0;
44783 }
44784 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44785 index 598dcc1..032dd4f 100644
44786 --- a/drivers/usb/gadget/u_serial.c
44787 +++ b/drivers/usb/gadget/u_serial.c
44788 @@ -735,9 +735,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44789 spin_lock_irq(&port->port_lock);
44790
44791 /* already open? Great. */
44792 - if (port->port.count) {
44793 + if (atomic_read(&port->port.count)) {
44794 status = 0;
44795 - port->port.count++;
44796 + atomic_inc(&port->port.count);
44797
44798 /* currently opening/closing? wait ... */
44799 } else if (port->openclose) {
44800 @@ -796,7 +796,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44801 tty->driver_data = port;
44802 port->port.tty = tty;
44803
44804 - port->port.count = 1;
44805 + atomic_set(&port->port.count, 1);
44806 port->openclose = false;
44807
44808 /* if connected, start the I/O stream */
44809 @@ -838,11 +838,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44810
44811 spin_lock_irq(&port->port_lock);
44812
44813 - if (port->port.count != 1) {
44814 - if (port->port.count == 0)
44815 + if (atomic_read(&port->port.count) != 1) {
44816 + if (atomic_read(&port->port.count) == 0)
44817 WARN_ON(1);
44818 else
44819 - --port->port.count;
44820 + atomic_dec(&port->port.count);
44821 goto exit;
44822 }
44823
44824 @@ -852,7 +852,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44825 * and sleep if necessary
44826 */
44827 port->openclose = true;
44828 - port->port.count = 0;
44829 + atomic_set(&port->port.count, 0);
44830
44831 gser = port->port_usb;
44832 if (gser && gser->disconnect)
44833 @@ -1159,7 +1159,7 @@ static int gs_closed(struct gs_port *port)
44834 int cond;
44835
44836 spin_lock_irq(&port->port_lock);
44837 - cond = (port->port.count == 0) && !port->openclose;
44838 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44839 spin_unlock_irq(&port->port_lock);
44840 return cond;
44841 }
44842 @@ -1273,7 +1273,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44843 /* if it's already open, start I/O ... and notify the serial
44844 * protocol about open/close status (connect/disconnect).
44845 */
44846 - if (port->port.count) {
44847 + if (atomic_read(&port->port.count)) {
44848 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44849 gs_start_io(port);
44850 if (gser->connect)
44851 @@ -1320,7 +1320,7 @@ void gserial_disconnect(struct gserial *gser)
44852
44853 port->port_usb = NULL;
44854 gser->ioport = NULL;
44855 - if (port->port.count > 0 || port->openclose) {
44856 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44857 wake_up_interruptible(&port->drain_wait);
44858 if (port->port.tty)
44859 tty_hangup(port->port.tty);
44860 @@ -1336,7 +1336,7 @@ void gserial_disconnect(struct gserial *gser)
44861
44862 /* finally, free any unused/unusable I/O buffers */
44863 spin_lock_irqsave(&port->port_lock, flags);
44864 - if (port->port.count == 0 && !port->openclose)
44865 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44866 gs_buf_free(&port->port_write_buf);
44867 gs_free_requests(gser->out, &port->read_pool, NULL);
44868 gs_free_requests(gser->out, &port->read_queue, NULL);
44869 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44870 index 5f3bcd3..bfca43f 100644
44871 --- a/drivers/usb/serial/console.c
44872 +++ b/drivers/usb/serial/console.c
44873 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44874
44875 info->port = port;
44876
44877 - ++port->port.count;
44878 + atomic_inc(&port->port.count);
44879 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44880 if (serial->type->set_termios) {
44881 /*
44882 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44883 }
44884 /* Now that any required fake tty operations are completed restore
44885 * the tty port count */
44886 - --port->port.count;
44887 + atomic_dec(&port->port.count);
44888 /* The console is special in terms of closing the device so
44889 * indicate this port is now acting as a system console. */
44890 port->port.console = 1;
44891 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44892 free_tty:
44893 kfree(tty);
44894 reset_open_count:
44895 - port->port.count = 0;
44896 + atomic_set(&port->port.count, 0);
44897 usb_autopm_put_interface(serial->interface);
44898 error_get_interface:
44899 usb_serial_put(serial);
44900 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44901 index 6c3586a..a94e621 100644
44902 --- a/drivers/usb/storage/realtek_cr.c
44903 +++ b/drivers/usb/storage/realtek_cr.c
44904 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44905
44906 buf = kmalloc(len, GFP_NOIO);
44907 if (buf == NULL)
44908 - return USB_STOR_TRANSPORT_ERROR;
44909 + return -ENOMEM;
44910
44911 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44912
44913 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44914 index 75f70f0..d467e1a 100644
44915 --- a/drivers/usb/storage/usb.h
44916 +++ b/drivers/usb/storage/usb.h
44917 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44918 __u8 useProtocol;
44919 __u8 useTransport;
44920 int (*initFunction)(struct us_data *);
44921 -};
44922 +} __do_const;
44923
44924
44925 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44926 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44927 index d6bea3e..60b250e 100644
44928 --- a/drivers/usb/wusbcore/wa-hc.h
44929 +++ b/drivers/usb/wusbcore/wa-hc.h
44930 @@ -192,7 +192,7 @@ struct wahc {
44931 struct list_head xfer_delayed_list;
44932 spinlock_t xfer_list_lock;
44933 struct work_struct xfer_work;
44934 - atomic_t xfer_id_count;
44935 + atomic_unchecked_t xfer_id_count;
44936 };
44937
44938
44939 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44940 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44941 spin_lock_init(&wa->xfer_list_lock);
44942 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44943 - atomic_set(&wa->xfer_id_count, 1);
44944 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44945 }
44946
44947 /**
44948 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44949 index 57c01ab..8a05959 100644
44950 --- a/drivers/usb/wusbcore/wa-xfer.c
44951 +++ b/drivers/usb/wusbcore/wa-xfer.c
44952 @@ -296,7 +296,7 @@ out:
44953 */
44954 static void wa_xfer_id_init(struct wa_xfer *xfer)
44955 {
44956 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44957 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44958 }
44959
44960 /*
44961 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44962 index 8c55011..eed4ae1a 100644
44963 --- a/drivers/video/aty/aty128fb.c
44964 +++ b/drivers/video/aty/aty128fb.c
44965 @@ -149,7 +149,7 @@ enum {
44966 };
44967
44968 /* Must match above enum */
44969 -static char * const r128_family[] = {
44970 +static const char * const r128_family[] = {
44971 "AGP",
44972 "PCI",
44973 "PRO AGP",
44974 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
44975 index 4f27fdc..d3537e6 100644
44976 --- a/drivers/video/aty/atyfb_base.c
44977 +++ b/drivers/video/aty/atyfb_base.c
44978 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44979 par->accel_flags = var->accel_flags; /* hack */
44980
44981 if (var->accel_flags) {
44982 - info->fbops->fb_sync = atyfb_sync;
44983 + pax_open_kernel();
44984 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44985 + pax_close_kernel();
44986 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44987 } else {
44988 - info->fbops->fb_sync = NULL;
44989 + pax_open_kernel();
44990 + *(void **)&info->fbops->fb_sync = NULL;
44991 + pax_close_kernel();
44992 info->flags |= FBINFO_HWACCEL_DISABLED;
44993 }
44994
44995 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44996 index 95ec042..e6affdd 100644
44997 --- a/drivers/video/aty/mach64_cursor.c
44998 +++ b/drivers/video/aty/mach64_cursor.c
44999 @@ -7,6 +7,7 @@
45000 #include <linux/string.h>
45001
45002 #include <asm/io.h>
45003 +#include <asm/pgtable.h>
45004
45005 #ifdef __sparc__
45006 #include <asm/fbio.h>
45007 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
45008 info->sprite.buf_align = 16; /* and 64 lines tall. */
45009 info->sprite.flags = FB_PIXMAP_IO;
45010
45011 - info->fbops->fb_cursor = atyfb_cursor;
45012 + pax_open_kernel();
45013 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
45014 + pax_close_kernel();
45015
45016 return 0;
45017 }
45018 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
45019 index 6c5ed6b..b727c88 100644
45020 --- a/drivers/video/backlight/kb3886_bl.c
45021 +++ b/drivers/video/backlight/kb3886_bl.c
45022 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
45023 static unsigned long kb3886bl_flags;
45024 #define KB3886BL_SUSPENDED 0x01
45025
45026 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
45027 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
45028 {
45029 .ident = "Sahara Touch-iT",
45030 .matches = {
45031 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
45032 index 88cad6b..dd746c7 100644
45033 --- a/drivers/video/fb_defio.c
45034 +++ b/drivers/video/fb_defio.c
45035 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
45036
45037 BUG_ON(!fbdefio);
45038 mutex_init(&fbdefio->lock);
45039 - info->fbops->fb_mmap = fb_deferred_io_mmap;
45040 + pax_open_kernel();
45041 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
45042 + pax_close_kernel();
45043 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
45044 INIT_LIST_HEAD(&fbdefio->pagelist);
45045 if (fbdefio->delay == 0) /* set a default of 1 s */
45046 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
45047 page->mapping = NULL;
45048 }
45049
45050 - info->fbops->fb_mmap = NULL;
45051 + *(void **)&info->fbops->fb_mmap = NULL;
45052 mutex_destroy(&fbdefio->lock);
45053 }
45054 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
45055 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
45056 index 5c3960d..15cf8fc 100644
45057 --- a/drivers/video/fbcmap.c
45058 +++ b/drivers/video/fbcmap.c
45059 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
45060 rc = -ENODEV;
45061 goto out;
45062 }
45063 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
45064 - !info->fbops->fb_setcmap)) {
45065 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
45066 rc = -EINVAL;
45067 goto out1;
45068 }
45069 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45070 index dc61c12..e29796e 100644
45071 --- a/drivers/video/fbmem.c
45072 +++ b/drivers/video/fbmem.c
45073 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45074 image->dx += image->width + 8;
45075 }
45076 } else if (rotate == FB_ROTATE_UD) {
45077 - for (x = 0; x < num && image->dx >= 0; x++) {
45078 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
45079 info->fbops->fb_imageblit(info, image);
45080 image->dx -= image->width + 8;
45081 }
45082 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45083 image->dy += image->height + 8;
45084 }
45085 } else if (rotate == FB_ROTATE_CCW) {
45086 - for (x = 0; x < num && image->dy >= 0; x++) {
45087 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
45088 info->fbops->fb_imageblit(info, image);
45089 image->dy -= image->height + 8;
45090 }
45091 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
45092 return -EFAULT;
45093 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
45094 return -EINVAL;
45095 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
45096 + if (con2fb.framebuffer >= FB_MAX)
45097 return -EINVAL;
45098 if (!registered_fb[con2fb.framebuffer])
45099 request_module("fb%d", con2fb.framebuffer);
45100 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
45101 index 7672d2e..b56437f 100644
45102 --- a/drivers/video/i810/i810_accel.c
45103 +++ b/drivers/video/i810/i810_accel.c
45104 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45105 }
45106 }
45107 printk("ringbuffer lockup!!!\n");
45108 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45109 i810_report_error(mmio);
45110 par->dev_flags |= LOCKUP;
45111 info->pixmap.scan_align = 1;
45112 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45113 index 3c14e43..eafa544 100644
45114 --- a/drivers/video/logo/logo_linux_clut224.ppm
45115 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45116 @@ -1,1604 +1,1123 @@
45117 P3
45118 -# Standard 224-color Linux logo
45119 80 80
45120 255
45121 - 0 0 0 0 0 0 0 0 0 0 0 0
45122 - 0 0 0 0 0 0 0 0 0 0 0 0
45123 - 0 0 0 0 0 0 0 0 0 0 0 0
45124 - 0 0 0 0 0 0 0 0 0 0 0 0
45125 - 0 0 0 0 0 0 0 0 0 0 0 0
45126 - 0 0 0 0 0 0 0 0 0 0 0 0
45127 - 0 0 0 0 0 0 0 0 0 0 0 0
45128 - 0 0 0 0 0 0 0 0 0 0 0 0
45129 - 0 0 0 0 0 0 0 0 0 0 0 0
45130 - 6 6 6 6 6 6 10 10 10 10 10 10
45131 - 10 10 10 6 6 6 6 6 6 6 6 6
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 0 0 0
45138 - 0 0 0 0 0 0 0 0 0 0 0 0
45139 - 0 0 0 0 0 0 0 0 0 0 0 0
45140 - 0 0 0 0 0 0 0 0 0 0 0 0
45141 - 0 0 0 0 0 0 0 0 0 0 0 0
45142 - 0 0 0 0 0 0 0 0 0 0 0 0
45143 - 0 0 0 0 0 0 0 0 0 0 0 0
45144 - 0 0 0 0 0 0 0 0 0 0 0 0
45145 - 0 0 0 0 0 0 0 0 0 0 0 0
45146 - 0 0 0 0 0 0 0 0 0 0 0 0
45147 - 0 0 0 0 0 0 0 0 0 0 0 0
45148 - 0 0 0 0 0 0 0 0 0 0 0 0
45149 - 0 0 0 6 6 6 10 10 10 14 14 14
45150 - 22 22 22 26 26 26 30 30 30 34 34 34
45151 - 30 30 30 30 30 30 26 26 26 18 18 18
45152 - 14 14 14 10 10 10 6 6 6 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 0 0 0
45158 - 0 0 0 0 0 0 0 0 0 0 0 0
45159 - 0 0 0 0 0 0 0 0 0 0 0 0
45160 - 0 0 0 0 0 0 0 0 0 0 0 0
45161 - 0 0 0 0 0 0 0 0 0 0 0 0
45162 - 0 0 0 0 0 1 0 0 1 0 0 0
45163 - 0 0 0 0 0 0 0 0 0 0 0 0
45164 - 0 0 0 0 0 0 0 0 0 0 0 0
45165 - 0 0 0 0 0 0 0 0 0 0 0 0
45166 - 0 0 0 0 0 0 0 0 0 0 0 0
45167 - 0 0 0 0 0 0 0 0 0 0 0 0
45168 - 0 0 0 0 0 0 0 0 0 0 0 0
45169 - 6 6 6 14 14 14 26 26 26 42 42 42
45170 - 54 54 54 66 66 66 78 78 78 78 78 78
45171 - 78 78 78 74 74 74 66 66 66 54 54 54
45172 - 42 42 42 26 26 26 18 18 18 10 10 10
45173 - 6 6 6 0 0 0 0 0 0 0 0 0
45174 - 0 0 0 0 0 0 0 0 0 0 0 0
45175 - 0 0 0 0 0 0 0 0 0 0 0 0
45176 - 0 0 0 0 0 0 0 0 0 0 0 0
45177 - 0 0 0 0 0 0 0 0 0 0 0 0
45178 - 0 0 0 0 0 0 0 0 0 0 0 0
45179 - 0 0 0 0 0 0 0 0 0 0 0 0
45180 - 0 0 0 0 0 0 0 0 0 0 0 0
45181 - 0 0 0 0 0 0 0 0 0 0 0 0
45182 - 0 0 1 0 0 0 0 0 0 0 0 0
45183 - 0 0 0 0 0 0 0 0 0 0 0 0
45184 - 0 0 0 0 0 0 0 0 0 0 0 0
45185 - 0 0 0 0 0 0 0 0 0 0 0 0
45186 - 0 0 0 0 0 0 0 0 0 0 0 0
45187 - 0 0 0 0 0 0 0 0 0 0 0 0
45188 - 0 0 0 0 0 0 0 0 0 10 10 10
45189 - 22 22 22 42 42 42 66 66 66 86 86 86
45190 - 66 66 66 38 38 38 38 38 38 22 22 22
45191 - 26 26 26 34 34 34 54 54 54 66 66 66
45192 - 86 86 86 70 70 70 46 46 46 26 26 26
45193 - 14 14 14 6 6 6 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 0 0 0 0 0 0
45198 - 0 0 0 0 0 0 0 0 0 0 0 0
45199 - 0 0 0 0 0 0 0 0 0 0 0 0
45200 - 0 0 0 0 0 0 0 0 0 0 0 0
45201 - 0 0 0 0 0 0 0 0 0 0 0 0
45202 - 0 0 1 0 0 1 0 0 1 0 0 0
45203 - 0 0 0 0 0 0 0 0 0 0 0 0
45204 - 0 0 0 0 0 0 0 0 0 0 0 0
45205 - 0 0 0 0 0 0 0 0 0 0 0 0
45206 - 0 0 0 0 0 0 0 0 0 0 0 0
45207 - 0 0 0 0 0 0 0 0 0 0 0 0
45208 - 0 0 0 0 0 0 10 10 10 26 26 26
45209 - 50 50 50 82 82 82 58 58 58 6 6 6
45210 - 2 2 6 2 2 6 2 2 6 2 2 6
45211 - 2 2 6 2 2 6 2 2 6 2 2 6
45212 - 6 6 6 54 54 54 86 86 86 66 66 66
45213 - 38 38 38 18 18 18 6 6 6 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 0 0 0 0 0 0 0 0 0
45218 - 0 0 0 0 0 0 0 0 0 0 0 0
45219 - 0 0 0 0 0 0 0 0 0 0 0 0
45220 - 0 0 0 0 0 0 0 0 0 0 0 0
45221 - 0 0 0 0 0 0 0 0 0 0 0 0
45222 - 0 0 0 0 0 0 0 0 0 0 0 0
45223 - 0 0 0 0 0 0 0 0 0 0 0 0
45224 - 0 0 0 0 0 0 0 0 0 0 0 0
45225 - 0 0 0 0 0 0 0 0 0 0 0 0
45226 - 0 0 0 0 0 0 0 0 0 0 0 0
45227 - 0 0 0 0 0 0 0 0 0 0 0 0
45228 - 0 0 0 6 6 6 22 22 22 50 50 50
45229 - 78 78 78 34 34 34 2 2 6 2 2 6
45230 - 2 2 6 2 2 6 2 2 6 2 2 6
45231 - 2 2 6 2 2 6 2 2 6 2 2 6
45232 - 2 2 6 2 2 6 6 6 6 70 70 70
45233 - 78 78 78 46 46 46 22 22 22 6 6 6
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 0 0 0 0 0 0 0 0 0
45238 - 0 0 0 0 0 0 0 0 0 0 0 0
45239 - 0 0 0 0 0 0 0 0 0 0 0 0
45240 - 0 0 0 0 0 0 0 0 0 0 0 0
45241 - 0 0 0 0 0 0 0 0 0 0 0 0
45242 - 0 0 1 0 0 1 0 0 1 0 0 0
45243 - 0 0 0 0 0 0 0 0 0 0 0 0
45244 - 0 0 0 0 0 0 0 0 0 0 0 0
45245 - 0 0 0 0 0 0 0 0 0 0 0 0
45246 - 0 0 0 0 0 0 0 0 0 0 0 0
45247 - 0 0 0 0 0 0 0 0 0 0 0 0
45248 - 6 6 6 18 18 18 42 42 42 82 82 82
45249 - 26 26 26 2 2 6 2 2 6 2 2 6
45250 - 2 2 6 2 2 6 2 2 6 2 2 6
45251 - 2 2 6 2 2 6 2 2 6 14 14 14
45252 - 46 46 46 34 34 34 6 6 6 2 2 6
45253 - 42 42 42 78 78 78 42 42 42 18 18 18
45254 - 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45258 - 0 0 0 0 0 0 0 0 0 0 0 0
45259 - 0 0 0 0 0 0 0 0 0 0 0 0
45260 - 0 0 0 0 0 0 0 0 0 0 0 0
45261 - 0 0 0 0 0 0 0 0 0 0 0 0
45262 - 0 0 1 0 0 0 0 0 1 0 0 0
45263 - 0 0 0 0 0 0 0 0 0 0 0 0
45264 - 0 0 0 0 0 0 0 0 0 0 0 0
45265 - 0 0 0 0 0 0 0 0 0 0 0 0
45266 - 0 0 0 0 0 0 0 0 0 0 0 0
45267 - 0 0 0 0 0 0 0 0 0 0 0 0
45268 - 10 10 10 30 30 30 66 66 66 58 58 58
45269 - 2 2 6 2 2 6 2 2 6 2 2 6
45270 - 2 2 6 2 2 6 2 2 6 2 2 6
45271 - 2 2 6 2 2 6 2 2 6 26 26 26
45272 - 86 86 86 101 101 101 46 46 46 10 10 10
45273 - 2 2 6 58 58 58 70 70 70 34 34 34
45274 - 10 10 10 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45278 - 0 0 0 0 0 0 0 0 0 0 0 0
45279 - 0 0 0 0 0 0 0 0 0 0 0 0
45280 - 0 0 0 0 0 0 0 0 0 0 0 0
45281 - 0 0 0 0 0 0 0 0 0 0 0 0
45282 - 0 0 1 0 0 1 0 0 1 0 0 0
45283 - 0 0 0 0 0 0 0 0 0 0 0 0
45284 - 0 0 0 0 0 0 0 0 0 0 0 0
45285 - 0 0 0 0 0 0 0 0 0 0 0 0
45286 - 0 0 0 0 0 0 0 0 0 0 0 0
45287 - 0 0 0 0 0 0 0 0 0 0 0 0
45288 - 14 14 14 42 42 42 86 86 86 10 10 10
45289 - 2 2 6 2 2 6 2 2 6 2 2 6
45290 - 2 2 6 2 2 6 2 2 6 2 2 6
45291 - 2 2 6 2 2 6 2 2 6 30 30 30
45292 - 94 94 94 94 94 94 58 58 58 26 26 26
45293 - 2 2 6 6 6 6 78 78 78 54 54 54
45294 - 22 22 22 6 6 6 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 0 0 0
45297 - 0 0 0 0 0 0 0 0 0 0 0 0
45298 - 0 0 0 0 0 0 0 0 0 0 0 0
45299 - 0 0 0 0 0 0 0 0 0 0 0 0
45300 - 0 0 0 0 0 0 0 0 0 0 0 0
45301 - 0 0 0 0 0 0 0 0 0 0 0 0
45302 - 0 0 0 0 0 0 0 0 0 0 0 0
45303 - 0 0 0 0 0 0 0 0 0 0 0 0
45304 - 0 0 0 0 0 0 0 0 0 0 0 0
45305 - 0 0 0 0 0 0 0 0 0 0 0 0
45306 - 0 0 0 0 0 0 0 0 0 0 0 0
45307 - 0 0 0 0 0 0 0 0 0 6 6 6
45308 - 22 22 22 62 62 62 62 62 62 2 2 6
45309 - 2 2 6 2 2 6 2 2 6 2 2 6
45310 - 2 2 6 2 2 6 2 2 6 2 2 6
45311 - 2 2 6 2 2 6 2 2 6 26 26 26
45312 - 54 54 54 38 38 38 18 18 18 10 10 10
45313 - 2 2 6 2 2 6 34 34 34 82 82 82
45314 - 38 38 38 14 14 14 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 0 0 0
45317 - 0 0 0 0 0 0 0 0 0 0 0 0
45318 - 0 0 0 0 0 0 0 0 0 0 0 0
45319 - 0 0 0 0 0 0 0 0 0 0 0 0
45320 - 0 0 0 0 0 0 0 0 0 0 0 0
45321 - 0 0 0 0 0 0 0 0 0 0 0 0
45322 - 0 0 0 0 0 1 0 0 1 0 0 0
45323 - 0 0 0 0 0 0 0 0 0 0 0 0
45324 - 0 0 0 0 0 0 0 0 0 0 0 0
45325 - 0 0 0 0 0 0 0 0 0 0 0 0
45326 - 0 0 0 0 0 0 0 0 0 0 0 0
45327 - 0 0 0 0 0 0 0 0 0 6 6 6
45328 - 30 30 30 78 78 78 30 30 30 2 2 6
45329 - 2 2 6 2 2 6 2 2 6 2 2 6
45330 - 2 2 6 2 2 6 2 2 6 2 2 6
45331 - 2 2 6 2 2 6 2 2 6 10 10 10
45332 - 10 10 10 2 2 6 2 2 6 2 2 6
45333 - 2 2 6 2 2 6 2 2 6 78 78 78
45334 - 50 50 50 18 18 18 6 6 6 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 0 0 0
45337 - 0 0 0 0 0 0 0 0 0 0 0 0
45338 - 0 0 0 0 0 0 0 0 0 0 0 0
45339 - 0 0 0 0 0 0 0 0 0 0 0 0
45340 - 0 0 0 0 0 0 0 0 0 0 0 0
45341 - 0 0 0 0 0 0 0 0 0 0 0 0
45342 - 0 0 1 0 0 0 0 0 0 0 0 0
45343 - 0 0 0 0 0 0 0 0 0 0 0 0
45344 - 0 0 0 0 0 0 0 0 0 0 0 0
45345 - 0 0 0 0 0 0 0 0 0 0 0 0
45346 - 0 0 0 0 0 0 0 0 0 0 0 0
45347 - 0 0 0 0 0 0 0 0 0 10 10 10
45348 - 38 38 38 86 86 86 14 14 14 2 2 6
45349 - 2 2 6 2 2 6 2 2 6 2 2 6
45350 - 2 2 6 2 2 6 2 2 6 2 2 6
45351 - 2 2 6 2 2 6 2 2 6 2 2 6
45352 - 2 2 6 2 2 6 2 2 6 2 2 6
45353 - 2 2 6 2 2 6 2 2 6 54 54 54
45354 - 66 66 66 26 26 26 6 6 6 0 0 0
45355 - 0 0 0 0 0 0 0 0 0 0 0 0
45356 - 0 0 0 0 0 0 0 0 0 0 0 0
45357 - 0 0 0 0 0 0 0 0 0 0 0 0
45358 - 0 0 0 0 0 0 0 0 0 0 0 0
45359 - 0 0 0 0 0 0 0 0 0 0 0 0
45360 - 0 0 0 0 0 0 0 0 0 0 0 0
45361 - 0 0 0 0 0 0 0 0 0 0 0 0
45362 - 0 0 0 0 0 1 0 0 1 0 0 0
45363 - 0 0 0 0 0 0 0 0 0 0 0 0
45364 - 0 0 0 0 0 0 0 0 0 0 0 0
45365 - 0 0 0 0 0 0 0 0 0 0 0 0
45366 - 0 0 0 0 0 0 0 0 0 0 0 0
45367 - 0 0 0 0 0 0 0 0 0 14 14 14
45368 - 42 42 42 82 82 82 2 2 6 2 2 6
45369 - 2 2 6 6 6 6 10 10 10 2 2 6
45370 - 2 2 6 2 2 6 2 2 6 2 2 6
45371 - 2 2 6 2 2 6 2 2 6 6 6 6
45372 - 14 14 14 10 10 10 2 2 6 2 2 6
45373 - 2 2 6 2 2 6 2 2 6 18 18 18
45374 - 82 82 82 34 34 34 10 10 10 0 0 0
45375 - 0 0 0 0 0 0 0 0 0 0 0 0
45376 - 0 0 0 0 0 0 0 0 0 0 0 0
45377 - 0 0 0 0 0 0 0 0 0 0 0 0
45378 - 0 0 0 0 0 0 0 0 0 0 0 0
45379 - 0 0 0 0 0 0 0 0 0 0 0 0
45380 - 0 0 0 0 0 0 0 0 0 0 0 0
45381 - 0 0 0 0 0 0 0 0 0 0 0 0
45382 - 0 0 1 0 0 0 0 0 0 0 0 0
45383 - 0 0 0 0 0 0 0 0 0 0 0 0
45384 - 0 0 0 0 0 0 0 0 0 0 0 0
45385 - 0 0 0 0 0 0 0 0 0 0 0 0
45386 - 0 0 0 0 0 0 0 0 0 0 0 0
45387 - 0 0 0 0 0 0 0 0 0 14 14 14
45388 - 46 46 46 86 86 86 2 2 6 2 2 6
45389 - 6 6 6 6 6 6 22 22 22 34 34 34
45390 - 6 6 6 2 2 6 2 2 6 2 2 6
45391 - 2 2 6 2 2 6 18 18 18 34 34 34
45392 - 10 10 10 50 50 50 22 22 22 2 2 6
45393 - 2 2 6 2 2 6 2 2 6 10 10 10
45394 - 86 86 86 42 42 42 14 14 14 0 0 0
45395 - 0 0 0 0 0 0 0 0 0 0 0 0
45396 - 0 0 0 0 0 0 0 0 0 0 0 0
45397 - 0 0 0 0 0 0 0 0 0 0 0 0
45398 - 0 0 0 0 0 0 0 0 0 0 0 0
45399 - 0 0 0 0 0 0 0 0 0 0 0 0
45400 - 0 0 0 0 0 0 0 0 0 0 0 0
45401 - 0 0 0 0 0 0 0 0 0 0 0 0
45402 - 0 0 1 0 0 1 0 0 1 0 0 0
45403 - 0 0 0 0 0 0 0 0 0 0 0 0
45404 - 0 0 0 0 0 0 0 0 0 0 0 0
45405 - 0 0 0 0 0 0 0 0 0 0 0 0
45406 - 0 0 0 0 0 0 0 0 0 0 0 0
45407 - 0 0 0 0 0 0 0 0 0 14 14 14
45408 - 46 46 46 86 86 86 2 2 6 2 2 6
45409 - 38 38 38 116 116 116 94 94 94 22 22 22
45410 - 22 22 22 2 2 6 2 2 6 2 2 6
45411 - 14 14 14 86 86 86 138 138 138 162 162 162
45412 -154 154 154 38 38 38 26 26 26 6 6 6
45413 - 2 2 6 2 2 6 2 2 6 2 2 6
45414 - 86 86 86 46 46 46 14 14 14 0 0 0
45415 - 0 0 0 0 0 0 0 0 0 0 0 0
45416 - 0 0 0 0 0 0 0 0 0 0 0 0
45417 - 0 0 0 0 0 0 0 0 0 0 0 0
45418 - 0 0 0 0 0 0 0 0 0 0 0 0
45419 - 0 0 0 0 0 0 0 0 0 0 0 0
45420 - 0 0 0 0 0 0 0 0 0 0 0 0
45421 - 0 0 0 0 0 0 0 0 0 0 0 0
45422 - 0 0 0 0 0 0 0 0 0 0 0 0
45423 - 0 0 0 0 0 0 0 0 0 0 0 0
45424 - 0 0 0 0 0 0 0 0 0 0 0 0
45425 - 0 0 0 0 0 0 0 0 0 0 0 0
45426 - 0 0 0 0 0 0 0 0 0 0 0 0
45427 - 0 0 0 0 0 0 0 0 0 14 14 14
45428 - 46 46 46 86 86 86 2 2 6 14 14 14
45429 -134 134 134 198 198 198 195 195 195 116 116 116
45430 - 10 10 10 2 2 6 2 2 6 6 6 6
45431 -101 98 89 187 187 187 210 210 210 218 218 218
45432 -214 214 214 134 134 134 14 14 14 6 6 6
45433 - 2 2 6 2 2 6 2 2 6 2 2 6
45434 - 86 86 86 50 50 50 18 18 18 6 6 6
45435 - 0 0 0 0 0 0 0 0 0 0 0 0
45436 - 0 0 0 0 0 0 0 0 0 0 0 0
45437 - 0 0 0 0 0 0 0 0 0 0 0 0
45438 - 0 0 0 0 0 0 0 0 0 0 0 0
45439 - 0 0 0 0 0 0 0 0 0 0 0 0
45440 - 0 0 0 0 0 0 0 0 0 0 0 0
45441 - 0 0 0 0 0 0 0 0 1 0 0 0
45442 - 0 0 1 0 0 1 0 0 1 0 0 0
45443 - 0 0 0 0 0 0 0 0 0 0 0 0
45444 - 0 0 0 0 0 0 0 0 0 0 0 0
45445 - 0 0 0 0 0 0 0 0 0 0 0 0
45446 - 0 0 0 0 0 0 0 0 0 0 0 0
45447 - 0 0 0 0 0 0 0 0 0 14 14 14
45448 - 46 46 46 86 86 86 2 2 6 54 54 54
45449 -218 218 218 195 195 195 226 226 226 246 246 246
45450 - 58 58 58 2 2 6 2 2 6 30 30 30
45451 -210 210 210 253 253 253 174 174 174 123 123 123
45452 -221 221 221 234 234 234 74 74 74 2 2 6
45453 - 2 2 6 2 2 6 2 2 6 2 2 6
45454 - 70 70 70 58 58 58 22 22 22 6 6 6
45455 - 0 0 0 0 0 0 0 0 0 0 0 0
45456 - 0 0 0 0 0 0 0 0 0 0 0 0
45457 - 0 0 0 0 0 0 0 0 0 0 0 0
45458 - 0 0 0 0 0 0 0 0 0 0 0 0
45459 - 0 0 0 0 0 0 0 0 0 0 0 0
45460 - 0 0 0 0 0 0 0 0 0 0 0 0
45461 - 0 0 0 0 0 0 0 0 0 0 0 0
45462 - 0 0 0 0 0 0 0 0 0 0 0 0
45463 - 0 0 0 0 0 0 0 0 0 0 0 0
45464 - 0 0 0 0 0 0 0 0 0 0 0 0
45465 - 0 0 0 0 0 0 0 0 0 0 0 0
45466 - 0 0 0 0 0 0 0 0 0 0 0 0
45467 - 0 0 0 0 0 0 0 0 0 14 14 14
45468 - 46 46 46 82 82 82 2 2 6 106 106 106
45469 -170 170 170 26 26 26 86 86 86 226 226 226
45470 -123 123 123 10 10 10 14 14 14 46 46 46
45471 -231 231 231 190 190 190 6 6 6 70 70 70
45472 - 90 90 90 238 238 238 158 158 158 2 2 6
45473 - 2 2 6 2 2 6 2 2 6 2 2 6
45474 - 70 70 70 58 58 58 22 22 22 6 6 6
45475 - 0 0 0 0 0 0 0 0 0 0 0 0
45476 - 0 0 0 0 0 0 0 0 0 0 0 0
45477 - 0 0 0 0 0 0 0 0 0 0 0 0
45478 - 0 0 0 0 0 0 0 0 0 0 0 0
45479 - 0 0 0 0 0 0 0 0 0 0 0 0
45480 - 0 0 0 0 0 0 0 0 0 0 0 0
45481 - 0 0 0 0 0 0 0 0 1 0 0 0
45482 - 0 0 1 0 0 1 0 0 1 0 0 0
45483 - 0 0 0 0 0 0 0 0 0 0 0 0
45484 - 0 0 0 0 0 0 0 0 0 0 0 0
45485 - 0 0 0 0 0 0 0 0 0 0 0 0
45486 - 0 0 0 0 0 0 0 0 0 0 0 0
45487 - 0 0 0 0 0 0 0 0 0 14 14 14
45488 - 42 42 42 86 86 86 6 6 6 116 116 116
45489 -106 106 106 6 6 6 70 70 70 149 149 149
45490 -128 128 128 18 18 18 38 38 38 54 54 54
45491 -221 221 221 106 106 106 2 2 6 14 14 14
45492 - 46 46 46 190 190 190 198 198 198 2 2 6
45493 - 2 2 6 2 2 6 2 2 6 2 2 6
45494 - 74 74 74 62 62 62 22 22 22 6 6 6
45495 - 0 0 0 0 0 0 0 0 0 0 0 0
45496 - 0 0 0 0 0 0 0 0 0 0 0 0
45497 - 0 0 0 0 0 0 0 0 0 0 0 0
45498 - 0 0 0 0 0 0 0 0 0 0 0 0
45499 - 0 0 0 0 0 0 0 0 0 0 0 0
45500 - 0 0 0 0 0 0 0 0 0 0 0 0
45501 - 0 0 0 0 0 0 0 0 1 0 0 0
45502 - 0 0 1 0 0 0 0 0 1 0 0 0
45503 - 0 0 0 0 0 0 0 0 0 0 0 0
45504 - 0 0 0 0 0 0 0 0 0 0 0 0
45505 - 0 0 0 0 0 0 0 0 0 0 0 0
45506 - 0 0 0 0 0 0 0 0 0 0 0 0
45507 - 0 0 0 0 0 0 0 0 0 14 14 14
45508 - 42 42 42 94 94 94 14 14 14 101 101 101
45509 -128 128 128 2 2 6 18 18 18 116 116 116
45510 -118 98 46 121 92 8 121 92 8 98 78 10
45511 -162 162 162 106 106 106 2 2 6 2 2 6
45512 - 2 2 6 195 195 195 195 195 195 6 6 6
45513 - 2 2 6 2 2 6 2 2 6 2 2 6
45514 - 74 74 74 62 62 62 22 22 22 6 6 6
45515 - 0 0 0 0 0 0 0 0 0 0 0 0
45516 - 0 0 0 0 0 0 0 0 0 0 0 0
45517 - 0 0 0 0 0 0 0 0 0 0 0 0
45518 - 0 0 0 0 0 0 0 0 0 0 0 0
45519 - 0 0 0 0 0 0 0 0 0 0 0 0
45520 - 0 0 0 0 0 0 0 0 0 0 0 0
45521 - 0 0 0 0 0 0 0 0 1 0 0 1
45522 - 0 0 1 0 0 0 0 0 1 0 0 0
45523 - 0 0 0 0 0 0 0 0 0 0 0 0
45524 - 0 0 0 0 0 0 0 0 0 0 0 0
45525 - 0 0 0 0 0 0 0 0 0 0 0 0
45526 - 0 0 0 0 0 0 0 0 0 0 0 0
45527 - 0 0 0 0 0 0 0 0 0 10 10 10
45528 - 38 38 38 90 90 90 14 14 14 58 58 58
45529 -210 210 210 26 26 26 54 38 6 154 114 10
45530 -226 170 11 236 186 11 225 175 15 184 144 12
45531 -215 174 15 175 146 61 37 26 9 2 2 6
45532 - 70 70 70 246 246 246 138 138 138 2 2 6
45533 - 2 2 6 2 2 6 2 2 6 2 2 6
45534 - 70 70 70 66 66 66 26 26 26 6 6 6
45535 - 0 0 0 0 0 0 0 0 0 0 0 0
45536 - 0 0 0 0 0 0 0 0 0 0 0 0
45537 - 0 0 0 0 0 0 0 0 0 0 0 0
45538 - 0 0 0 0 0 0 0 0 0 0 0 0
45539 - 0 0 0 0 0 0 0 0 0 0 0 0
45540 - 0 0 0 0 0 0 0 0 0 0 0 0
45541 - 0 0 0 0 0 0 0 0 0 0 0 0
45542 - 0 0 0 0 0 0 0 0 0 0 0 0
45543 - 0 0 0 0 0 0 0 0 0 0 0 0
45544 - 0 0 0 0 0 0 0 0 0 0 0 0
45545 - 0 0 0 0 0 0 0 0 0 0 0 0
45546 - 0 0 0 0 0 0 0 0 0 0 0 0
45547 - 0 0 0 0 0 0 0 0 0 10 10 10
45548 - 38 38 38 86 86 86 14 14 14 10 10 10
45549 -195 195 195 188 164 115 192 133 9 225 175 15
45550 -239 182 13 234 190 10 232 195 16 232 200 30
45551 -245 207 45 241 208 19 232 195 16 184 144 12
45552 -218 194 134 211 206 186 42 42 42 2 2 6
45553 - 2 2 6 2 2 6 2 2 6 2 2 6
45554 - 50 50 50 74 74 74 30 30 30 6 6 6
45555 - 0 0 0 0 0 0 0 0 0 0 0 0
45556 - 0 0 0 0 0 0 0 0 0 0 0 0
45557 - 0 0 0 0 0 0 0 0 0 0 0 0
45558 - 0 0 0 0 0 0 0 0 0 0 0 0
45559 - 0 0 0 0 0 0 0 0 0 0 0 0
45560 - 0 0 0 0 0 0 0 0 0 0 0 0
45561 - 0 0 0 0 0 0 0 0 0 0 0 0
45562 - 0 0 0 0 0 0 0 0 0 0 0 0
45563 - 0 0 0 0 0 0 0 0 0 0 0 0
45564 - 0 0 0 0 0 0 0 0 0 0 0 0
45565 - 0 0 0 0 0 0 0 0 0 0 0 0
45566 - 0 0 0 0 0 0 0 0 0 0 0 0
45567 - 0 0 0 0 0 0 0 0 0 10 10 10
45568 - 34 34 34 86 86 86 14 14 14 2 2 6
45569 -121 87 25 192 133 9 219 162 10 239 182 13
45570 -236 186 11 232 195 16 241 208 19 244 214 54
45571 -246 218 60 246 218 38 246 215 20 241 208 19
45572 -241 208 19 226 184 13 121 87 25 2 2 6
45573 - 2 2 6 2 2 6 2 2 6 2 2 6
45574 - 50 50 50 82 82 82 34 34 34 10 10 10
45575 - 0 0 0 0 0 0 0 0 0 0 0 0
45576 - 0 0 0 0 0 0 0 0 0 0 0 0
45577 - 0 0 0 0 0 0 0 0 0 0 0 0
45578 - 0 0 0 0 0 0 0 0 0 0 0 0
45579 - 0 0 0 0 0 0 0 0 0 0 0 0
45580 - 0 0 0 0 0 0 0 0 0 0 0 0
45581 - 0 0 0 0 0 0 0 0 0 0 0 0
45582 - 0 0 0 0 0 0 0 0 0 0 0 0
45583 - 0 0 0 0 0 0 0 0 0 0 0 0
45584 - 0 0 0 0 0 0 0 0 0 0 0 0
45585 - 0 0 0 0 0 0 0 0 0 0 0 0
45586 - 0 0 0 0 0 0 0 0 0 0 0 0
45587 - 0 0 0 0 0 0 0 0 0 10 10 10
45588 - 34 34 34 82 82 82 30 30 30 61 42 6
45589 -180 123 7 206 145 10 230 174 11 239 182 13
45590 -234 190 10 238 202 15 241 208 19 246 218 74
45591 -246 218 38 246 215 20 246 215 20 246 215 20
45592 -226 184 13 215 174 15 184 144 12 6 6 6
45593 - 2 2 6 2 2 6 2 2 6 2 2 6
45594 - 26 26 26 94 94 94 42 42 42 14 14 14
45595 - 0 0 0 0 0 0 0 0 0 0 0 0
45596 - 0 0 0 0 0 0 0 0 0 0 0 0
45597 - 0 0 0 0 0 0 0 0 0 0 0 0
45598 - 0 0 0 0 0 0 0 0 0 0 0 0
45599 - 0 0 0 0 0 0 0 0 0 0 0 0
45600 - 0 0 0 0 0 0 0 0 0 0 0 0
45601 - 0 0 0 0 0 0 0 0 0 0 0 0
45602 - 0 0 0 0 0 0 0 0 0 0 0 0
45603 - 0 0 0 0 0 0 0 0 0 0 0 0
45604 - 0 0 0 0 0 0 0 0 0 0 0 0
45605 - 0 0 0 0 0 0 0 0 0 0 0 0
45606 - 0 0 0 0 0 0 0 0 0 0 0 0
45607 - 0 0 0 0 0 0 0 0 0 10 10 10
45608 - 30 30 30 78 78 78 50 50 50 104 69 6
45609 -192 133 9 216 158 10 236 178 12 236 186 11
45610 -232 195 16 241 208 19 244 214 54 245 215 43
45611 -246 215 20 246 215 20 241 208 19 198 155 10
45612 -200 144 11 216 158 10 156 118 10 2 2 6
45613 - 2 2 6 2 2 6 2 2 6 2 2 6
45614 - 6 6 6 90 90 90 54 54 54 18 18 18
45615 - 6 6 6 0 0 0 0 0 0 0 0 0
45616 - 0 0 0 0 0 0 0 0 0 0 0 0
45617 - 0 0 0 0 0 0 0 0 0 0 0 0
45618 - 0 0 0 0 0 0 0 0 0 0 0 0
45619 - 0 0 0 0 0 0 0 0 0 0 0 0
45620 - 0 0 0 0 0 0 0 0 0 0 0 0
45621 - 0 0 0 0 0 0 0 0 0 0 0 0
45622 - 0 0 0 0 0 0 0 0 0 0 0 0
45623 - 0 0 0 0 0 0 0 0 0 0 0 0
45624 - 0 0 0 0 0 0 0 0 0 0 0 0
45625 - 0 0 0 0 0 0 0 0 0 0 0 0
45626 - 0 0 0 0 0 0 0 0 0 0 0 0
45627 - 0 0 0 0 0 0 0 0 0 10 10 10
45628 - 30 30 30 78 78 78 46 46 46 22 22 22
45629 -137 92 6 210 162 10 239 182 13 238 190 10
45630 -238 202 15 241 208 19 246 215 20 246 215 20
45631 -241 208 19 203 166 17 185 133 11 210 150 10
45632 -216 158 10 210 150 10 102 78 10 2 2 6
45633 - 6 6 6 54 54 54 14 14 14 2 2 6
45634 - 2 2 6 62 62 62 74 74 74 30 30 30
45635 - 10 10 10 0 0 0 0 0 0 0 0 0
45636 - 0 0 0 0 0 0 0 0 0 0 0 0
45637 - 0 0 0 0 0 0 0 0 0 0 0 0
45638 - 0 0 0 0 0 0 0 0 0 0 0 0
45639 - 0 0 0 0 0 0 0 0 0 0 0 0
45640 - 0 0 0 0 0 0 0 0 0 0 0 0
45641 - 0 0 0 0 0 0 0 0 0 0 0 0
45642 - 0 0 0 0 0 0 0 0 0 0 0 0
45643 - 0 0 0 0 0 0 0 0 0 0 0 0
45644 - 0 0 0 0 0 0 0 0 0 0 0 0
45645 - 0 0 0 0 0 0 0 0 0 0 0 0
45646 - 0 0 0 0 0 0 0 0 0 0 0 0
45647 - 0 0 0 0 0 0 0 0 0 10 10 10
45648 - 34 34 34 78 78 78 50 50 50 6 6 6
45649 - 94 70 30 139 102 15 190 146 13 226 184 13
45650 -232 200 30 232 195 16 215 174 15 190 146 13
45651 -168 122 10 192 133 9 210 150 10 213 154 11
45652 -202 150 34 182 157 106 101 98 89 2 2 6
45653 - 2 2 6 78 78 78 116 116 116 58 58 58
45654 - 2 2 6 22 22 22 90 90 90 46 46 46
45655 - 18 18 18 6 6 6 0 0 0 0 0 0
45656 - 0 0 0 0 0 0 0 0 0 0 0 0
45657 - 0 0 0 0 0 0 0 0 0 0 0 0
45658 - 0 0 0 0 0 0 0 0 0 0 0 0
45659 - 0 0 0 0 0 0 0 0 0 0 0 0
45660 - 0 0 0 0 0 0 0 0 0 0 0 0
45661 - 0 0 0 0 0 0 0 0 0 0 0 0
45662 - 0 0 0 0 0 0 0 0 0 0 0 0
45663 - 0 0 0 0 0 0 0 0 0 0 0 0
45664 - 0 0 0 0 0 0 0 0 0 0 0 0
45665 - 0 0 0 0 0 0 0 0 0 0 0 0
45666 - 0 0 0 0 0 0 0 0 0 0 0 0
45667 - 0 0 0 0 0 0 0 0 0 10 10 10
45668 - 38 38 38 86 86 86 50 50 50 6 6 6
45669 -128 128 128 174 154 114 156 107 11 168 122 10
45670 -198 155 10 184 144 12 197 138 11 200 144 11
45671 -206 145 10 206 145 10 197 138 11 188 164 115
45672 -195 195 195 198 198 198 174 174 174 14 14 14
45673 - 2 2 6 22 22 22 116 116 116 116 116 116
45674 - 22 22 22 2 2 6 74 74 74 70 70 70
45675 - 30 30 30 10 10 10 0 0 0 0 0 0
45676 - 0 0 0 0 0 0 0 0 0 0 0 0
45677 - 0 0 0 0 0 0 0 0 0 0 0 0
45678 - 0 0 0 0 0 0 0 0 0 0 0 0
45679 - 0 0 0 0 0 0 0 0 0 0 0 0
45680 - 0 0 0 0 0 0 0 0 0 0 0 0
45681 - 0 0 0 0 0 0 0 0 0 0 0 0
45682 - 0 0 0 0 0 0 0 0 0 0 0 0
45683 - 0 0 0 0 0 0 0 0 0 0 0 0
45684 - 0 0 0 0 0 0 0 0 0 0 0 0
45685 - 0 0 0 0 0 0 0 0 0 0 0 0
45686 - 0 0 0 0 0 0 0 0 0 0 0 0
45687 - 0 0 0 0 0 0 6 6 6 18 18 18
45688 - 50 50 50 101 101 101 26 26 26 10 10 10
45689 -138 138 138 190 190 190 174 154 114 156 107 11
45690 -197 138 11 200 144 11 197 138 11 192 133 9
45691 -180 123 7 190 142 34 190 178 144 187 187 187
45692 -202 202 202 221 221 221 214 214 214 66 66 66
45693 - 2 2 6 2 2 6 50 50 50 62 62 62
45694 - 6 6 6 2 2 6 10 10 10 90 90 90
45695 - 50 50 50 18 18 18 6 6 6 0 0 0
45696 - 0 0 0 0 0 0 0 0 0 0 0 0
45697 - 0 0 0 0 0 0 0 0 0 0 0 0
45698 - 0 0 0 0 0 0 0 0 0 0 0 0
45699 - 0 0 0 0 0 0 0 0 0 0 0 0
45700 - 0 0 0 0 0 0 0 0 0 0 0 0
45701 - 0 0 0 0 0 0 0 0 0 0 0 0
45702 - 0 0 0 0 0 0 0 0 0 0 0 0
45703 - 0 0 0 0 0 0 0 0 0 0 0 0
45704 - 0 0 0 0 0 0 0 0 0 0 0 0
45705 - 0 0 0 0 0 0 0 0 0 0 0 0
45706 - 0 0 0 0 0 0 0 0 0 0 0 0
45707 - 0 0 0 0 0 0 10 10 10 34 34 34
45708 - 74 74 74 74 74 74 2 2 6 6 6 6
45709 -144 144 144 198 198 198 190 190 190 178 166 146
45710 -154 121 60 156 107 11 156 107 11 168 124 44
45711 -174 154 114 187 187 187 190 190 190 210 210 210
45712 -246 246 246 253 253 253 253 253 253 182 182 182
45713 - 6 6 6 2 2 6 2 2 6 2 2 6
45714 - 2 2 6 2 2 6 2 2 6 62 62 62
45715 - 74 74 74 34 34 34 14 14 14 0 0 0
45716 - 0 0 0 0 0 0 0 0 0 0 0 0
45717 - 0 0 0 0 0 0 0 0 0 0 0 0
45718 - 0 0 0 0 0 0 0 0 0 0 0 0
45719 - 0 0 0 0 0 0 0 0 0 0 0 0
45720 - 0 0 0 0 0 0 0 0 0 0 0 0
45721 - 0 0 0 0 0 0 0 0 0 0 0 0
45722 - 0 0 0 0 0 0 0 0 0 0 0 0
45723 - 0 0 0 0 0 0 0 0 0 0 0 0
45724 - 0 0 0 0 0 0 0 0 0 0 0 0
45725 - 0 0 0 0 0 0 0 0 0 0 0 0
45726 - 0 0 0 0 0 0 0 0 0 0 0 0
45727 - 0 0 0 10 10 10 22 22 22 54 54 54
45728 - 94 94 94 18 18 18 2 2 6 46 46 46
45729 -234 234 234 221 221 221 190 190 190 190 190 190
45730 -190 190 190 187 187 187 187 187 187 190 190 190
45731 -190 190 190 195 195 195 214 214 214 242 242 242
45732 -253 253 253 253 253 253 253 253 253 253 253 253
45733 - 82 82 82 2 2 6 2 2 6 2 2 6
45734 - 2 2 6 2 2 6 2 2 6 14 14 14
45735 - 86 86 86 54 54 54 22 22 22 6 6 6
45736 - 0 0 0 0 0 0 0 0 0 0 0 0
45737 - 0 0 0 0 0 0 0 0 0 0 0 0
45738 - 0 0 0 0 0 0 0 0 0 0 0 0
45739 - 0 0 0 0 0 0 0 0 0 0 0 0
45740 - 0 0 0 0 0 0 0 0 0 0 0 0
45741 - 0 0 0 0 0 0 0 0 0 0 0 0
45742 - 0 0 0 0 0 0 0 0 0 0 0 0
45743 - 0 0 0 0 0 0 0 0 0 0 0 0
45744 - 0 0 0 0 0 0 0 0 0 0 0 0
45745 - 0 0 0 0 0 0 0 0 0 0 0 0
45746 - 0 0 0 0 0 0 0 0 0 0 0 0
45747 - 6 6 6 18 18 18 46 46 46 90 90 90
45748 - 46 46 46 18 18 18 6 6 6 182 182 182
45749 -253 253 253 246 246 246 206 206 206 190 190 190
45750 -190 190 190 190 190 190 190 190 190 190 190 190
45751 -206 206 206 231 231 231 250 250 250 253 253 253
45752 -253 253 253 253 253 253 253 253 253 253 253 253
45753 -202 202 202 14 14 14 2 2 6 2 2 6
45754 - 2 2 6 2 2 6 2 2 6 2 2 6
45755 - 42 42 42 86 86 86 42 42 42 18 18 18
45756 - 6 6 6 0 0 0 0 0 0 0 0 0
45757 - 0 0 0 0 0 0 0 0 0 0 0 0
45758 - 0 0 0 0 0 0 0 0 0 0 0 0
45759 - 0 0 0 0 0 0 0 0 0 0 0 0
45760 - 0 0 0 0 0 0 0 0 0 0 0 0
45761 - 0 0 0 0 0 0 0 0 0 0 0 0
45762 - 0 0 0 0 0 0 0 0 0 0 0 0
45763 - 0 0 0 0 0 0 0 0 0 0 0 0
45764 - 0 0 0 0 0 0 0 0 0 0 0 0
45765 - 0 0 0 0 0 0 0 0 0 0 0 0
45766 - 0 0 0 0 0 0 0 0 0 6 6 6
45767 - 14 14 14 38 38 38 74 74 74 66 66 66
45768 - 2 2 6 6 6 6 90 90 90 250 250 250
45769 -253 253 253 253 253 253 238 238 238 198 198 198
45770 -190 190 190 190 190 190 195 195 195 221 221 221
45771 -246 246 246 253 253 253 253 253 253 253 253 253
45772 -253 253 253 253 253 253 253 253 253 253 253 253
45773 -253 253 253 82 82 82 2 2 6 2 2 6
45774 - 2 2 6 2 2 6 2 2 6 2 2 6
45775 - 2 2 6 78 78 78 70 70 70 34 34 34
45776 - 14 14 14 6 6 6 0 0 0 0 0 0
45777 - 0 0 0 0 0 0 0 0 0 0 0 0
45778 - 0 0 0 0 0 0 0 0 0 0 0 0
45779 - 0 0 0 0 0 0 0 0 0 0 0 0
45780 - 0 0 0 0 0 0 0 0 0 0 0 0
45781 - 0 0 0 0 0 0 0 0 0 0 0 0
45782 - 0 0 0 0 0 0 0 0 0 0 0 0
45783 - 0 0 0 0 0 0 0 0 0 0 0 0
45784 - 0 0 0 0 0 0 0 0 0 0 0 0
45785 - 0 0 0 0 0 0 0 0 0 0 0 0
45786 - 0 0 0 0 0 0 0 0 0 14 14 14
45787 - 34 34 34 66 66 66 78 78 78 6 6 6
45788 - 2 2 6 18 18 18 218 218 218 253 253 253
45789 -253 253 253 253 253 253 253 253 253 246 246 246
45790 -226 226 226 231 231 231 246 246 246 253 253 253
45791 -253 253 253 253 253 253 253 253 253 253 253 253
45792 -253 253 253 253 253 253 253 253 253 253 253 253
45793 -253 253 253 178 178 178 2 2 6 2 2 6
45794 - 2 2 6 2 2 6 2 2 6 2 2 6
45795 - 2 2 6 18 18 18 90 90 90 62 62 62
45796 - 30 30 30 10 10 10 0 0 0 0 0 0
45797 - 0 0 0 0 0 0 0 0 0 0 0 0
45798 - 0 0 0 0 0 0 0 0 0 0 0 0
45799 - 0 0 0 0 0 0 0 0 0 0 0 0
45800 - 0 0 0 0 0 0 0 0 0 0 0 0
45801 - 0 0 0 0 0 0 0 0 0 0 0 0
45802 - 0 0 0 0 0 0 0 0 0 0 0 0
45803 - 0 0 0 0 0 0 0 0 0 0 0 0
45804 - 0 0 0 0 0 0 0 0 0 0 0 0
45805 - 0 0 0 0 0 0 0 0 0 0 0 0
45806 - 0 0 0 0 0 0 10 10 10 26 26 26
45807 - 58 58 58 90 90 90 18 18 18 2 2 6
45808 - 2 2 6 110 110 110 253 253 253 253 253 253
45809 -253 253 253 253 253 253 253 253 253 253 253 253
45810 -250 250 250 253 253 253 253 253 253 253 253 253
45811 -253 253 253 253 253 253 253 253 253 253 253 253
45812 -253 253 253 253 253 253 253 253 253 253 253 253
45813 -253 253 253 231 231 231 18 18 18 2 2 6
45814 - 2 2 6 2 2 6 2 2 6 2 2 6
45815 - 2 2 6 2 2 6 18 18 18 94 94 94
45816 - 54 54 54 26 26 26 10 10 10 0 0 0
45817 - 0 0 0 0 0 0 0 0 0 0 0 0
45818 - 0 0 0 0 0 0 0 0 0 0 0 0
45819 - 0 0 0 0 0 0 0 0 0 0 0 0
45820 - 0 0 0 0 0 0 0 0 0 0 0 0
45821 - 0 0 0 0 0 0 0 0 0 0 0 0
45822 - 0 0 0 0 0 0 0 0 0 0 0 0
45823 - 0 0 0 0 0 0 0 0 0 0 0 0
45824 - 0 0 0 0 0 0 0 0 0 0 0 0
45825 - 0 0 0 0 0 0 0 0 0 0 0 0
45826 - 0 0 0 6 6 6 22 22 22 50 50 50
45827 - 90 90 90 26 26 26 2 2 6 2 2 6
45828 - 14 14 14 195 195 195 250 250 250 253 253 253
45829 -253 253 253 253 253 253 253 253 253 253 253 253
45830 -253 253 253 253 253 253 253 253 253 253 253 253
45831 -253 253 253 253 253 253 253 253 253 253 253 253
45832 -253 253 253 253 253 253 253 253 253 253 253 253
45833 -250 250 250 242 242 242 54 54 54 2 2 6
45834 - 2 2 6 2 2 6 2 2 6 2 2 6
45835 - 2 2 6 2 2 6 2 2 6 38 38 38
45836 - 86 86 86 50 50 50 22 22 22 6 6 6
45837 - 0 0 0 0 0 0 0 0 0 0 0 0
45838 - 0 0 0 0 0 0 0 0 0 0 0 0
45839 - 0 0 0 0 0 0 0 0 0 0 0 0
45840 - 0 0 0 0 0 0 0 0 0 0 0 0
45841 - 0 0 0 0 0 0 0 0 0 0 0 0
45842 - 0 0 0 0 0 0 0 0 0 0 0 0
45843 - 0 0 0 0 0 0 0 0 0 0 0 0
45844 - 0 0 0 0 0 0 0 0 0 0 0 0
45845 - 0 0 0 0 0 0 0 0 0 0 0 0
45846 - 6 6 6 14 14 14 38 38 38 82 82 82
45847 - 34 34 34 2 2 6 2 2 6 2 2 6
45848 - 42 42 42 195 195 195 246 246 246 253 253 253
45849 -253 253 253 253 253 253 253 253 253 250 250 250
45850 -242 242 242 242 242 242 250 250 250 253 253 253
45851 -253 253 253 253 253 253 253 253 253 253 253 253
45852 -253 253 253 250 250 250 246 246 246 238 238 238
45853 -226 226 226 231 231 231 101 101 101 6 6 6
45854 - 2 2 6 2 2 6 2 2 6 2 2 6
45855 - 2 2 6 2 2 6 2 2 6 2 2 6
45856 - 38 38 38 82 82 82 42 42 42 14 14 14
45857 - 6 6 6 0 0 0 0 0 0 0 0 0
45858 - 0 0 0 0 0 0 0 0 0 0 0 0
45859 - 0 0 0 0 0 0 0 0 0 0 0 0
45860 - 0 0 0 0 0 0 0 0 0 0 0 0
45861 - 0 0 0 0 0 0 0 0 0 0 0 0
45862 - 0 0 0 0 0 0 0 0 0 0 0 0
45863 - 0 0 0 0 0 0 0 0 0 0 0 0
45864 - 0 0 0 0 0 0 0 0 0 0 0 0
45865 - 0 0 0 0 0 0 0 0 0 0 0 0
45866 - 10 10 10 26 26 26 62 62 62 66 66 66
45867 - 2 2 6 2 2 6 2 2 6 6 6 6
45868 - 70 70 70 170 170 170 206 206 206 234 234 234
45869 -246 246 246 250 250 250 250 250 250 238 238 238
45870 -226 226 226 231 231 231 238 238 238 250 250 250
45871 -250 250 250 250 250 250 246 246 246 231 231 231
45872 -214 214 214 206 206 206 202 202 202 202 202 202
45873 -198 198 198 202 202 202 182 182 182 18 18 18
45874 - 2 2 6 2 2 6 2 2 6 2 2 6
45875 - 2 2 6 2 2 6 2 2 6 2 2 6
45876 - 2 2 6 62 62 62 66 66 66 30 30 30
45877 - 10 10 10 0 0 0 0 0 0 0 0 0
45878 - 0 0 0 0 0 0 0 0 0 0 0 0
45879 - 0 0 0 0 0 0 0 0 0 0 0 0
45880 - 0 0 0 0 0 0 0 0 0 0 0 0
45881 - 0 0 0 0 0 0 0 0 0 0 0 0
45882 - 0 0 0 0 0 0 0 0 0 0 0 0
45883 - 0 0 0 0 0 0 0 0 0 0 0 0
45884 - 0 0 0 0 0 0 0 0 0 0 0 0
45885 - 0 0 0 0 0 0 0 0 0 0 0 0
45886 - 14 14 14 42 42 42 82 82 82 18 18 18
45887 - 2 2 6 2 2 6 2 2 6 10 10 10
45888 - 94 94 94 182 182 182 218 218 218 242 242 242
45889 -250 250 250 253 253 253 253 253 253 250 250 250
45890 -234 234 234 253 253 253 253 253 253 253 253 253
45891 -253 253 253 253 253 253 253 253 253 246 246 246
45892 -238 238 238 226 226 226 210 210 210 202 202 202
45893 -195 195 195 195 195 195 210 210 210 158 158 158
45894 - 6 6 6 14 14 14 50 50 50 14 14 14
45895 - 2 2 6 2 2 6 2 2 6 2 2 6
45896 - 2 2 6 6 6 6 86 86 86 46 46 46
45897 - 18 18 18 6 6 6 0 0 0 0 0 0
45898 - 0 0 0 0 0 0 0 0 0 0 0 0
45899 - 0 0 0 0 0 0 0 0 0 0 0 0
45900 - 0 0 0 0 0 0 0 0 0 0 0 0
45901 - 0 0 0 0 0 0 0 0 0 0 0 0
45902 - 0 0 0 0 0 0 0 0 0 0 0 0
45903 - 0 0 0 0 0 0 0 0 0 0 0 0
45904 - 0 0 0 0 0 0 0 0 0 0 0 0
45905 - 0 0 0 0 0 0 0 0 0 6 6 6
45906 - 22 22 22 54 54 54 70 70 70 2 2 6
45907 - 2 2 6 10 10 10 2 2 6 22 22 22
45908 -166 166 166 231 231 231 250 250 250 253 253 253
45909 -253 253 253 253 253 253 253 253 253 250 250 250
45910 -242 242 242 253 253 253 253 253 253 253 253 253
45911 -253 253 253 253 253 253 253 253 253 253 253 253
45912 -253 253 253 253 253 253 253 253 253 246 246 246
45913 -231 231 231 206 206 206 198 198 198 226 226 226
45914 - 94 94 94 2 2 6 6 6 6 38 38 38
45915 - 30 30 30 2 2 6 2 2 6 2 2 6
45916 - 2 2 6 2 2 6 62 62 62 66 66 66
45917 - 26 26 26 10 10 10 0 0 0 0 0 0
45918 - 0 0 0 0 0 0 0 0 0 0 0 0
45919 - 0 0 0 0 0 0 0 0 0 0 0 0
45920 - 0 0 0 0 0 0 0 0 0 0 0 0
45921 - 0 0 0 0 0 0 0 0 0 0 0 0
45922 - 0 0 0 0 0 0 0 0 0 0 0 0
45923 - 0 0 0 0 0 0 0 0 0 0 0 0
45924 - 0 0 0 0 0 0 0 0 0 0 0 0
45925 - 0 0 0 0 0 0 0 0 0 10 10 10
45926 - 30 30 30 74 74 74 50 50 50 2 2 6
45927 - 26 26 26 26 26 26 2 2 6 106 106 106
45928 -238 238 238 253 253 253 253 253 253 253 253 253
45929 -253 253 253 253 253 253 253 253 253 253 253 253
45930 -253 253 253 253 253 253 253 253 253 253 253 253
45931 -253 253 253 253 253 253 253 253 253 253 253 253
45932 -253 253 253 253 253 253 253 253 253 253 253 253
45933 -253 253 253 246 246 246 218 218 218 202 202 202
45934 -210 210 210 14 14 14 2 2 6 2 2 6
45935 - 30 30 30 22 22 22 2 2 6 2 2 6
45936 - 2 2 6 2 2 6 18 18 18 86 86 86
45937 - 42 42 42 14 14 14 0 0 0 0 0 0
45938 - 0 0 0 0 0 0 0 0 0 0 0 0
45939 - 0 0 0 0 0 0 0 0 0 0 0 0
45940 - 0 0 0 0 0 0 0 0 0 0 0 0
45941 - 0 0 0 0 0 0 0 0 0 0 0 0
45942 - 0 0 0 0 0 0 0 0 0 0 0 0
45943 - 0 0 0 0 0 0 0 0 0 0 0 0
45944 - 0 0 0 0 0 0 0 0 0 0 0 0
45945 - 0 0 0 0 0 0 0 0 0 14 14 14
45946 - 42 42 42 90 90 90 22 22 22 2 2 6
45947 - 42 42 42 2 2 6 18 18 18 218 218 218
45948 -253 253 253 253 253 253 253 253 253 253 253 253
45949 -253 253 253 253 253 253 253 253 253 253 253 253
45950 -253 253 253 253 253 253 253 253 253 253 253 253
45951 -253 253 253 253 253 253 253 253 253 253 253 253
45952 -253 253 253 253 253 253 253 253 253 253 253 253
45953 -253 253 253 253 253 253 250 250 250 221 221 221
45954 -218 218 218 101 101 101 2 2 6 14 14 14
45955 - 18 18 18 38 38 38 10 10 10 2 2 6
45956 - 2 2 6 2 2 6 2 2 6 78 78 78
45957 - 58 58 58 22 22 22 6 6 6 0 0 0
45958 - 0 0 0 0 0 0 0 0 0 0 0 0
45959 - 0 0 0 0 0 0 0 0 0 0 0 0
45960 - 0 0 0 0 0 0 0 0 0 0 0 0
45961 - 0 0 0 0 0 0 0 0 0 0 0 0
45962 - 0 0 0 0 0 0 0 0 0 0 0 0
45963 - 0 0 0 0 0 0 0 0 0 0 0 0
45964 - 0 0 0 0 0 0 0 0 0 0 0 0
45965 - 0 0 0 0 0 0 6 6 6 18 18 18
45966 - 54 54 54 82 82 82 2 2 6 26 26 26
45967 - 22 22 22 2 2 6 123 123 123 253 253 253
45968 -253 253 253 253 253 253 253 253 253 253 253 253
45969 -253 253 253 253 253 253 253 253 253 253 253 253
45970 -253 253 253 253 253 253 253 253 253 253 253 253
45971 -253 253 253 253 253 253 253 253 253 253 253 253
45972 -253 253 253 253 253 253 253 253 253 253 253 253
45973 -253 253 253 253 253 253 253 253 253 250 250 250
45974 -238 238 238 198 198 198 6 6 6 38 38 38
45975 - 58 58 58 26 26 26 38 38 38 2 2 6
45976 - 2 2 6 2 2 6 2 2 6 46 46 46
45977 - 78 78 78 30 30 30 10 10 10 0 0 0
45978 - 0 0 0 0 0 0 0 0 0 0 0 0
45979 - 0 0 0 0 0 0 0 0 0 0 0 0
45980 - 0 0 0 0 0 0 0 0 0 0 0 0
45981 - 0 0 0 0 0 0 0 0 0 0 0 0
45982 - 0 0 0 0 0 0 0 0 0 0 0 0
45983 - 0 0 0 0 0 0 0 0 0 0 0 0
45984 - 0 0 0 0 0 0 0 0 0 0 0 0
45985 - 0 0 0 0 0 0 10 10 10 30 30 30
45986 - 74 74 74 58 58 58 2 2 6 42 42 42
45987 - 2 2 6 22 22 22 231 231 231 253 253 253
45988 -253 253 253 253 253 253 253 253 253 253 253 253
45989 -253 253 253 253 253 253 253 253 253 250 250 250
45990 -253 253 253 253 253 253 253 253 253 253 253 253
45991 -253 253 253 253 253 253 253 253 253 253 253 253
45992 -253 253 253 253 253 253 253 253 253 253 253 253
45993 -253 253 253 253 253 253 253 253 253 253 253 253
45994 -253 253 253 246 246 246 46 46 46 38 38 38
45995 - 42 42 42 14 14 14 38 38 38 14 14 14
45996 - 2 2 6 2 2 6 2 2 6 6 6 6
45997 - 86 86 86 46 46 46 14 14 14 0 0 0
45998 - 0 0 0 0 0 0 0 0 0 0 0 0
45999 - 0 0 0 0 0 0 0 0 0 0 0 0
46000 - 0 0 0 0 0 0 0 0 0 0 0 0
46001 - 0 0 0 0 0 0 0 0 0 0 0 0
46002 - 0 0 0 0 0 0 0 0 0 0 0 0
46003 - 0 0 0 0 0 0 0 0 0 0 0 0
46004 - 0 0 0 0 0 0 0 0 0 0 0 0
46005 - 0 0 0 6 6 6 14 14 14 42 42 42
46006 - 90 90 90 18 18 18 18 18 18 26 26 26
46007 - 2 2 6 116 116 116 253 253 253 253 253 253
46008 -253 253 253 253 253 253 253 253 253 253 253 253
46009 -253 253 253 253 253 253 250 250 250 238 238 238
46010 -253 253 253 253 253 253 253 253 253 253 253 253
46011 -253 253 253 253 253 253 253 253 253 253 253 253
46012 -253 253 253 253 253 253 253 253 253 253 253 253
46013 -253 253 253 253 253 253 253 253 253 253 253 253
46014 -253 253 253 253 253 253 94 94 94 6 6 6
46015 - 2 2 6 2 2 6 10 10 10 34 34 34
46016 - 2 2 6 2 2 6 2 2 6 2 2 6
46017 - 74 74 74 58 58 58 22 22 22 6 6 6
46018 - 0 0 0 0 0 0 0 0 0 0 0 0
46019 - 0 0 0 0 0 0 0 0 0 0 0 0
46020 - 0 0 0 0 0 0 0 0 0 0 0 0
46021 - 0 0 0 0 0 0 0 0 0 0 0 0
46022 - 0 0 0 0 0 0 0 0 0 0 0 0
46023 - 0 0 0 0 0 0 0 0 0 0 0 0
46024 - 0 0 0 0 0 0 0 0 0 0 0 0
46025 - 0 0 0 10 10 10 26 26 26 66 66 66
46026 - 82 82 82 2 2 6 38 38 38 6 6 6
46027 - 14 14 14 210 210 210 253 253 253 253 253 253
46028 -253 253 253 253 253 253 253 253 253 253 253 253
46029 -253 253 253 253 253 253 246 246 246 242 242 242
46030 -253 253 253 253 253 253 253 253 253 253 253 253
46031 -253 253 253 253 253 253 253 253 253 253 253 253
46032 -253 253 253 253 253 253 253 253 253 253 253 253
46033 -253 253 253 253 253 253 253 253 253 253 253 253
46034 -253 253 253 253 253 253 144 144 144 2 2 6
46035 - 2 2 6 2 2 6 2 2 6 46 46 46
46036 - 2 2 6 2 2 6 2 2 6 2 2 6
46037 - 42 42 42 74 74 74 30 30 30 10 10 10
46038 - 0 0 0 0 0 0 0 0 0 0 0 0
46039 - 0 0 0 0 0 0 0 0 0 0 0 0
46040 - 0 0 0 0 0 0 0 0 0 0 0 0
46041 - 0 0 0 0 0 0 0 0 0 0 0 0
46042 - 0 0 0 0 0 0 0 0 0 0 0 0
46043 - 0 0 0 0 0 0 0 0 0 0 0 0
46044 - 0 0 0 0 0 0 0 0 0 0 0 0
46045 - 6 6 6 14 14 14 42 42 42 90 90 90
46046 - 26 26 26 6 6 6 42 42 42 2 2 6
46047 - 74 74 74 250 250 250 253 253 253 253 253 253
46048 -253 253 253 253 253 253 253 253 253 253 253 253
46049 -253 253 253 253 253 253 242 242 242 242 242 242
46050 -253 253 253 253 253 253 253 253 253 253 253 253
46051 -253 253 253 253 253 253 253 253 253 253 253 253
46052 -253 253 253 253 253 253 253 253 253 253 253 253
46053 -253 253 253 253 253 253 253 253 253 253 253 253
46054 -253 253 253 253 253 253 182 182 182 2 2 6
46055 - 2 2 6 2 2 6 2 2 6 46 46 46
46056 - 2 2 6 2 2 6 2 2 6 2 2 6
46057 - 10 10 10 86 86 86 38 38 38 10 10 10
46058 - 0 0 0 0 0 0 0 0 0 0 0 0
46059 - 0 0 0 0 0 0 0 0 0 0 0 0
46060 - 0 0 0 0 0 0 0 0 0 0 0 0
46061 - 0 0 0 0 0 0 0 0 0 0 0 0
46062 - 0 0 0 0 0 0 0 0 0 0 0 0
46063 - 0 0 0 0 0 0 0 0 0 0 0 0
46064 - 0 0 0 0 0 0 0 0 0 0 0 0
46065 - 10 10 10 26 26 26 66 66 66 82 82 82
46066 - 2 2 6 22 22 22 18 18 18 2 2 6
46067 -149 149 149 253 253 253 253 253 253 253 253 253
46068 -253 253 253 253 253 253 253 253 253 253 253 253
46069 -253 253 253 253 253 253 234 234 234 242 242 242
46070 -253 253 253 253 253 253 253 253 253 253 253 253
46071 -253 253 253 253 253 253 253 253 253 253 253 253
46072 -253 253 253 253 253 253 253 253 253 253 253 253
46073 -253 253 253 253 253 253 253 253 253 253 253 253
46074 -253 253 253 253 253 253 206 206 206 2 2 6
46075 - 2 2 6 2 2 6 2 2 6 38 38 38
46076 - 2 2 6 2 2 6 2 2 6 2 2 6
46077 - 6 6 6 86 86 86 46 46 46 14 14 14
46078 - 0 0 0 0 0 0 0 0 0 0 0 0
46079 - 0 0 0 0 0 0 0 0 0 0 0 0
46080 - 0 0 0 0 0 0 0 0 0 0 0 0
46081 - 0 0 0 0 0 0 0 0 0 0 0 0
46082 - 0 0 0 0 0 0 0 0 0 0 0 0
46083 - 0 0 0 0 0 0 0 0 0 0 0 0
46084 - 0 0 0 0 0 0 0 0 0 6 6 6
46085 - 18 18 18 46 46 46 86 86 86 18 18 18
46086 - 2 2 6 34 34 34 10 10 10 6 6 6
46087 -210 210 210 253 253 253 253 253 253 253 253 253
46088 -253 253 253 253 253 253 253 253 253 253 253 253
46089 -253 253 253 253 253 253 234 234 234 242 242 242
46090 -253 253 253 253 253 253 253 253 253 253 253 253
46091 -253 253 253 253 253 253 253 253 253 253 253 253
46092 -253 253 253 253 253 253 253 253 253 253 253 253
46093 -253 253 253 253 253 253 253 253 253 253 253 253
46094 -253 253 253 253 253 253 221 221 221 6 6 6
46095 - 2 2 6 2 2 6 6 6 6 30 30 30
46096 - 2 2 6 2 2 6 2 2 6 2 2 6
46097 - 2 2 6 82 82 82 54 54 54 18 18 18
46098 - 6 6 6 0 0 0 0 0 0 0 0 0
46099 - 0 0 0 0 0 0 0 0 0 0 0 0
46100 - 0 0 0 0 0 0 0 0 0 0 0 0
46101 - 0 0 0 0 0 0 0 0 0 0 0 0
46102 - 0 0 0 0 0 0 0 0 0 0 0 0
46103 - 0 0 0 0 0 0 0 0 0 0 0 0
46104 - 0 0 0 0 0 0 0 0 0 10 10 10
46105 - 26 26 26 66 66 66 62 62 62 2 2 6
46106 - 2 2 6 38 38 38 10 10 10 26 26 26
46107 -238 238 238 253 253 253 253 253 253 253 253 253
46108 -253 253 253 253 253 253 253 253 253 253 253 253
46109 -253 253 253 253 253 253 231 231 231 238 238 238
46110 -253 253 253 253 253 253 253 253 253 253 253 253
46111 -253 253 253 253 253 253 253 253 253 253 253 253
46112 -253 253 253 253 253 253 253 253 253 253 253 253
46113 -253 253 253 253 253 253 253 253 253 253 253 253
46114 -253 253 253 253 253 253 231 231 231 6 6 6
46115 - 2 2 6 2 2 6 10 10 10 30 30 30
46116 - 2 2 6 2 2 6 2 2 6 2 2 6
46117 - 2 2 6 66 66 66 58 58 58 22 22 22
46118 - 6 6 6 0 0 0 0 0 0 0 0 0
46119 - 0 0 0 0 0 0 0 0 0 0 0 0
46120 - 0 0 0 0 0 0 0 0 0 0 0 0
46121 - 0 0 0 0 0 0 0 0 0 0 0 0
46122 - 0 0 0 0 0 0 0 0 0 0 0 0
46123 - 0 0 0 0 0 0 0 0 0 0 0 0
46124 - 0 0 0 0 0 0 0 0 0 10 10 10
46125 - 38 38 38 78 78 78 6 6 6 2 2 6
46126 - 2 2 6 46 46 46 14 14 14 42 42 42
46127 -246 246 246 253 253 253 253 253 253 253 253 253
46128 -253 253 253 253 253 253 253 253 253 253 253 253
46129 -253 253 253 253 253 253 231 231 231 242 242 242
46130 -253 253 253 253 253 253 253 253 253 253 253 253
46131 -253 253 253 253 253 253 253 253 253 253 253 253
46132 -253 253 253 253 253 253 253 253 253 253 253 253
46133 -253 253 253 253 253 253 253 253 253 253 253 253
46134 -253 253 253 253 253 253 234 234 234 10 10 10
46135 - 2 2 6 2 2 6 22 22 22 14 14 14
46136 - 2 2 6 2 2 6 2 2 6 2 2 6
46137 - 2 2 6 66 66 66 62 62 62 22 22 22
46138 - 6 6 6 0 0 0 0 0 0 0 0 0
46139 - 0 0 0 0 0 0 0 0 0 0 0 0
46140 - 0 0 0 0 0 0 0 0 0 0 0 0
46141 - 0 0 0 0 0 0 0 0 0 0 0 0
46142 - 0 0 0 0 0 0 0 0 0 0 0 0
46143 - 0 0 0 0 0 0 0 0 0 0 0 0
46144 - 0 0 0 0 0 0 6 6 6 18 18 18
46145 - 50 50 50 74 74 74 2 2 6 2 2 6
46146 - 14 14 14 70 70 70 34 34 34 62 62 62
46147 -250 250 250 253 253 253 253 253 253 253 253 253
46148 -253 253 253 253 253 253 253 253 253 253 253 253
46149 -253 253 253 253 253 253 231 231 231 246 246 246
46150 -253 253 253 253 253 253 253 253 253 253 253 253
46151 -253 253 253 253 253 253 253 253 253 253 253 253
46152 -253 253 253 253 253 253 253 253 253 253 253 253
46153 -253 253 253 253 253 253 253 253 253 253 253 253
46154 -253 253 253 253 253 253 234 234 234 14 14 14
46155 - 2 2 6 2 2 6 30 30 30 2 2 6
46156 - 2 2 6 2 2 6 2 2 6 2 2 6
46157 - 2 2 6 66 66 66 62 62 62 22 22 22
46158 - 6 6 6 0 0 0 0 0 0 0 0 0
46159 - 0 0 0 0 0 0 0 0 0 0 0 0
46160 - 0 0 0 0 0 0 0 0 0 0 0 0
46161 - 0 0 0 0 0 0 0 0 0 0 0 0
46162 - 0 0 0 0 0 0 0 0 0 0 0 0
46163 - 0 0 0 0 0 0 0 0 0 0 0 0
46164 - 0 0 0 0 0 0 6 6 6 18 18 18
46165 - 54 54 54 62 62 62 2 2 6 2 2 6
46166 - 2 2 6 30 30 30 46 46 46 70 70 70
46167 -250 250 250 253 253 253 253 253 253 253 253 253
46168 -253 253 253 253 253 253 253 253 253 253 253 253
46169 -253 253 253 253 253 253 231 231 231 246 246 246
46170 -253 253 253 253 253 253 253 253 253 253 253 253
46171 -253 253 253 253 253 253 253 253 253 253 253 253
46172 -253 253 253 253 253 253 253 253 253 253 253 253
46173 -253 253 253 253 253 253 253 253 253 253 253 253
46174 -253 253 253 253 253 253 226 226 226 10 10 10
46175 - 2 2 6 6 6 6 30 30 30 2 2 6
46176 - 2 2 6 2 2 6 2 2 6 2 2 6
46177 - 2 2 6 66 66 66 58 58 58 22 22 22
46178 - 6 6 6 0 0 0 0 0 0 0 0 0
46179 - 0 0 0 0 0 0 0 0 0 0 0 0
46180 - 0 0 0 0 0 0 0 0 0 0 0 0
46181 - 0 0 0 0 0 0 0 0 0 0 0 0
46182 - 0 0 0 0 0 0 0 0 0 0 0 0
46183 - 0 0 0 0 0 0 0 0 0 0 0 0
46184 - 0 0 0 0 0 0 6 6 6 22 22 22
46185 - 58 58 58 62 62 62 2 2 6 2 2 6
46186 - 2 2 6 2 2 6 30 30 30 78 78 78
46187 -250 250 250 253 253 253 253 253 253 253 253 253
46188 -253 253 253 253 253 253 253 253 253 253 253 253
46189 -253 253 253 253 253 253 231 231 231 246 246 246
46190 -253 253 253 253 253 253 253 253 253 253 253 253
46191 -253 253 253 253 253 253 253 253 253 253 253 253
46192 -253 253 253 253 253 253 253 253 253 253 253 253
46193 -253 253 253 253 253 253 253 253 253 253 253 253
46194 -253 253 253 253 253 253 206 206 206 2 2 6
46195 - 22 22 22 34 34 34 18 14 6 22 22 22
46196 - 26 26 26 18 18 18 6 6 6 2 2 6
46197 - 2 2 6 82 82 82 54 54 54 18 18 18
46198 - 6 6 6 0 0 0 0 0 0 0 0 0
46199 - 0 0 0 0 0 0 0 0 0 0 0 0
46200 - 0 0 0 0 0 0 0 0 0 0 0 0
46201 - 0 0 0 0 0 0 0 0 0 0 0 0
46202 - 0 0 0 0 0 0 0 0 0 0 0 0
46203 - 0 0 0 0 0 0 0 0 0 0 0 0
46204 - 0 0 0 0 0 0 6 6 6 26 26 26
46205 - 62 62 62 106 106 106 74 54 14 185 133 11
46206 -210 162 10 121 92 8 6 6 6 62 62 62
46207 -238 238 238 253 253 253 253 253 253 253 253 253
46208 -253 253 253 253 253 253 253 253 253 253 253 253
46209 -253 253 253 253 253 253 231 231 231 246 246 246
46210 -253 253 253 253 253 253 253 253 253 253 253 253
46211 -253 253 253 253 253 253 253 253 253 253 253 253
46212 -253 253 253 253 253 253 253 253 253 253 253 253
46213 -253 253 253 253 253 253 253 253 253 253 253 253
46214 -253 253 253 253 253 253 158 158 158 18 18 18
46215 - 14 14 14 2 2 6 2 2 6 2 2 6
46216 - 6 6 6 18 18 18 66 66 66 38 38 38
46217 - 6 6 6 94 94 94 50 50 50 18 18 18
46218 - 6 6 6 0 0 0 0 0 0 0 0 0
46219 - 0 0 0 0 0 0 0 0 0 0 0 0
46220 - 0 0 0 0 0 0 0 0 0 0 0 0
46221 - 0 0 0 0 0 0 0 0 0 0 0 0
46222 - 0 0 0 0 0 0 0 0 0 0 0 0
46223 - 0 0 0 0 0 0 0 0 0 6 6 6
46224 - 10 10 10 10 10 10 18 18 18 38 38 38
46225 - 78 78 78 142 134 106 216 158 10 242 186 14
46226 -246 190 14 246 190 14 156 118 10 10 10 10
46227 - 90 90 90 238 238 238 253 253 253 253 253 253
46228 -253 253 253 253 253 253 253 253 253 253 253 253
46229 -253 253 253 253 253 253 231 231 231 250 250 250
46230 -253 253 253 253 253 253 253 253 253 253 253 253
46231 -253 253 253 253 253 253 253 253 253 253 253 253
46232 -253 253 253 253 253 253 253 253 253 253 253 253
46233 -253 253 253 253 253 253 253 253 253 246 230 190
46234 -238 204 91 238 204 91 181 142 44 37 26 9
46235 - 2 2 6 2 2 6 2 2 6 2 2 6
46236 - 2 2 6 2 2 6 38 38 38 46 46 46
46237 - 26 26 26 106 106 106 54 54 54 18 18 18
46238 - 6 6 6 0 0 0 0 0 0 0 0 0
46239 - 0 0 0 0 0 0 0 0 0 0 0 0
46240 - 0 0 0 0 0 0 0 0 0 0 0 0
46241 - 0 0 0 0 0 0 0 0 0 0 0 0
46242 - 0 0 0 0 0 0 0 0 0 0 0 0
46243 - 0 0 0 6 6 6 14 14 14 22 22 22
46244 - 30 30 30 38 38 38 50 50 50 70 70 70
46245 -106 106 106 190 142 34 226 170 11 242 186 14
46246 -246 190 14 246 190 14 246 190 14 154 114 10
46247 - 6 6 6 74 74 74 226 226 226 253 253 253
46248 -253 253 253 253 253 253 253 253 253 253 253 253
46249 -253 253 253 253 253 253 231 231 231 250 250 250
46250 -253 253 253 253 253 253 253 253 253 253 253 253
46251 -253 253 253 253 253 253 253 253 253 253 253 253
46252 -253 253 253 253 253 253 253 253 253 253 253 253
46253 -253 253 253 253 253 253 253 253 253 228 184 62
46254 -241 196 14 241 208 19 232 195 16 38 30 10
46255 - 2 2 6 2 2 6 2 2 6 2 2 6
46256 - 2 2 6 6 6 6 30 30 30 26 26 26
46257 -203 166 17 154 142 90 66 66 66 26 26 26
46258 - 6 6 6 0 0 0 0 0 0 0 0 0
46259 - 0 0 0 0 0 0 0 0 0 0 0 0
46260 - 0 0 0 0 0 0 0 0 0 0 0 0
46261 - 0 0 0 0 0 0 0 0 0 0 0 0
46262 - 0 0 0 0 0 0 0 0 0 0 0 0
46263 - 6 6 6 18 18 18 38 38 38 58 58 58
46264 - 78 78 78 86 86 86 101 101 101 123 123 123
46265 -175 146 61 210 150 10 234 174 13 246 186 14
46266 -246 190 14 246 190 14 246 190 14 238 190 10
46267 -102 78 10 2 2 6 46 46 46 198 198 198
46268 -253 253 253 253 253 253 253 253 253 253 253 253
46269 -253 253 253 253 253 253 234 234 234 242 242 242
46270 -253 253 253 253 253 253 253 253 253 253 253 253
46271 -253 253 253 253 253 253 253 253 253 253 253 253
46272 -253 253 253 253 253 253 253 253 253 253 253 253
46273 -253 253 253 253 253 253 253 253 253 224 178 62
46274 -242 186 14 241 196 14 210 166 10 22 18 6
46275 - 2 2 6 2 2 6 2 2 6 2 2 6
46276 - 2 2 6 2 2 6 6 6 6 121 92 8
46277 -238 202 15 232 195 16 82 82 82 34 34 34
46278 - 10 10 10 0 0 0 0 0 0 0 0 0
46279 - 0 0 0 0 0 0 0 0 0 0 0 0
46280 - 0 0 0 0 0 0 0 0 0 0 0 0
46281 - 0 0 0 0 0 0 0 0 0 0 0 0
46282 - 0 0 0 0 0 0 0 0 0 0 0 0
46283 - 14 14 14 38 38 38 70 70 70 154 122 46
46284 -190 142 34 200 144 11 197 138 11 197 138 11
46285 -213 154 11 226 170 11 242 186 14 246 190 14
46286 -246 190 14 246 190 14 246 190 14 246 190 14
46287 -225 175 15 46 32 6 2 2 6 22 22 22
46288 -158 158 158 250 250 250 253 253 253 253 253 253
46289 -253 253 253 253 253 253 253 253 253 253 253 253
46290 -253 253 253 253 253 253 253 253 253 253 253 253
46291 -253 253 253 253 253 253 253 253 253 253 253 253
46292 -253 253 253 253 253 253 253 253 253 253 253 253
46293 -253 253 253 250 250 250 242 242 242 224 178 62
46294 -239 182 13 236 186 11 213 154 11 46 32 6
46295 - 2 2 6 2 2 6 2 2 6 2 2 6
46296 - 2 2 6 2 2 6 61 42 6 225 175 15
46297 -238 190 10 236 186 11 112 100 78 42 42 42
46298 - 14 14 14 0 0 0 0 0 0 0 0 0
46299 - 0 0 0 0 0 0 0 0 0 0 0 0
46300 - 0 0 0 0 0 0 0 0 0 0 0 0
46301 - 0 0 0 0 0 0 0 0 0 0 0 0
46302 - 0 0 0 0 0 0 0 0 0 6 6 6
46303 - 22 22 22 54 54 54 154 122 46 213 154 11
46304 -226 170 11 230 174 11 226 170 11 226 170 11
46305 -236 178 12 242 186 14 246 190 14 246 190 14
46306 -246 190 14 246 190 14 246 190 14 246 190 14
46307 -241 196 14 184 144 12 10 10 10 2 2 6
46308 - 6 6 6 116 116 116 242 242 242 253 253 253
46309 -253 253 253 253 253 253 253 253 253 253 253 253
46310 -253 253 253 253 253 253 253 253 253 253 253 253
46311 -253 253 253 253 253 253 253 253 253 253 253 253
46312 -253 253 253 253 253 253 253 253 253 253 253 253
46313 -253 253 253 231 231 231 198 198 198 214 170 54
46314 -236 178 12 236 178 12 210 150 10 137 92 6
46315 - 18 14 6 2 2 6 2 2 6 2 2 6
46316 - 6 6 6 70 47 6 200 144 11 236 178 12
46317 -239 182 13 239 182 13 124 112 88 58 58 58
46318 - 22 22 22 6 6 6 0 0 0 0 0 0
46319 - 0 0 0 0 0 0 0 0 0 0 0 0
46320 - 0 0 0 0 0 0 0 0 0 0 0 0
46321 - 0 0 0 0 0 0 0 0 0 0 0 0
46322 - 0 0 0 0 0 0 0 0 0 10 10 10
46323 - 30 30 30 70 70 70 180 133 36 226 170 11
46324 -239 182 13 242 186 14 242 186 14 246 186 14
46325 -246 190 14 246 190 14 246 190 14 246 190 14
46326 -246 190 14 246 190 14 246 190 14 246 190 14
46327 -246 190 14 232 195 16 98 70 6 2 2 6
46328 - 2 2 6 2 2 6 66 66 66 221 221 221
46329 -253 253 253 253 253 253 253 253 253 253 253 253
46330 -253 253 253 253 253 253 253 253 253 253 253 253
46331 -253 253 253 253 253 253 253 253 253 253 253 253
46332 -253 253 253 253 253 253 253 253 253 253 253 253
46333 -253 253 253 206 206 206 198 198 198 214 166 58
46334 -230 174 11 230 174 11 216 158 10 192 133 9
46335 -163 110 8 116 81 8 102 78 10 116 81 8
46336 -167 114 7 197 138 11 226 170 11 239 182 13
46337 -242 186 14 242 186 14 162 146 94 78 78 78
46338 - 34 34 34 14 14 14 6 6 6 0 0 0
46339 - 0 0 0 0 0 0 0 0 0 0 0 0
46340 - 0 0 0 0 0 0 0 0 0 0 0 0
46341 - 0 0 0 0 0 0 0 0 0 0 0 0
46342 - 0 0 0 0 0 0 0 0 0 6 6 6
46343 - 30 30 30 78 78 78 190 142 34 226 170 11
46344 -239 182 13 246 190 14 246 190 14 246 190 14
46345 -246 190 14 246 190 14 246 190 14 246 190 14
46346 -246 190 14 246 190 14 246 190 14 246 190 14
46347 -246 190 14 241 196 14 203 166 17 22 18 6
46348 - 2 2 6 2 2 6 2 2 6 38 38 38
46349 -218 218 218 253 253 253 253 253 253 253 253 253
46350 -253 253 253 253 253 253 253 253 253 253 253 253
46351 -253 253 253 253 253 253 253 253 253 253 253 253
46352 -253 253 253 253 253 253 253 253 253 253 253 253
46353 -250 250 250 206 206 206 198 198 198 202 162 69
46354 -226 170 11 236 178 12 224 166 10 210 150 10
46355 -200 144 11 197 138 11 192 133 9 197 138 11
46356 -210 150 10 226 170 11 242 186 14 246 190 14
46357 -246 190 14 246 186 14 225 175 15 124 112 88
46358 - 62 62 62 30 30 30 14 14 14 6 6 6
46359 - 0 0 0 0 0 0 0 0 0 0 0 0
46360 - 0 0 0 0 0 0 0 0 0 0 0 0
46361 - 0 0 0 0 0 0 0 0 0 0 0 0
46362 - 0 0 0 0 0 0 0 0 0 10 10 10
46363 - 30 30 30 78 78 78 174 135 50 224 166 10
46364 -239 182 13 246 190 14 246 190 14 246 190 14
46365 -246 190 14 246 190 14 246 190 14 246 190 14
46366 -246 190 14 246 190 14 246 190 14 246 190 14
46367 -246 190 14 246 190 14 241 196 14 139 102 15
46368 - 2 2 6 2 2 6 2 2 6 2 2 6
46369 - 78 78 78 250 250 250 253 253 253 253 253 253
46370 -253 253 253 253 253 253 253 253 253 253 253 253
46371 -253 253 253 253 253 253 253 253 253 253 253 253
46372 -253 253 253 253 253 253 253 253 253 253 253 253
46373 -250 250 250 214 214 214 198 198 198 190 150 46
46374 -219 162 10 236 178 12 234 174 13 224 166 10
46375 -216 158 10 213 154 11 213 154 11 216 158 10
46376 -226 170 11 239 182 13 246 190 14 246 190 14
46377 -246 190 14 246 190 14 242 186 14 206 162 42
46378 -101 101 101 58 58 58 30 30 30 14 14 14
46379 - 6 6 6 0 0 0 0 0 0 0 0 0
46380 - 0 0 0 0 0 0 0 0 0 0 0 0
46381 - 0 0 0 0 0 0 0 0 0 0 0 0
46382 - 0 0 0 0 0 0 0 0 0 10 10 10
46383 - 30 30 30 74 74 74 174 135 50 216 158 10
46384 -236 178 12 246 190 14 246 190 14 246 190 14
46385 -246 190 14 246 190 14 246 190 14 246 190 14
46386 -246 190 14 246 190 14 246 190 14 246 190 14
46387 -246 190 14 246 190 14 241 196 14 226 184 13
46388 - 61 42 6 2 2 6 2 2 6 2 2 6
46389 - 22 22 22 238 238 238 253 253 253 253 253 253
46390 -253 253 253 253 253 253 253 253 253 253 253 253
46391 -253 253 253 253 253 253 253 253 253 253 253 253
46392 -253 253 253 253 253 253 253 253 253 253 253 253
46393 -253 253 253 226 226 226 187 187 187 180 133 36
46394 -216 158 10 236 178 12 239 182 13 236 178 12
46395 -230 174 11 226 170 11 226 170 11 230 174 11
46396 -236 178 12 242 186 14 246 190 14 246 190 14
46397 -246 190 14 246 190 14 246 186 14 239 182 13
46398 -206 162 42 106 106 106 66 66 66 34 34 34
46399 - 14 14 14 6 6 6 0 0 0 0 0 0
46400 - 0 0 0 0 0 0 0 0 0 0 0 0
46401 - 0 0 0 0 0 0 0 0 0 0 0 0
46402 - 0 0 0 0 0 0 0 0 0 6 6 6
46403 - 26 26 26 70 70 70 163 133 67 213 154 11
46404 -236 178 12 246 190 14 246 190 14 246 190 14
46405 -246 190 14 246 190 14 246 190 14 246 190 14
46406 -246 190 14 246 190 14 246 190 14 246 190 14
46407 -246 190 14 246 190 14 246 190 14 241 196 14
46408 -190 146 13 18 14 6 2 2 6 2 2 6
46409 - 46 46 46 246 246 246 253 253 253 253 253 253
46410 -253 253 253 253 253 253 253 253 253 253 253 253
46411 -253 253 253 253 253 253 253 253 253 253 253 253
46412 -253 253 253 253 253 253 253 253 253 253 253 253
46413 -253 253 253 221 221 221 86 86 86 156 107 11
46414 -216 158 10 236 178 12 242 186 14 246 186 14
46415 -242 186 14 239 182 13 239 182 13 242 186 14
46416 -242 186 14 246 186 14 246 190 14 246 190 14
46417 -246 190 14 246 190 14 246 190 14 246 190 14
46418 -242 186 14 225 175 15 142 122 72 66 66 66
46419 - 30 30 30 10 10 10 0 0 0 0 0 0
46420 - 0 0 0 0 0 0 0 0 0 0 0 0
46421 - 0 0 0 0 0 0 0 0 0 0 0 0
46422 - 0 0 0 0 0 0 0 0 0 6 6 6
46423 - 26 26 26 70 70 70 163 133 67 210 150 10
46424 -236 178 12 246 190 14 246 190 14 246 190 14
46425 -246 190 14 246 190 14 246 190 14 246 190 14
46426 -246 190 14 246 190 14 246 190 14 246 190 14
46427 -246 190 14 246 190 14 246 190 14 246 190 14
46428 -232 195 16 121 92 8 34 34 34 106 106 106
46429 -221 221 221 253 253 253 253 253 253 253 253 253
46430 -253 253 253 253 253 253 253 253 253 253 253 253
46431 -253 253 253 253 253 253 253 253 253 253 253 253
46432 -253 253 253 253 253 253 253 253 253 253 253 253
46433 -242 242 242 82 82 82 18 14 6 163 110 8
46434 -216 158 10 236 178 12 242 186 14 246 190 14
46435 -246 190 14 246 190 14 246 190 14 246 190 14
46436 -246 190 14 246 190 14 246 190 14 246 190 14
46437 -246 190 14 246 190 14 246 190 14 246 190 14
46438 -246 190 14 246 190 14 242 186 14 163 133 67
46439 - 46 46 46 18 18 18 6 6 6 0 0 0
46440 - 0 0 0 0 0 0 0 0 0 0 0 0
46441 - 0 0 0 0 0 0 0 0 0 0 0 0
46442 - 0 0 0 0 0 0 0 0 0 10 10 10
46443 - 30 30 30 78 78 78 163 133 67 210 150 10
46444 -236 178 12 246 186 14 246 190 14 246 190 14
46445 -246 190 14 246 190 14 246 190 14 246 190 14
46446 -246 190 14 246 190 14 246 190 14 246 190 14
46447 -246 190 14 246 190 14 246 190 14 246 190 14
46448 -241 196 14 215 174 15 190 178 144 253 253 253
46449 -253 253 253 253 253 253 253 253 253 253 253 253
46450 -253 253 253 253 253 253 253 253 253 253 253 253
46451 -253 253 253 253 253 253 253 253 253 253 253 253
46452 -253 253 253 253 253 253 253 253 253 218 218 218
46453 - 58 58 58 2 2 6 22 18 6 167 114 7
46454 -216 158 10 236 178 12 246 186 14 246 190 14
46455 -246 190 14 246 190 14 246 190 14 246 190 14
46456 -246 190 14 246 190 14 246 190 14 246 190 14
46457 -246 190 14 246 190 14 246 190 14 246 190 14
46458 -246 190 14 246 186 14 242 186 14 190 150 46
46459 - 54 54 54 22 22 22 6 6 6 0 0 0
46460 - 0 0 0 0 0 0 0 0 0 0 0 0
46461 - 0 0 0 0 0 0 0 0 0 0 0 0
46462 - 0 0 0 0 0 0 0 0 0 14 14 14
46463 - 38 38 38 86 86 86 180 133 36 213 154 11
46464 -236 178 12 246 186 14 246 190 14 246 190 14
46465 -246 190 14 246 190 14 246 190 14 246 190 14
46466 -246 190 14 246 190 14 246 190 14 246 190 14
46467 -246 190 14 246 190 14 246 190 14 246 190 14
46468 -246 190 14 232 195 16 190 146 13 214 214 214
46469 -253 253 253 253 253 253 253 253 253 253 253 253
46470 -253 253 253 253 253 253 253 253 253 253 253 253
46471 -253 253 253 253 253 253 253 253 253 253 253 253
46472 -253 253 253 250 250 250 170 170 170 26 26 26
46473 - 2 2 6 2 2 6 37 26 9 163 110 8
46474 -219 162 10 239 182 13 246 186 14 246 190 14
46475 -246 190 14 246 190 14 246 190 14 246 190 14
46476 -246 190 14 246 190 14 246 190 14 246 190 14
46477 -246 190 14 246 190 14 246 190 14 246 190 14
46478 -246 186 14 236 178 12 224 166 10 142 122 72
46479 - 46 46 46 18 18 18 6 6 6 0 0 0
46480 - 0 0 0 0 0 0 0 0 0 0 0 0
46481 - 0 0 0 0 0 0 0 0 0 0 0 0
46482 - 0 0 0 0 0 0 6 6 6 18 18 18
46483 - 50 50 50 109 106 95 192 133 9 224 166 10
46484 -242 186 14 246 190 14 246 190 14 246 190 14
46485 -246 190 14 246 190 14 246 190 14 246 190 14
46486 -246 190 14 246 190 14 246 190 14 246 190 14
46487 -246 190 14 246 190 14 246 190 14 246 190 14
46488 -242 186 14 226 184 13 210 162 10 142 110 46
46489 -226 226 226 253 253 253 253 253 253 253 253 253
46490 -253 253 253 253 253 253 253 253 253 253 253 253
46491 -253 253 253 253 253 253 253 253 253 253 253 253
46492 -198 198 198 66 66 66 2 2 6 2 2 6
46493 - 2 2 6 2 2 6 50 34 6 156 107 11
46494 -219 162 10 239 182 13 246 186 14 246 190 14
46495 -246 190 14 246 190 14 246 190 14 246 190 14
46496 -246 190 14 246 190 14 246 190 14 246 190 14
46497 -246 190 14 246 190 14 246 190 14 242 186 14
46498 -234 174 13 213 154 11 154 122 46 66 66 66
46499 - 30 30 30 10 10 10 0 0 0 0 0 0
46500 - 0 0 0 0 0 0 0 0 0 0 0 0
46501 - 0 0 0 0 0 0 0 0 0 0 0 0
46502 - 0 0 0 0 0 0 6 6 6 22 22 22
46503 - 58 58 58 154 121 60 206 145 10 234 174 13
46504 -242 186 14 246 186 14 246 190 14 246 190 14
46505 -246 190 14 246 190 14 246 190 14 246 190 14
46506 -246 190 14 246 190 14 246 190 14 246 190 14
46507 -246 190 14 246 190 14 246 190 14 246 190 14
46508 -246 186 14 236 178 12 210 162 10 163 110 8
46509 - 61 42 6 138 138 138 218 218 218 250 250 250
46510 -253 253 253 253 253 253 253 253 253 250 250 250
46511 -242 242 242 210 210 210 144 144 144 66 66 66
46512 - 6 6 6 2 2 6 2 2 6 2 2 6
46513 - 2 2 6 2 2 6 61 42 6 163 110 8
46514 -216 158 10 236 178 12 246 190 14 246 190 14
46515 -246 190 14 246 190 14 246 190 14 246 190 14
46516 -246 190 14 246 190 14 246 190 14 246 190 14
46517 -246 190 14 239 182 13 230 174 11 216 158 10
46518 -190 142 34 124 112 88 70 70 70 38 38 38
46519 - 18 18 18 6 6 6 0 0 0 0 0 0
46520 - 0 0 0 0 0 0 0 0 0 0 0 0
46521 - 0 0 0 0 0 0 0 0 0 0 0 0
46522 - 0 0 0 0 0 0 6 6 6 22 22 22
46523 - 62 62 62 168 124 44 206 145 10 224 166 10
46524 -236 178 12 239 182 13 242 186 14 242 186 14
46525 -246 186 14 246 190 14 246 190 14 246 190 14
46526 -246 190 14 246 190 14 246 190 14 246 190 14
46527 -246 190 14 246 190 14 246 190 14 246 190 14
46528 -246 190 14 236 178 12 216 158 10 175 118 6
46529 - 80 54 7 2 2 6 6 6 6 30 30 30
46530 - 54 54 54 62 62 62 50 50 50 38 38 38
46531 - 14 14 14 2 2 6 2 2 6 2 2 6
46532 - 2 2 6 2 2 6 2 2 6 2 2 6
46533 - 2 2 6 6 6 6 80 54 7 167 114 7
46534 -213 154 11 236 178 12 246 190 14 246 190 14
46535 -246 190 14 246 190 14 246 190 14 246 190 14
46536 -246 190 14 242 186 14 239 182 13 239 182 13
46537 -230 174 11 210 150 10 174 135 50 124 112 88
46538 - 82 82 82 54 54 54 34 34 34 18 18 18
46539 - 6 6 6 0 0 0 0 0 0 0 0 0
46540 - 0 0 0 0 0 0 0 0 0 0 0 0
46541 - 0 0 0 0 0 0 0 0 0 0 0 0
46542 - 0 0 0 0 0 0 6 6 6 18 18 18
46543 - 50 50 50 158 118 36 192 133 9 200 144 11
46544 -216 158 10 219 162 10 224 166 10 226 170 11
46545 -230 174 11 236 178 12 239 182 13 239 182 13
46546 -242 186 14 246 186 14 246 190 14 246 190 14
46547 -246 190 14 246 190 14 246 190 14 246 190 14
46548 -246 186 14 230 174 11 210 150 10 163 110 8
46549 -104 69 6 10 10 10 2 2 6 2 2 6
46550 - 2 2 6 2 2 6 2 2 6 2 2 6
46551 - 2 2 6 2 2 6 2 2 6 2 2 6
46552 - 2 2 6 2 2 6 2 2 6 2 2 6
46553 - 2 2 6 6 6 6 91 60 6 167 114 7
46554 -206 145 10 230 174 11 242 186 14 246 190 14
46555 -246 190 14 246 190 14 246 186 14 242 186 14
46556 -239 182 13 230 174 11 224 166 10 213 154 11
46557 -180 133 36 124 112 88 86 86 86 58 58 58
46558 - 38 38 38 22 22 22 10 10 10 6 6 6
46559 - 0 0 0 0 0 0 0 0 0 0 0 0
46560 - 0 0 0 0 0 0 0 0 0 0 0 0
46561 - 0 0 0 0 0 0 0 0 0 0 0 0
46562 - 0 0 0 0 0 0 0 0 0 14 14 14
46563 - 34 34 34 70 70 70 138 110 50 158 118 36
46564 -167 114 7 180 123 7 192 133 9 197 138 11
46565 -200 144 11 206 145 10 213 154 11 219 162 10
46566 -224 166 10 230 174 11 239 182 13 242 186 14
46567 -246 186 14 246 186 14 246 186 14 246 186 14
46568 -239 182 13 216 158 10 185 133 11 152 99 6
46569 -104 69 6 18 14 6 2 2 6 2 2 6
46570 - 2 2 6 2 2 6 2 2 6 2 2 6
46571 - 2 2 6 2 2 6 2 2 6 2 2 6
46572 - 2 2 6 2 2 6 2 2 6 2 2 6
46573 - 2 2 6 6 6 6 80 54 7 152 99 6
46574 -192 133 9 219 162 10 236 178 12 239 182 13
46575 -246 186 14 242 186 14 239 182 13 236 178 12
46576 -224 166 10 206 145 10 192 133 9 154 121 60
46577 - 94 94 94 62 62 62 42 42 42 22 22 22
46578 - 14 14 14 6 6 6 0 0 0 0 0 0
46579 - 0 0 0 0 0 0 0 0 0 0 0 0
46580 - 0 0 0 0 0 0 0 0 0 0 0 0
46581 - 0 0 0 0 0 0 0 0 0 0 0 0
46582 - 0 0 0 0 0 0 0 0 0 6 6 6
46583 - 18 18 18 34 34 34 58 58 58 78 78 78
46584 -101 98 89 124 112 88 142 110 46 156 107 11
46585 -163 110 8 167 114 7 175 118 6 180 123 7
46586 -185 133 11 197 138 11 210 150 10 219 162 10
46587 -226 170 11 236 178 12 236 178 12 234 174 13
46588 -219 162 10 197 138 11 163 110 8 130 83 6
46589 - 91 60 6 10 10 10 2 2 6 2 2 6
46590 - 18 18 18 38 38 38 38 38 38 38 38 38
46591 - 38 38 38 38 38 38 38 38 38 38 38 38
46592 - 38 38 38 38 38 38 26 26 26 2 2 6
46593 - 2 2 6 6 6 6 70 47 6 137 92 6
46594 -175 118 6 200 144 11 219 162 10 230 174 11
46595 -234 174 13 230 174 11 219 162 10 210 150 10
46596 -192 133 9 163 110 8 124 112 88 82 82 82
46597 - 50 50 50 30 30 30 14 14 14 6 6 6
46598 - 0 0 0 0 0 0 0 0 0 0 0 0
46599 - 0 0 0 0 0 0 0 0 0 0 0 0
46600 - 0 0 0 0 0 0 0 0 0 0 0 0
46601 - 0 0 0 0 0 0 0 0 0 0 0 0
46602 - 0 0 0 0 0 0 0 0 0 0 0 0
46603 - 6 6 6 14 14 14 22 22 22 34 34 34
46604 - 42 42 42 58 58 58 74 74 74 86 86 86
46605 -101 98 89 122 102 70 130 98 46 121 87 25
46606 -137 92 6 152 99 6 163 110 8 180 123 7
46607 -185 133 11 197 138 11 206 145 10 200 144 11
46608 -180 123 7 156 107 11 130 83 6 104 69 6
46609 - 50 34 6 54 54 54 110 110 110 101 98 89
46610 - 86 86 86 82 82 82 78 78 78 78 78 78
46611 - 78 78 78 78 78 78 78 78 78 78 78 78
46612 - 78 78 78 82 82 82 86 86 86 94 94 94
46613 -106 106 106 101 101 101 86 66 34 124 80 6
46614 -156 107 11 180 123 7 192 133 9 200 144 11
46615 -206 145 10 200 144 11 192 133 9 175 118 6
46616 -139 102 15 109 106 95 70 70 70 42 42 42
46617 - 22 22 22 10 10 10 0 0 0 0 0 0
46618 - 0 0 0 0 0 0 0 0 0 0 0 0
46619 - 0 0 0 0 0 0 0 0 0 0 0 0
46620 - 0 0 0 0 0 0 0 0 0 0 0 0
46621 - 0 0 0 0 0 0 0 0 0 0 0 0
46622 - 0 0 0 0 0 0 0 0 0 0 0 0
46623 - 0 0 0 0 0 0 6 6 6 10 10 10
46624 - 14 14 14 22 22 22 30 30 30 38 38 38
46625 - 50 50 50 62 62 62 74 74 74 90 90 90
46626 -101 98 89 112 100 78 121 87 25 124 80 6
46627 -137 92 6 152 99 6 152 99 6 152 99 6
46628 -138 86 6 124 80 6 98 70 6 86 66 30
46629 -101 98 89 82 82 82 58 58 58 46 46 46
46630 - 38 38 38 34 34 34 34 34 34 34 34 34
46631 - 34 34 34 34 34 34 34 34 34 34 34 34
46632 - 34 34 34 34 34 34 38 38 38 42 42 42
46633 - 54 54 54 82 82 82 94 86 76 91 60 6
46634 -134 86 6 156 107 11 167 114 7 175 118 6
46635 -175 118 6 167 114 7 152 99 6 121 87 25
46636 -101 98 89 62 62 62 34 34 34 18 18 18
46637 - 6 6 6 0 0 0 0 0 0 0 0 0
46638 - 0 0 0 0 0 0 0 0 0 0 0 0
46639 - 0 0 0 0 0 0 0 0 0 0 0 0
46640 - 0 0 0 0 0 0 0 0 0 0 0 0
46641 - 0 0 0 0 0 0 0 0 0 0 0 0
46642 - 0 0 0 0 0 0 0 0 0 0 0 0
46643 - 0 0 0 0 0 0 0 0 0 0 0 0
46644 - 0 0 0 6 6 6 6 6 6 10 10 10
46645 - 18 18 18 22 22 22 30 30 30 42 42 42
46646 - 50 50 50 66 66 66 86 86 86 101 98 89
46647 -106 86 58 98 70 6 104 69 6 104 69 6
46648 -104 69 6 91 60 6 82 62 34 90 90 90
46649 - 62 62 62 38 38 38 22 22 22 14 14 14
46650 - 10 10 10 10 10 10 10 10 10 10 10 10
46651 - 10 10 10 10 10 10 6 6 6 10 10 10
46652 - 10 10 10 10 10 10 10 10 10 14 14 14
46653 - 22 22 22 42 42 42 70 70 70 89 81 66
46654 - 80 54 7 104 69 6 124 80 6 137 92 6
46655 -134 86 6 116 81 8 100 82 52 86 86 86
46656 - 58 58 58 30 30 30 14 14 14 6 6 6
46657 - 0 0 0 0 0 0 0 0 0 0 0 0
46658 - 0 0 0 0 0 0 0 0 0 0 0 0
46659 - 0 0 0 0 0 0 0 0 0 0 0 0
46660 - 0 0 0 0 0 0 0 0 0 0 0 0
46661 - 0 0 0 0 0 0 0 0 0 0 0 0
46662 - 0 0 0 0 0 0 0 0 0 0 0 0
46663 - 0 0 0 0 0 0 0 0 0 0 0 0
46664 - 0 0 0 0 0 0 0 0 0 0 0 0
46665 - 0 0 0 6 6 6 10 10 10 14 14 14
46666 - 18 18 18 26 26 26 38 38 38 54 54 54
46667 - 70 70 70 86 86 86 94 86 76 89 81 66
46668 - 89 81 66 86 86 86 74 74 74 50 50 50
46669 - 30 30 30 14 14 14 6 6 6 0 0 0
46670 - 0 0 0 0 0 0 0 0 0 0 0 0
46671 - 0 0 0 0 0 0 0 0 0 0 0 0
46672 - 0 0 0 0 0 0 0 0 0 0 0 0
46673 - 6 6 6 18 18 18 34 34 34 58 58 58
46674 - 82 82 82 89 81 66 89 81 66 89 81 66
46675 - 94 86 66 94 86 76 74 74 74 50 50 50
46676 - 26 26 26 14 14 14 6 6 6 0 0 0
46677 - 0 0 0 0 0 0 0 0 0 0 0 0
46678 - 0 0 0 0 0 0 0 0 0 0 0 0
46679 - 0 0 0 0 0 0 0 0 0 0 0 0
46680 - 0 0 0 0 0 0 0 0 0 0 0 0
46681 - 0 0 0 0 0 0 0 0 0 0 0 0
46682 - 0 0 0 0 0 0 0 0 0 0 0 0
46683 - 0 0 0 0 0 0 0 0 0 0 0 0
46684 - 0 0 0 0 0 0 0 0 0 0 0 0
46685 - 0 0 0 0 0 0 0 0 0 0 0 0
46686 - 6 6 6 6 6 6 14 14 14 18 18 18
46687 - 30 30 30 38 38 38 46 46 46 54 54 54
46688 - 50 50 50 42 42 42 30 30 30 18 18 18
46689 - 10 10 10 0 0 0 0 0 0 0 0 0
46690 - 0 0 0 0 0 0 0 0 0 0 0 0
46691 - 0 0 0 0 0 0 0 0 0 0 0 0
46692 - 0 0 0 0 0 0 0 0 0 0 0 0
46693 - 0 0 0 6 6 6 14 14 14 26 26 26
46694 - 38 38 38 50 50 50 58 58 58 58 58 58
46695 - 54 54 54 42 42 42 30 30 30 18 18 18
46696 - 10 10 10 0 0 0 0 0 0 0 0 0
46697 - 0 0 0 0 0 0 0 0 0 0 0 0
46698 - 0 0 0 0 0 0 0 0 0 0 0 0
46699 - 0 0 0 0 0 0 0 0 0 0 0 0
46700 - 0 0 0 0 0 0 0 0 0 0 0 0
46701 - 0 0 0 0 0 0 0 0 0 0 0 0
46702 - 0 0 0 0 0 0 0 0 0 0 0 0
46703 - 0 0 0 0 0 0 0 0 0 0 0 0
46704 - 0 0 0 0 0 0 0 0 0 0 0 0
46705 - 0 0 0 0 0 0 0 0 0 0 0 0
46706 - 0 0 0 0 0 0 0 0 0 6 6 6
46707 - 6 6 6 10 10 10 14 14 14 18 18 18
46708 - 18 18 18 14 14 14 10 10 10 6 6 6
46709 - 0 0 0 0 0 0 0 0 0 0 0 0
46710 - 0 0 0 0 0 0 0 0 0 0 0 0
46711 - 0 0 0 0 0 0 0 0 0 0 0 0
46712 - 0 0 0 0 0 0 0 0 0 0 0 0
46713 - 0 0 0 0 0 0 0 0 0 6 6 6
46714 - 14 14 14 18 18 18 22 22 22 22 22 22
46715 - 18 18 18 14 14 14 10 10 10 6 6 6
46716 - 0 0 0 0 0 0 0 0 0 0 0 0
46717 - 0 0 0 0 0 0 0 0 0 0 0 0
46718 - 0 0 0 0 0 0 0 0 0 0 0 0
46719 - 0 0 0 0 0 0 0 0 0 0 0 0
46720 - 0 0 0 0 0 0 0 0 0 0 0 0
46721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46732 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46734 +4 4 4 4 4 4
46735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46738 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46743 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46744 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46746 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46748 +4 4 4 4 4 4
46749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46760 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46762 +4 4 4 4 4 4
46763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46776 +4 4 4 4 4 4
46777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46784 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46786 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46790 +4 4 4 4 4 4
46791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46794 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46798 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46800 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46801 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46802 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46804 +4 4 4 4 4 4
46805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46809 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46810 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46812 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46814 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46815 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46816 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46817 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46818 +4 4 4 4 4 4
46819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46823 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46824 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46825 +5 5 5 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 3 3 3 0 0 0 1 1 1 6 6 6
46829 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46830 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46831 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46832 +4 4 4 4 4 4
46833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46837 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46838 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46839 +0 0 0 3 3 3 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 0 0 0 4 4 4 41 54 63 125 124 125
46843 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46844 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46845 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46846 +4 4 4 4 4 4
46847 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46848 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46849 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46850 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46851 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46852 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46853 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 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 5 5 5 5 5 5
46856 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46857 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46858 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46859 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46860 +4 4 4 4 4 4
46861 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46862 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46863 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46864 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46865 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46866 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46867 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46868 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46869 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46870 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46871 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46872 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46873 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46874 +4 4 4 4 4 4
46875 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46876 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46878 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46879 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46880 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46881 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46882 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46883 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46884 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46885 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46886 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46887 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46888 +4 4 4 4 4 4
46889 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46890 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46891 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46892 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46893 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46894 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46895 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46896 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46897 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46898 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46899 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46900 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46901 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46902 +4 4 4 4 4 4
46903 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46904 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46905 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46906 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46907 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46908 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46909 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46910 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46911 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46912 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46913 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46914 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46915 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46916 +4 4 4 4 4 4
46917 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46918 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46919 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46920 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46921 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46922 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46923 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46924 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46925 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46926 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46927 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46928 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46929 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46930 +4 4 4 4 4 4
46931 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46932 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46933 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46934 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46935 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46936 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46937 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46938 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46939 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46940 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46941 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46942 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46943 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46944 +4 4 4 4 4 4
46945 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46946 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
46947 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46948 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46949 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46950 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46951 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46952 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46953 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46954 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46955 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46956 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46957 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46958 +4 4 4 4 4 4
46959 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46960 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46961 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46962 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46963 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46964 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46965 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46966 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46967 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46968 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
46969 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
46970 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
46971 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
46972 +0 0 0 4 4 4
46973 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46974 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
46975 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46976 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46977 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46978 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46979 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46980 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46981 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46982 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46983 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46984 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46985 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46986 +2 0 0 0 0 0
46987 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46988 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46989 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46990 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46991 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46992 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46993 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46994 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46995 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46996 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46997 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46998 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46999 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
47000 +37 38 37 0 0 0
47001 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47002 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
47003 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
47004 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
47005 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
47006 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
47007 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
47008 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
47009 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
47010 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
47011 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
47012 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
47013 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
47014 +85 115 134 4 0 0
47015 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
47016 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
47017 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
47018 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
47019 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
47020 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
47021 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
47022 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
47023 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
47024 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
47025 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
47026 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
47027 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
47028 +60 73 81 4 0 0
47029 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
47030 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
47031 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
47032 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
47033 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
47034 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
47035 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
47036 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
47037 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
47038 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
47039 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
47040 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
47041 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
47042 +16 19 21 4 0 0
47043 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
47044 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
47045 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
47046 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
47047 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
47048 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
47049 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
47050 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
47051 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
47052 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
47053 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
47054 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
47055 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
47056 +4 0 0 4 3 3
47057 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
47058 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
47059 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
47060 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
47061 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
47062 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
47063 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
47064 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
47065 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
47066 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
47067 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
47068 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
47069 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
47070 +3 2 2 4 4 4
47071 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
47072 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
47073 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
47074 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47075 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
47076 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
47077 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47078 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
47079 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
47080 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
47081 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
47082 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
47083 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
47084 +4 4 4 4 4 4
47085 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
47086 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
47087 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
47088 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
47089 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
47090 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
47091 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
47092 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
47093 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
47094 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
47095 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
47096 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
47097 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
47098 +4 4 4 4 4 4
47099 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
47100 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
47101 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
47102 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
47103 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
47104 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47105 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47106 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47107 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47108 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47109 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47110 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47111 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47112 +5 5 5 5 5 5
47113 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47114 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47115 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47116 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47117 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47118 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47119 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47120 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47121 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47122 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47123 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47124 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47125 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47126 +5 5 5 4 4 4
47127 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47128 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47129 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47130 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47131 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47132 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47133 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47134 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47135 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47136 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47137 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47138 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47139 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47140 +4 4 4 4 4 4
47141 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47142 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47143 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47144 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47145 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47146 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47147 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47148 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47149 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47150 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47151 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47152 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47153 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47154 +4 4 4 4 4 4
47155 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47156 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47157 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47158 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47159 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47160 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47161 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47162 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47163 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47164 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47165 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
47166 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47167 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47168 +4 4 4 4 4 4
47169 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47170 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47171 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47172 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47173 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47174 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47175 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47176 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47177 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47178 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47179 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
47180 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47181 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47182 +4 4 4 4 4 4
47183 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47184 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47185 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47186 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47187 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47188 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47189 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47190 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47191 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47192 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47193 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47194 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47195 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47196 +4 4 4 4 4 4
47197 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47198 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47199 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47200 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47201 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47202 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47203 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47204 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47205 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47206 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47207 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
47208 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47209 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47210 +4 4 4 4 4 4
47211 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47212 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47213 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47214 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47215 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47216 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47217 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47218 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47219 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47220 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47221 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
47222 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47223 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47224 +4 4 4 4 4 4
47225 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47226 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47227 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47228 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47229 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47230 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47231 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47232 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47233 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47234 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47235 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47236 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47237 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47238 +4 4 4 4 4 4
47239 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47240 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47241 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47242 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47243 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47244 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47245 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47246 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47247 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47248 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47249 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47250 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47251 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47252 +4 4 4 4 4 4
47253 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47254 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47255 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47256 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47257 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47258 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47259 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47260 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47261 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47262 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47263 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47264 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47265 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47266 +4 4 4 4 4 4
47267 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47268 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47269 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47270 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47271 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47272 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47273 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47274 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47275 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47276 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47277 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47278 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47279 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47280 +4 4 4 4 4 4
47281 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47282 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47283 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47284 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47285 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47286 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47287 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47288 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47289 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47290 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47291 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47292 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47293 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47294 +4 4 4 4 4 4
47295 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47296 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47297 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47298 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47299 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47300 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47301 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47302 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47303 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47304 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47305 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47306 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47307 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47308 +4 4 4 4 4 4
47309 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47310 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47311 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47312 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47313 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47314 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47315 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47316 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47317 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47318 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47319 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47320 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47321 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47322 +4 4 4 4 4 4
47323 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47324 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47325 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47326 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47327 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47328 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47329 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47330 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47331 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47332 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47333 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47334 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47335 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47336 +4 4 4 4 4 4
47337 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47338 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47339 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47340 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47341 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47342 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47343 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47344 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47345 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47346 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47347 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47348 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47349 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47350 +4 4 4 4 4 4
47351 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47352 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47353 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47354 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47355 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47356 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47357 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47358 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47359 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47360 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47361 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47362 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47363 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47364 +4 4 4 4 4 4
47365 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47366 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47367 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47368 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47369 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47370 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47371 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47372 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47373 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47374 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47375 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47376 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47377 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47378 +4 4 4 4 4 4
47379 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47380 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47381 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47382 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47383 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47384 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47385 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47386 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47387 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47388 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47389 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47390 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47391 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47392 +4 4 4 4 4 4
47393 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47394 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47395 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47396 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47397 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47398 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47399 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47400 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47401 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47402 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47403 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47404 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47405 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47406 +4 4 4 4 4 4
47407 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47408 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47409 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47410 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47411 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47412 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47413 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47414 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47415 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47416 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47417 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47418 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47419 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47420 +4 4 4 4 4 4
47421 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47422 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47423 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47424 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47425 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47426 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47427 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47428 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47429 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47430 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47431 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47432 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47433 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47434 +4 4 4 4 4 4
47435 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47436 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47437 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47438 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47439 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47440 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47441 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47442 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47443 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47444 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47445 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47446 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47447 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47448 +4 4 4 4 4 4
47449 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47450 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47451 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47452 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47453 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47454 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47455 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47456 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47457 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47458 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47459 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47460 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47461 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47462 +4 4 4 4 4 4
47463 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47464 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47465 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47466 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47467 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47468 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47469 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47470 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47471 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47472 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47473 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47474 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47475 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47476 +4 4 4 4 4 4
47477 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47478 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47479 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47480 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47481 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47482 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47483 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47484 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47485 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47486 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47487 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47488 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47489 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47490 +4 4 4 4 4 4
47491 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47492 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47493 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47494 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47495 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47496 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47497 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47498 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47499 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47500 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47501 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47502 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47503 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47504 +4 4 4 4 4 4
47505 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47506 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47507 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47508 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47509 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47510 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47511 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47512 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47513 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47514 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47515 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47516 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47517 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47518 +4 4 4 4 4 4
47519 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47520 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47521 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47522 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47523 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47524 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47525 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47526 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47527 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47528 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47529 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47530 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47531 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47532 +4 4 4 4 4 4
47533 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47534 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47535 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47536 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47537 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47538 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47539 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47540 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47541 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47542 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47543 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47544 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47545 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47546 +4 4 4 4 4 4
47547 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47548 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47549 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47550 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47551 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47552 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47553 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47554 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47555 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47556 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47557 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47558 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47559 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47560 +4 4 4 4 4 4
47561 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47562 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47563 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47564 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47565 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47566 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47567 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47568 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47569 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47570 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47571 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47572 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47574 +4 4 4 4 4 4
47575 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47576 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47577 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47578 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47579 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47580 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47581 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47582 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47583 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47584 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47585 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47586 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47588 +4 4 4 4 4 4
47589 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47590 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47591 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47592 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47593 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47594 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47595 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47596 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47597 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47598 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47599 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47600 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47601 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47602 +4 4 4 4 4 4
47603 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47604 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47605 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47606 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47607 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47608 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47609 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47610 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47611 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47612 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47613 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47614 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47615 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47616 +4 4 4 4 4 4
47617 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47618 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47619 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47620 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47621 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47622 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47623 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47624 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47625 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47626 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47627 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47628 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47630 +4 4 4 4 4 4
47631 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47632 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47633 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47634 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47635 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47636 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47637 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47638 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47640 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47641 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47642 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47643 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47644 +4 4 4 4 4 4
47645 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47646 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47647 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47648 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47649 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47650 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47651 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47652 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47658 +4 4 4 4 4 4
47659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47660 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47661 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47662 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47663 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47664 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47665 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47666 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47672 +4 4 4 4 4 4
47673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47674 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47675 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47676 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47677 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47678 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47679 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47680 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47686 +4 4 4 4 4 4
47687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47688 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47689 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47690 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47691 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47692 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47693 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47694 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47700 +4 4 4 4 4 4
47701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47703 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47704 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47705 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47706 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47707 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47708 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47714 +4 4 4 4 4 4
47715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47718 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47719 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47720 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47721 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47728 +4 4 4 4 4 4
47729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47732 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47733 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47734 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47735 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47738 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47742 +4 4 4 4 4 4
47743 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47744 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47746 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47747 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47748 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47749 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47756 +4 4 4 4 4 4
47757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47760 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47761 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47762 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47763 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47770 +4 4 4 4 4 4
47771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47775 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47776 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47777 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47784 +4 4 4 4 4 4
47785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47786 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47789 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47790 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47791 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47794 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47798 +4 4 4 4 4 4
47799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47800 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47801 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47802 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47803 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47804 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47805 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47807 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47808 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47812 +4 4 4 4 4 4
47813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47814 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47815 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47816 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47817 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47818 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47819 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47820 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47821 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47822 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47825 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47826 +4 4 4 4 4 4
47827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47828 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47830 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47831 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47832 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47833 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47834 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47835 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47836 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47839 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47840 +4 4 4 4 4 4
47841 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47842 index fe92eed..106e085 100644
47843 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47844 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47845 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47846 struct mb862xxfb_par *par = info->par;
47847
47848 if (info->var.bits_per_pixel == 32) {
47849 - info->fbops->fb_fillrect = cfb_fillrect;
47850 - info->fbops->fb_copyarea = cfb_copyarea;
47851 - info->fbops->fb_imageblit = cfb_imageblit;
47852 + pax_open_kernel();
47853 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47854 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47855 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47856 + pax_close_kernel();
47857 } else {
47858 outreg(disp, GC_L0EM, 3);
47859 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47860 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47861 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47862 + pax_open_kernel();
47863 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47864 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47865 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47866 + pax_close_kernel();
47867 }
47868 outreg(draw, GDC_REG_DRAW_BASE, 0);
47869 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47870 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47871 index ff22871..b129bed 100644
47872 --- a/drivers/video/nvidia/nvidia.c
47873 +++ b/drivers/video/nvidia/nvidia.c
47874 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47875 info->fix.line_length = (info->var.xres_virtual *
47876 info->var.bits_per_pixel) >> 3;
47877 if (info->var.accel_flags) {
47878 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47879 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47880 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47881 - info->fbops->fb_sync = nvidiafb_sync;
47882 + pax_open_kernel();
47883 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47884 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47885 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47886 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47887 + pax_close_kernel();
47888 info->pixmap.scan_align = 4;
47889 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47890 info->flags |= FBINFO_READS_FAST;
47891 NVResetGraphics(info);
47892 } else {
47893 - info->fbops->fb_imageblit = cfb_imageblit;
47894 - info->fbops->fb_fillrect = cfb_fillrect;
47895 - info->fbops->fb_copyarea = cfb_copyarea;
47896 - info->fbops->fb_sync = NULL;
47897 + pax_open_kernel();
47898 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47899 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47900 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47901 + *(void **)&info->fbops->fb_sync = NULL;
47902 + pax_close_kernel();
47903 info->pixmap.scan_align = 1;
47904 info->flags |= FBINFO_HWACCEL_DISABLED;
47905 info->flags &= ~FBINFO_READS_FAST;
47906 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47907 info->pixmap.size = 8 * 1024;
47908 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47909
47910 - if (!hwcur)
47911 - info->fbops->fb_cursor = NULL;
47912 + if (!hwcur) {
47913 + pax_open_kernel();
47914 + *(void **)&info->fbops->fb_cursor = NULL;
47915 + pax_close_kernel();
47916 + }
47917
47918 info->var.accel_flags = (!noaccel);
47919
47920 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47921 index 76d9053..dec2bfd 100644
47922 --- a/drivers/video/s1d13xxxfb.c
47923 +++ b/drivers/video/s1d13xxxfb.c
47924 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47925
47926 switch(prod_id) {
47927 case S1D13506_PROD_ID: /* activate acceleration */
47928 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47929 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47930 + pax_open_kernel();
47931 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47932 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47933 + pax_close_kernel();
47934 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47935 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47936 break;
47937 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47938 index 97bd662..39fab85 100644
47939 --- a/drivers/video/smscufx.c
47940 +++ b/drivers/video/smscufx.c
47941 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47942 fb_deferred_io_cleanup(info);
47943 kfree(info->fbdefio);
47944 info->fbdefio = NULL;
47945 - info->fbops->fb_mmap = ufx_ops_mmap;
47946 + pax_open_kernel();
47947 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47948 + pax_close_kernel();
47949 }
47950
47951 pr_debug("released /dev/fb%d user=%d count=%d",
47952 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47953 index 86d449e..8e04dc5 100644
47954 --- a/drivers/video/udlfb.c
47955 +++ b/drivers/video/udlfb.c
47956 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47957 dlfb_urb_completion(urb);
47958
47959 error:
47960 - atomic_add(bytes_sent, &dev->bytes_sent);
47961 - atomic_add(bytes_identical, &dev->bytes_identical);
47962 - atomic_add(width*height*2, &dev->bytes_rendered);
47963 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47964 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47965 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47966 end_cycles = get_cycles();
47967 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47968 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47969 >> 10)), /* Kcycles */
47970 &dev->cpu_kcycles_used);
47971
47972 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
47973 dlfb_urb_completion(urb);
47974
47975 error:
47976 - atomic_add(bytes_sent, &dev->bytes_sent);
47977 - atomic_add(bytes_identical, &dev->bytes_identical);
47978 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47979 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47980 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47981 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47982 end_cycles = get_cycles();
47983 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47984 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47985 >> 10)), /* Kcycles */
47986 &dev->cpu_kcycles_used);
47987 }
47988 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47989 fb_deferred_io_cleanup(info);
47990 kfree(info->fbdefio);
47991 info->fbdefio = NULL;
47992 - info->fbops->fb_mmap = dlfb_ops_mmap;
47993 + pax_open_kernel();
47994 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47995 + pax_close_kernel();
47996 }
47997
47998 pr_warn("released /dev/fb%d user=%d count=%d\n",
47999 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
48000 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48001 struct dlfb_data *dev = fb_info->par;
48002 return snprintf(buf, PAGE_SIZE, "%u\n",
48003 - atomic_read(&dev->bytes_rendered));
48004 + atomic_read_unchecked(&dev->bytes_rendered));
48005 }
48006
48007 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48008 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48009 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48010 struct dlfb_data *dev = fb_info->par;
48011 return snprintf(buf, PAGE_SIZE, "%u\n",
48012 - atomic_read(&dev->bytes_identical));
48013 + atomic_read_unchecked(&dev->bytes_identical));
48014 }
48015
48016 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48017 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48018 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48019 struct dlfb_data *dev = fb_info->par;
48020 return snprintf(buf, PAGE_SIZE, "%u\n",
48021 - atomic_read(&dev->bytes_sent));
48022 + atomic_read_unchecked(&dev->bytes_sent));
48023 }
48024
48025 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48026 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48027 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48028 struct dlfb_data *dev = fb_info->par;
48029 return snprintf(buf, PAGE_SIZE, "%u\n",
48030 - atomic_read(&dev->cpu_kcycles_used));
48031 + atomic_read_unchecked(&dev->cpu_kcycles_used));
48032 }
48033
48034 static ssize_t edid_show(
48035 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
48036 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48037 struct dlfb_data *dev = fb_info->par;
48038
48039 - atomic_set(&dev->bytes_rendered, 0);
48040 - atomic_set(&dev->bytes_identical, 0);
48041 - atomic_set(&dev->bytes_sent, 0);
48042 - atomic_set(&dev->cpu_kcycles_used, 0);
48043 + atomic_set_unchecked(&dev->bytes_rendered, 0);
48044 + atomic_set_unchecked(&dev->bytes_identical, 0);
48045 + atomic_set_unchecked(&dev->bytes_sent, 0);
48046 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
48047
48048 return count;
48049 }
48050 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
48051 index b75db01..ad2f34a 100644
48052 --- a/drivers/video/uvesafb.c
48053 +++ b/drivers/video/uvesafb.c
48054 @@ -19,6 +19,7 @@
48055 #include <linux/io.h>
48056 #include <linux/mutex.h>
48057 #include <linux/slab.h>
48058 +#include <linux/moduleloader.h>
48059 #include <video/edid.h>
48060 #include <video/uvesafb.h>
48061 #ifdef CONFIG_X86
48062 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
48063 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
48064 par->pmi_setpal = par->ypan = 0;
48065 } else {
48066 +
48067 +#ifdef CONFIG_PAX_KERNEXEC
48068 +#ifdef CONFIG_MODULES
48069 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
48070 +#endif
48071 + if (!par->pmi_code) {
48072 + par->pmi_setpal = par->ypan = 0;
48073 + return 0;
48074 + }
48075 +#endif
48076 +
48077 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
48078 + task->t.regs.edi);
48079 +
48080 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48081 + pax_open_kernel();
48082 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
48083 + pax_close_kernel();
48084 +
48085 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
48086 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
48087 +#else
48088 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
48089 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
48090 +#endif
48091 +
48092 printk(KERN_INFO "uvesafb: protected mode interface info at "
48093 "%04x:%04x\n",
48094 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48095 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48096 par->ypan = ypan;
48097
48098 if (par->pmi_setpal || par->ypan) {
48099 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48100 if (__supported_pte_mask & _PAGE_NX) {
48101 par->pmi_setpal = par->ypan = 0;
48102 printk(KERN_WARNING "uvesafb: NX protection is actively."
48103 "We have better not to use the PMI.\n");
48104 - } else {
48105 + } else
48106 +#endif
48107 uvesafb_vbe_getpmi(task, par);
48108 - }
48109 }
48110 #else
48111 /* The protected mode interface is not available on non-x86. */
48112 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48113 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48114
48115 /* Disable blanking if the user requested so. */
48116 - if (!blank)
48117 - info->fbops->fb_blank = NULL;
48118 + if (!blank) {
48119 + pax_open_kernel();
48120 + *(void **)&info->fbops->fb_blank = NULL;
48121 + pax_close_kernel();
48122 + }
48123
48124 /*
48125 * Find out how much IO memory is required for the mode with
48126 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48127 info->flags = FBINFO_FLAG_DEFAULT |
48128 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48129
48130 - if (!par->ypan)
48131 - info->fbops->fb_pan_display = NULL;
48132 + if (!par->ypan) {
48133 + pax_open_kernel();
48134 + *(void **)&info->fbops->fb_pan_display = NULL;
48135 + pax_close_kernel();
48136 + }
48137 }
48138
48139 static void uvesafb_init_mtrr(struct fb_info *info)
48140 @@ -1836,6 +1866,11 @@ out:
48141 if (par->vbe_modes)
48142 kfree(par->vbe_modes);
48143
48144 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48145 + if (par->pmi_code)
48146 + module_free_exec(NULL, par->pmi_code);
48147 +#endif
48148 +
48149 framebuffer_release(info);
48150 return err;
48151 }
48152 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48153 kfree(par->vbe_state_orig);
48154 if (par->vbe_state_saved)
48155 kfree(par->vbe_state_saved);
48156 +
48157 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48158 + if (par->pmi_code)
48159 + module_free_exec(NULL, par->pmi_code);
48160 +#endif
48161 +
48162 }
48163
48164 framebuffer_release(info);
48165 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48166 index 501b340..d80aa17 100644
48167 --- a/drivers/video/vesafb.c
48168 +++ b/drivers/video/vesafb.c
48169 @@ -9,6 +9,7 @@
48170 */
48171
48172 #include <linux/module.h>
48173 +#include <linux/moduleloader.h>
48174 #include <linux/kernel.h>
48175 #include <linux/errno.h>
48176 #include <linux/string.h>
48177 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48178 static int vram_total __initdata; /* Set total amount of memory */
48179 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48180 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48181 -static void (*pmi_start)(void) __read_mostly;
48182 -static void (*pmi_pal) (void) __read_mostly;
48183 +static void (*pmi_start)(void) __read_only;
48184 +static void (*pmi_pal) (void) __read_only;
48185 static int depth __read_mostly;
48186 static int vga_compat __read_mostly;
48187 /* --------------------------------------------------------------------- */
48188 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48189 unsigned int size_vmode;
48190 unsigned int size_remap;
48191 unsigned int size_total;
48192 + void *pmi_code = NULL;
48193
48194 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48195 return -ENODEV;
48196 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48197 size_remap = size_total;
48198 vesafb_fix.smem_len = size_remap;
48199
48200 -#ifndef __i386__
48201 - screen_info.vesapm_seg = 0;
48202 -#endif
48203 -
48204 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48205 printk(KERN_WARNING
48206 "vesafb: cannot reserve video memory at 0x%lx\n",
48207 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48208 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48209 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48210
48211 +#ifdef __i386__
48212 +
48213 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48214 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48215 + if (!pmi_code)
48216 +#elif !defined(CONFIG_PAX_KERNEXEC)
48217 + if (0)
48218 +#endif
48219 +
48220 +#endif
48221 + screen_info.vesapm_seg = 0;
48222 +
48223 if (screen_info.vesapm_seg) {
48224 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48225 - screen_info.vesapm_seg,screen_info.vesapm_off);
48226 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48227 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48228 }
48229
48230 if (screen_info.vesapm_seg < 0xc000)
48231 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48232
48233 if (ypan || pmi_setpal) {
48234 unsigned short *pmi_base;
48235 +
48236 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48237 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48238 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48239 +
48240 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48241 + pax_open_kernel();
48242 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48243 +#else
48244 + pmi_code = pmi_base;
48245 +#endif
48246 +
48247 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48248 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48249 +
48250 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48251 + pmi_start = ktva_ktla(pmi_start);
48252 + pmi_pal = ktva_ktla(pmi_pal);
48253 + pax_close_kernel();
48254 +#endif
48255 +
48256 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48257 if (pmi_base[3]) {
48258 printk(KERN_INFO "vesafb: pmi: ports = ");
48259 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48260 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48261 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48262
48263 - if (!ypan)
48264 - info->fbops->fb_pan_display = NULL;
48265 + if (!ypan) {
48266 + pax_open_kernel();
48267 + *(void **)&info->fbops->fb_pan_display = NULL;
48268 + pax_close_kernel();
48269 + }
48270
48271 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48272 err = -ENOMEM;
48273 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48274 info->node, info->fix.id);
48275 return 0;
48276 err:
48277 +
48278 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48279 + module_free_exec(NULL, pmi_code);
48280 +#endif
48281 +
48282 if (info->screen_base)
48283 iounmap(info->screen_base);
48284 framebuffer_release(info);
48285 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48286 index 88714ae..16c2e11 100644
48287 --- a/drivers/video/via/via_clock.h
48288 +++ b/drivers/video/via/via_clock.h
48289 @@ -56,7 +56,7 @@ struct via_clock {
48290
48291 void (*set_engine_pll_state)(u8 state);
48292 void (*set_engine_pll)(struct via_pll_config config);
48293 -};
48294 +} __no_const;
48295
48296
48297 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48298 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48299 index fef20db..d28b1ab 100644
48300 --- a/drivers/xen/xenfs/xenstored.c
48301 +++ b/drivers/xen/xenfs/xenstored.c
48302 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48303 static int xsd_kva_open(struct inode *inode, struct file *file)
48304 {
48305 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48306 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48307 + NULL);
48308 +#else
48309 xen_store_interface);
48310 +#endif
48311 +
48312 if (!file->private_data)
48313 return -ENOMEM;
48314 return 0;
48315 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48316 index 890bed5..17ae73e 100644
48317 --- a/fs/9p/vfs_inode.c
48318 +++ b/fs/9p/vfs_inode.c
48319 @@ -1329,7 +1329,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48320 void
48321 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48322 {
48323 - char *s = nd_get_link(nd);
48324 + const char *s = nd_get_link(nd);
48325
48326 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48327 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48328 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48329 index 0efd152..b5802ad 100644
48330 --- a/fs/Kconfig.binfmt
48331 +++ b/fs/Kconfig.binfmt
48332 @@ -89,7 +89,7 @@ config HAVE_AOUT
48333
48334 config BINFMT_AOUT
48335 tristate "Kernel support for a.out and ECOFF binaries"
48336 - depends on HAVE_AOUT
48337 + depends on HAVE_AOUT && BROKEN
48338 ---help---
48339 A.out (Assembler.OUTput) is a set of formats for libraries and
48340 executables used in the earliest versions of UNIX. Linux used
48341 diff --git a/fs/aio.c b/fs/aio.c
48342 index 71f613c..9d01f1f 100644
48343 --- a/fs/aio.c
48344 +++ b/fs/aio.c
48345 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48346 size += sizeof(struct io_event) * nr_events;
48347 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48348
48349 - if (nr_pages < 0)
48350 + if (nr_pages <= 0)
48351 return -EINVAL;
48352
48353 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48354 @@ -1373,18 +1373,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
48355 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48356 {
48357 ssize_t ret;
48358 + struct iovec iovstack;
48359
48360 #ifdef CONFIG_COMPAT
48361 if (compat)
48362 ret = compat_rw_copy_check_uvector(type,
48363 (struct compat_iovec __user *)kiocb->ki_buf,
48364 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48365 + kiocb->ki_nbytes, 1, &iovstack,
48366 &kiocb->ki_iovec);
48367 else
48368 #endif
48369 ret = rw_copy_check_uvector(type,
48370 (struct iovec __user *)kiocb->ki_buf,
48371 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48372 + kiocb->ki_nbytes, 1, &iovstack,
48373 &kiocb->ki_iovec);
48374 if (ret < 0)
48375 goto out;
48376 @@ -1393,6 +1394,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48377 if (ret < 0)
48378 goto out;
48379
48380 + if (kiocb->ki_iovec == &iovstack) {
48381 + kiocb->ki_inline_vec = iovstack;
48382 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48383 + }
48384 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48385 kiocb->ki_cur_seg = 0;
48386 /* ki_nbytes/left now reflect bytes instead of segs */
48387 diff --git a/fs/attr.c b/fs/attr.c
48388 index 1449adb..a2038c2 100644
48389 --- a/fs/attr.c
48390 +++ b/fs/attr.c
48391 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48392 unsigned long limit;
48393
48394 limit = rlimit(RLIMIT_FSIZE);
48395 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48396 if (limit != RLIM_INFINITY && offset > limit)
48397 goto out_sig;
48398 if (offset > inode->i_sb->s_maxbytes)
48399 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48400 index 03bc1d3..6205356 100644
48401 --- a/fs/autofs4/waitq.c
48402 +++ b/fs/autofs4/waitq.c
48403 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48404 {
48405 unsigned long sigpipe, flags;
48406 mm_segment_t fs;
48407 - const char *data = (const char *)addr;
48408 + const char __user *data = (const char __force_user *)addr;
48409 ssize_t wr = 0;
48410
48411 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48412 @@ -348,6 +348,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48413 return 1;
48414 }
48415
48416 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48417 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48418 +#endif
48419 +
48420 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48421 enum autofs_notify notify)
48422 {
48423 @@ -381,7 +385,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48424
48425 /* If this is a direct mount request create a dummy name */
48426 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48427 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48428 + /* this name does get written to userland via autofs4_write() */
48429 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48430 +#else
48431 qstr.len = sprintf(name, "%p", dentry);
48432 +#endif
48433 else {
48434 qstr.len = autofs4_getpath(sbi, dentry, &name);
48435 if (!qstr.len) {
48436 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48437 index 2722387..c8dd2a7 100644
48438 --- a/fs/befs/endian.h
48439 +++ b/fs/befs/endian.h
48440 @@ -11,7 +11,7 @@
48441
48442 #include <asm/byteorder.h>
48443
48444 -static inline u64
48445 +static inline u64 __intentional_overflow(-1)
48446 fs64_to_cpu(const struct super_block *sb, fs64 n)
48447 {
48448 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48449 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48450 return (__force fs64)cpu_to_be64(n);
48451 }
48452
48453 -static inline u32
48454 +static inline u32 __intentional_overflow(-1)
48455 fs32_to_cpu(const struct super_block *sb, fs32 n)
48456 {
48457 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48458 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48459 index 2b3bda8..6a2d4be 100644
48460 --- a/fs/befs/linuxvfs.c
48461 +++ b/fs/befs/linuxvfs.c
48462 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48463 {
48464 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48465 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48466 - char *link = nd_get_link(nd);
48467 + const char *link = nd_get_link(nd);
48468 if (!IS_ERR(link))
48469 kfree(link);
48470 }
48471 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48472 index 6043567..16a9239 100644
48473 --- a/fs/binfmt_aout.c
48474 +++ b/fs/binfmt_aout.c
48475 @@ -16,6 +16,7 @@
48476 #include <linux/string.h>
48477 #include <linux/fs.h>
48478 #include <linux/file.h>
48479 +#include <linux/security.h>
48480 #include <linux/stat.h>
48481 #include <linux/fcntl.h>
48482 #include <linux/ptrace.h>
48483 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48484 #endif
48485 # define START_STACK(u) ((void __user *)u.start_stack)
48486
48487 + memset(&dump, 0, sizeof(dump));
48488 +
48489 fs = get_fs();
48490 set_fs(KERNEL_DS);
48491 has_dumped = 1;
48492 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48493
48494 /* If the size of the dump file exceeds the rlimit, then see what would happen
48495 if we wrote the stack, but not the data area. */
48496 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48497 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48498 dump.u_dsize = 0;
48499
48500 /* Make sure we have enough room to write the stack and data areas. */
48501 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48502 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48503 dump.u_ssize = 0;
48504
48505 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48506 rlim = rlimit(RLIMIT_DATA);
48507 if (rlim >= RLIM_INFINITY)
48508 rlim = ~0;
48509 +
48510 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48511 if (ex.a_data + ex.a_bss > rlim)
48512 return -ENOMEM;
48513
48514 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48515
48516 install_exec_creds(bprm);
48517
48518 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48519 + current->mm->pax_flags = 0UL;
48520 +#endif
48521 +
48522 +#ifdef CONFIG_PAX_PAGEEXEC
48523 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48524 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48525 +
48526 +#ifdef CONFIG_PAX_EMUTRAMP
48527 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48528 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48529 +#endif
48530 +
48531 +#ifdef CONFIG_PAX_MPROTECT
48532 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48533 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48534 +#endif
48535 +
48536 + }
48537 +#endif
48538 +
48539 if (N_MAGIC(ex) == OMAGIC) {
48540 unsigned long text_addr, map_size;
48541 loff_t pos;
48542 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48543 }
48544
48545 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48546 - PROT_READ | PROT_WRITE | PROT_EXEC,
48547 + PROT_READ | PROT_WRITE,
48548 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48549 fd_offset + ex.a_text);
48550 if (error != N_DATADDR(ex)) {
48551 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48552 index 0c42cdb..b62581e9 100644
48553 --- a/fs/binfmt_elf.c
48554 +++ b/fs/binfmt_elf.c
48555 @@ -33,6 +33,7 @@
48556 #include <linux/elf.h>
48557 #include <linux/utsname.h>
48558 #include <linux/coredump.h>
48559 +#include <linux/xattr.h>
48560 #include <asm/uaccess.h>
48561 #include <asm/param.h>
48562 #include <asm/page.h>
48563 @@ -59,6 +60,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48564 #define elf_core_dump NULL
48565 #endif
48566
48567 +#ifdef CONFIG_PAX_MPROTECT
48568 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48569 +#endif
48570 +
48571 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48572 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48573 #else
48574 @@ -78,6 +83,11 @@ static struct linux_binfmt elf_format = {
48575 .load_binary = load_elf_binary,
48576 .load_shlib = load_elf_library,
48577 .core_dump = elf_core_dump,
48578 +
48579 +#ifdef CONFIG_PAX_MPROTECT
48580 + .handle_mprotect= elf_handle_mprotect,
48581 +#endif
48582 +
48583 .min_coredump = ELF_EXEC_PAGESIZE,
48584 };
48585
48586 @@ -85,6 +95,8 @@ static struct linux_binfmt elf_format = {
48587
48588 static int set_brk(unsigned long start, unsigned long end)
48589 {
48590 + unsigned long e = end;
48591 +
48592 start = ELF_PAGEALIGN(start);
48593 end = ELF_PAGEALIGN(end);
48594 if (end > start) {
48595 @@ -93,7 +105,7 @@ static int set_brk(unsigned long start, unsigned long end)
48596 if (BAD_ADDR(addr))
48597 return addr;
48598 }
48599 - current->mm->start_brk = current->mm->brk = end;
48600 + current->mm->start_brk = current->mm->brk = e;
48601 return 0;
48602 }
48603
48604 @@ -154,12 +166,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48605 elf_addr_t __user *u_rand_bytes;
48606 const char *k_platform = ELF_PLATFORM;
48607 const char *k_base_platform = ELF_BASE_PLATFORM;
48608 - unsigned char k_rand_bytes[16];
48609 + u32 k_rand_bytes[4];
48610 int items;
48611 elf_addr_t *elf_info;
48612 int ei_index = 0;
48613 const struct cred *cred = current_cred();
48614 struct vm_area_struct *vma;
48615 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48616
48617 /*
48618 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48619 @@ -201,8 +214,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48620 * Generate 16 random bytes for userspace PRNG seeding.
48621 */
48622 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48623 - u_rand_bytes = (elf_addr_t __user *)
48624 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48625 + srandom32(k_rand_bytes[0] ^ random32());
48626 + srandom32(k_rand_bytes[1] ^ random32());
48627 + srandom32(k_rand_bytes[2] ^ random32());
48628 + srandom32(k_rand_bytes[3] ^ random32());
48629 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48630 + u_rand_bytes = (elf_addr_t __user *) p;
48631 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48632 return -EFAULT;
48633
48634 @@ -314,9 +331,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48635 return -EFAULT;
48636 current->mm->env_end = p;
48637
48638 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48639 +
48640 /* Put the elf_info on the stack in the right place. */
48641 sp = (elf_addr_t __user *)envp + 1;
48642 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48643 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48644 return -EFAULT;
48645 return 0;
48646 }
48647 @@ -380,15 +399,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48648 an ELF header */
48649
48650 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48651 - struct file *interpreter, unsigned long *interp_map_addr,
48652 - unsigned long no_base)
48653 + struct file *interpreter, unsigned long no_base)
48654 {
48655 struct elf_phdr *elf_phdata;
48656 struct elf_phdr *eppnt;
48657 - unsigned long load_addr = 0;
48658 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48659 int load_addr_set = 0;
48660 unsigned long last_bss = 0, elf_bss = 0;
48661 - unsigned long error = ~0UL;
48662 + unsigned long error = -EINVAL;
48663 unsigned long total_size;
48664 int retval, i, size;
48665
48666 @@ -434,6 +452,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48667 goto out_close;
48668 }
48669
48670 +#ifdef CONFIG_PAX_SEGMEXEC
48671 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48672 + pax_task_size = SEGMEXEC_TASK_SIZE;
48673 +#endif
48674 +
48675 eppnt = elf_phdata;
48676 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48677 if (eppnt->p_type == PT_LOAD) {
48678 @@ -457,8 +480,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48679 map_addr = elf_map(interpreter, load_addr + vaddr,
48680 eppnt, elf_prot, elf_type, total_size);
48681 total_size = 0;
48682 - if (!*interp_map_addr)
48683 - *interp_map_addr = map_addr;
48684 error = map_addr;
48685 if (BAD_ADDR(map_addr))
48686 goto out_close;
48687 @@ -477,8 +498,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48688 k = load_addr + eppnt->p_vaddr;
48689 if (BAD_ADDR(k) ||
48690 eppnt->p_filesz > eppnt->p_memsz ||
48691 - eppnt->p_memsz > TASK_SIZE ||
48692 - TASK_SIZE - eppnt->p_memsz < k) {
48693 + eppnt->p_memsz > pax_task_size ||
48694 + pax_task_size - eppnt->p_memsz < k) {
48695 error = -ENOMEM;
48696 goto out_close;
48697 }
48698 @@ -530,6 +551,315 @@ out:
48699 return error;
48700 }
48701
48702 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48703 +#ifdef CONFIG_PAX_SOFTMODE
48704 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48705 +{
48706 + unsigned long pax_flags = 0UL;
48707 +
48708 +#ifdef CONFIG_PAX_PAGEEXEC
48709 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48710 + pax_flags |= MF_PAX_PAGEEXEC;
48711 +#endif
48712 +
48713 +#ifdef CONFIG_PAX_SEGMEXEC
48714 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48715 + pax_flags |= MF_PAX_SEGMEXEC;
48716 +#endif
48717 +
48718 +#ifdef CONFIG_PAX_EMUTRAMP
48719 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48720 + pax_flags |= MF_PAX_EMUTRAMP;
48721 +#endif
48722 +
48723 +#ifdef CONFIG_PAX_MPROTECT
48724 + if (elf_phdata->p_flags & PF_MPROTECT)
48725 + pax_flags |= MF_PAX_MPROTECT;
48726 +#endif
48727 +
48728 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48729 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48730 + pax_flags |= MF_PAX_RANDMMAP;
48731 +#endif
48732 +
48733 + return pax_flags;
48734 +}
48735 +#endif
48736 +
48737 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48738 +{
48739 + unsigned long pax_flags = 0UL;
48740 +
48741 +#ifdef CONFIG_PAX_PAGEEXEC
48742 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48743 + pax_flags |= MF_PAX_PAGEEXEC;
48744 +#endif
48745 +
48746 +#ifdef CONFIG_PAX_SEGMEXEC
48747 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48748 + pax_flags |= MF_PAX_SEGMEXEC;
48749 +#endif
48750 +
48751 +#ifdef CONFIG_PAX_EMUTRAMP
48752 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48753 + pax_flags |= MF_PAX_EMUTRAMP;
48754 +#endif
48755 +
48756 +#ifdef CONFIG_PAX_MPROTECT
48757 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48758 + pax_flags |= MF_PAX_MPROTECT;
48759 +#endif
48760 +
48761 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48762 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48763 + pax_flags |= MF_PAX_RANDMMAP;
48764 +#endif
48765 +
48766 + return pax_flags;
48767 +}
48768 +#endif
48769 +
48770 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48771 +#ifdef CONFIG_PAX_SOFTMODE
48772 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48773 +{
48774 + unsigned long pax_flags = 0UL;
48775 +
48776 +#ifdef CONFIG_PAX_PAGEEXEC
48777 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48778 + pax_flags |= MF_PAX_PAGEEXEC;
48779 +#endif
48780 +
48781 +#ifdef CONFIG_PAX_SEGMEXEC
48782 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48783 + pax_flags |= MF_PAX_SEGMEXEC;
48784 +#endif
48785 +
48786 +#ifdef CONFIG_PAX_EMUTRAMP
48787 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
48788 + pax_flags |= MF_PAX_EMUTRAMP;
48789 +#endif
48790 +
48791 +#ifdef CONFIG_PAX_MPROTECT
48792 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48793 + pax_flags |= MF_PAX_MPROTECT;
48794 +#endif
48795 +
48796 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48797 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48798 + pax_flags |= MF_PAX_RANDMMAP;
48799 +#endif
48800 +
48801 + return pax_flags;
48802 +}
48803 +#endif
48804 +
48805 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48806 +{
48807 + unsigned long pax_flags = 0UL;
48808 +
48809 +#ifdef CONFIG_PAX_PAGEEXEC
48810 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48811 + pax_flags |= MF_PAX_PAGEEXEC;
48812 +#endif
48813 +
48814 +#ifdef CONFIG_PAX_SEGMEXEC
48815 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48816 + pax_flags |= MF_PAX_SEGMEXEC;
48817 +#endif
48818 +
48819 +#ifdef CONFIG_PAX_EMUTRAMP
48820 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48821 + pax_flags |= MF_PAX_EMUTRAMP;
48822 +#endif
48823 +
48824 +#ifdef CONFIG_PAX_MPROTECT
48825 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48826 + pax_flags |= MF_PAX_MPROTECT;
48827 +#endif
48828 +
48829 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48830 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48831 + pax_flags |= MF_PAX_RANDMMAP;
48832 +#endif
48833 +
48834 + return pax_flags;
48835 +}
48836 +#endif
48837 +
48838 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48839 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48840 +{
48841 + unsigned long pax_flags = 0UL;
48842 +
48843 +#ifdef CONFIG_PAX_EI_PAX
48844 +
48845 +#ifdef CONFIG_PAX_PAGEEXEC
48846 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48847 + pax_flags |= MF_PAX_PAGEEXEC;
48848 +#endif
48849 +
48850 +#ifdef CONFIG_PAX_SEGMEXEC
48851 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48852 + pax_flags |= MF_PAX_SEGMEXEC;
48853 +#endif
48854 +
48855 +#ifdef CONFIG_PAX_EMUTRAMP
48856 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48857 + pax_flags |= MF_PAX_EMUTRAMP;
48858 +#endif
48859 +
48860 +#ifdef CONFIG_PAX_MPROTECT
48861 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48862 + pax_flags |= MF_PAX_MPROTECT;
48863 +#endif
48864 +
48865 +#ifdef CONFIG_PAX_ASLR
48866 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48867 + pax_flags |= MF_PAX_RANDMMAP;
48868 +#endif
48869 +
48870 +#else
48871 +
48872 +#ifdef CONFIG_PAX_PAGEEXEC
48873 + pax_flags |= MF_PAX_PAGEEXEC;
48874 +#endif
48875 +
48876 +#ifdef CONFIG_PAX_SEGMEXEC
48877 + pax_flags |= MF_PAX_SEGMEXEC;
48878 +#endif
48879 +
48880 +#ifdef CONFIG_PAX_MPROTECT
48881 + pax_flags |= MF_PAX_MPROTECT;
48882 +#endif
48883 +
48884 +#ifdef CONFIG_PAX_RANDMMAP
48885 + if (randomize_va_space)
48886 + pax_flags |= MF_PAX_RANDMMAP;
48887 +#endif
48888 +
48889 +#endif
48890 +
48891 + return pax_flags;
48892 +}
48893 +
48894 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48895 +{
48896 +
48897 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48898 + unsigned long i;
48899 +
48900 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48901 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48902 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48903 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48904 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48905 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48906 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48907 + return ~0UL;
48908 +
48909 +#ifdef CONFIG_PAX_SOFTMODE
48910 + if (pax_softmode)
48911 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48912 + else
48913 +#endif
48914 +
48915 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48916 + break;
48917 + }
48918 +#endif
48919 +
48920 + return ~0UL;
48921 +}
48922 +
48923 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48924 +{
48925 +
48926 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48927 + ssize_t xattr_size, i;
48928 + unsigned char xattr_value[5];
48929 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48930 +
48931 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
48932 + if (xattr_size <= 0 || xattr_size > 5)
48933 + return ~0UL;
48934 +
48935 + for (i = 0; i < xattr_size; i++)
48936 + switch (xattr_value[i]) {
48937 + default:
48938 + return ~0UL;
48939 +
48940 +#define parse_flag(option1, option2, flag) \
48941 + case option1: \
48942 + if (pax_flags_hardmode & MF_PAX_##flag) \
48943 + return ~0UL; \
48944 + pax_flags_hardmode |= MF_PAX_##flag; \
48945 + break; \
48946 + case option2: \
48947 + if (pax_flags_softmode & MF_PAX_##flag) \
48948 + return ~0UL; \
48949 + pax_flags_softmode |= MF_PAX_##flag; \
48950 + break;
48951 +
48952 + parse_flag('p', 'P', PAGEEXEC);
48953 + parse_flag('e', 'E', EMUTRAMP);
48954 + parse_flag('m', 'M', MPROTECT);
48955 + parse_flag('r', 'R', RANDMMAP);
48956 + parse_flag('s', 'S', SEGMEXEC);
48957 +
48958 +#undef parse_flag
48959 + }
48960 +
48961 + if (pax_flags_hardmode & pax_flags_softmode)
48962 + return ~0UL;
48963 +
48964 +#ifdef CONFIG_PAX_SOFTMODE
48965 + if (pax_softmode)
48966 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48967 + else
48968 +#endif
48969 +
48970 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
48971 +#else
48972 + return ~0UL;
48973 +#endif
48974 +
48975 +}
48976 +
48977 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48978 +{
48979 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48980 +
48981 + pax_flags = pax_parse_ei_pax(elf_ex);
48982 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48983 + xattr_pax_flags = pax_parse_xattr_pax(file);
48984 +
48985 + if (pt_pax_flags == ~0UL)
48986 + pt_pax_flags = xattr_pax_flags;
48987 + else if (xattr_pax_flags == ~0UL)
48988 + xattr_pax_flags = pt_pax_flags;
48989 + if (pt_pax_flags != xattr_pax_flags)
48990 + return -EINVAL;
48991 + if (pt_pax_flags != ~0UL)
48992 + pax_flags = pt_pax_flags;
48993 +
48994 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48995 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48996 + if ((__supported_pte_mask & _PAGE_NX))
48997 + pax_flags &= ~MF_PAX_SEGMEXEC;
48998 + else
48999 + pax_flags &= ~MF_PAX_PAGEEXEC;
49000 + }
49001 +#endif
49002 +
49003 + if (0 > pax_check_flags(&pax_flags))
49004 + return -EINVAL;
49005 +
49006 + current->mm->pax_flags = pax_flags;
49007 + return 0;
49008 +}
49009 +#endif
49010 +
49011 /*
49012 * These are the functions used to load ELF style executables and shared
49013 * libraries. There is no binary dependent code anywhere else.
49014 @@ -546,6 +876,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
49015 {
49016 unsigned int random_variable = 0;
49017
49018 +#ifdef CONFIG_PAX_RANDUSTACK
49019 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
49020 + return stack_top - current->mm->delta_stack;
49021 +#endif
49022 +
49023 if ((current->flags & PF_RANDOMIZE) &&
49024 !(current->personality & ADDR_NO_RANDOMIZE)) {
49025 random_variable = get_random_int() & STACK_RND_MASK;
49026 @@ -564,7 +899,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
49027 unsigned long load_addr = 0, load_bias = 0;
49028 int load_addr_set = 0;
49029 char * elf_interpreter = NULL;
49030 - unsigned long error;
49031 + unsigned long error = 0;
49032 struct elf_phdr *elf_ppnt, *elf_phdata;
49033 unsigned long elf_bss, elf_brk;
49034 int retval, i;
49035 @@ -574,12 +909,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
49036 unsigned long start_code, end_code, start_data, end_data;
49037 unsigned long reloc_func_desc __maybe_unused = 0;
49038 int executable_stack = EXSTACK_DEFAULT;
49039 - unsigned long def_flags = 0;
49040 struct pt_regs *regs = current_pt_regs();
49041 struct {
49042 struct elfhdr elf_ex;
49043 struct elfhdr interp_elf_ex;
49044 } *loc;
49045 + unsigned long pax_task_size = TASK_SIZE;
49046
49047 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
49048 if (!loc) {
49049 @@ -715,11 +1050,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
49050 goto out_free_dentry;
49051
49052 /* OK, This is the point of no return */
49053 - current->mm->def_flags = def_flags;
49054 +
49055 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49056 + current->mm->pax_flags = 0UL;
49057 +#endif
49058 +
49059 +#ifdef CONFIG_PAX_DLRESOLVE
49060 + current->mm->call_dl_resolve = 0UL;
49061 +#endif
49062 +
49063 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
49064 + current->mm->call_syscall = 0UL;
49065 +#endif
49066 +
49067 +#ifdef CONFIG_PAX_ASLR
49068 + current->mm->delta_mmap = 0UL;
49069 + current->mm->delta_stack = 0UL;
49070 +#endif
49071 +
49072 + current->mm->def_flags = 0;
49073 +
49074 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49075 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
49076 + send_sig(SIGKILL, current, 0);
49077 + goto out_free_dentry;
49078 + }
49079 +#endif
49080 +
49081 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49082 + pax_set_initial_flags(bprm);
49083 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49084 + if (pax_set_initial_flags_func)
49085 + (pax_set_initial_flags_func)(bprm);
49086 +#endif
49087 +
49088 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49089 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49090 + current->mm->context.user_cs_limit = PAGE_SIZE;
49091 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49092 + }
49093 +#endif
49094 +
49095 +#ifdef CONFIG_PAX_SEGMEXEC
49096 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49097 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49098 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49099 + pax_task_size = SEGMEXEC_TASK_SIZE;
49100 + current->mm->def_flags |= VM_NOHUGEPAGE;
49101 + }
49102 +#endif
49103 +
49104 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49105 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49106 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49107 + put_cpu();
49108 + }
49109 +#endif
49110
49111 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49112 may depend on the personality. */
49113 SET_PERSONALITY(loc->elf_ex);
49114 +
49115 +#ifdef CONFIG_PAX_ASLR
49116 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49117 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49118 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49119 + }
49120 +#endif
49121 +
49122 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49123 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49124 + executable_stack = EXSTACK_DISABLE_X;
49125 + current->personality &= ~READ_IMPLIES_EXEC;
49126 + } else
49127 +#endif
49128 +
49129 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49130 current->personality |= READ_IMPLIES_EXEC;
49131
49132 @@ -810,6 +1215,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49133 #else
49134 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49135 #endif
49136 +
49137 +#ifdef CONFIG_PAX_RANDMMAP
49138 + /* PaX: randomize base address at the default exe base if requested */
49139 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49140 +#ifdef CONFIG_SPARC64
49141 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49142 +#else
49143 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49144 +#endif
49145 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49146 + elf_flags |= MAP_FIXED;
49147 + }
49148 +#endif
49149 +
49150 }
49151
49152 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49153 @@ -842,9 +1261,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49154 * allowed task size. Note that p_filesz must always be
49155 * <= p_memsz so it is only necessary to check p_memsz.
49156 */
49157 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49158 - elf_ppnt->p_memsz > TASK_SIZE ||
49159 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49160 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49161 + elf_ppnt->p_memsz > pax_task_size ||
49162 + pax_task_size - elf_ppnt->p_memsz < k) {
49163 /* set_brk can never work. Avoid overflows. */
49164 send_sig(SIGKILL, current, 0);
49165 retval = -EINVAL;
49166 @@ -883,17 +1302,44 @@ static int load_elf_binary(struct linux_binprm *bprm)
49167 goto out_free_dentry;
49168 }
49169 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49170 - send_sig(SIGSEGV, current, 0);
49171 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49172 - goto out_free_dentry;
49173 + /*
49174 + * This bss-zeroing can fail if the ELF
49175 + * file specifies odd protections. So
49176 + * we don't check the return value
49177 + */
49178 }
49179
49180 +#ifdef CONFIG_PAX_RANDMMAP
49181 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49182 + unsigned long start, size, flags, vm_flags;
49183 +
49184 + start = ELF_PAGEALIGN(elf_brk);
49185 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49186 + flags = MAP_FIXED | MAP_PRIVATE;
49187 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49188 +
49189 + down_write(&current->mm->mmap_sem);
49190 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49191 + retval = -ENOMEM;
49192 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49193 +// if (current->personality & ADDR_NO_RANDOMIZE)
49194 +// vm_flags |= VM_READ | VM_MAYREAD;
49195 + start = mmap_region(NULL, start, PAGE_ALIGN(size), flags, vm_flags, 0);
49196 + retval = IS_ERR_VALUE(start) ? start : 0;
49197 + }
49198 + up_write(&current->mm->mmap_sem);
49199 + if (retval == 0)
49200 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49201 + if (retval < 0) {
49202 + send_sig(SIGKILL, current, 0);
49203 + goto out_free_dentry;
49204 + }
49205 + }
49206 +#endif
49207 +
49208 if (elf_interpreter) {
49209 - unsigned long interp_map_addr = 0;
49210 -
49211 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49212 interpreter,
49213 - &interp_map_addr,
49214 load_bias);
49215 if (!IS_ERR((void *)elf_entry)) {
49216 /*
49217 @@ -1115,7 +1561,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49218 * Decide what to dump of a segment, part, all or none.
49219 */
49220 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49221 - unsigned long mm_flags)
49222 + unsigned long mm_flags, long signr)
49223 {
49224 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49225
49226 @@ -1152,7 +1598,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49227 if (vma->vm_file == NULL)
49228 return 0;
49229
49230 - if (FILTER(MAPPED_PRIVATE))
49231 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49232 goto whole;
49233
49234 /*
49235 @@ -1374,9 +1820,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49236 {
49237 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49238 int i = 0;
49239 - do
49240 + do {
49241 i += 2;
49242 - while (auxv[i - 2] != AT_NULL);
49243 + } while (auxv[i - 2] != AT_NULL);
49244 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49245 }
49246
49247 @@ -2006,14 +2452,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49248 }
49249
49250 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49251 - unsigned long mm_flags)
49252 + struct coredump_params *cprm)
49253 {
49254 struct vm_area_struct *vma;
49255 size_t size = 0;
49256
49257 for (vma = first_vma(current, gate_vma); vma != NULL;
49258 vma = next_vma(vma, gate_vma))
49259 - size += vma_dump_size(vma, mm_flags);
49260 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49261 return size;
49262 }
49263
49264 @@ -2107,7 +2553,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49265
49266 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49267
49268 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49269 + offset += elf_core_vma_data_size(gate_vma, cprm);
49270 offset += elf_core_extra_data_size();
49271 e_shoff = offset;
49272
49273 @@ -2121,10 +2567,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49274 offset = dataoff;
49275
49276 size += sizeof(*elf);
49277 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49278 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49279 goto end_coredump;
49280
49281 size += sizeof(*phdr4note);
49282 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49283 if (size > cprm->limit
49284 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49285 goto end_coredump;
49286 @@ -2138,7 +2586,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49287 phdr.p_offset = offset;
49288 phdr.p_vaddr = vma->vm_start;
49289 phdr.p_paddr = 0;
49290 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49291 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49292 phdr.p_memsz = vma->vm_end - vma->vm_start;
49293 offset += phdr.p_filesz;
49294 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49295 @@ -2149,6 +2597,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49296 phdr.p_align = ELF_EXEC_PAGESIZE;
49297
49298 size += sizeof(phdr);
49299 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49300 if (size > cprm->limit
49301 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49302 goto end_coredump;
49303 @@ -2173,7 +2622,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49304 unsigned long addr;
49305 unsigned long end;
49306
49307 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49308 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49309
49310 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49311 struct page *page;
49312 @@ -2182,6 +2631,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49313 page = get_dump_page(addr);
49314 if (page) {
49315 void *kaddr = kmap(page);
49316 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49317 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49318 !dump_write(cprm->file, kaddr,
49319 PAGE_SIZE);
49320 @@ -2199,6 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49321
49322 if (e_phnum == PN_XNUM) {
49323 size += sizeof(*shdr4extnum);
49324 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49325 if (size > cprm->limit
49326 || !dump_write(cprm->file, shdr4extnum,
49327 sizeof(*shdr4extnum)))
49328 @@ -2219,6 +2670,97 @@ out:
49329
49330 #endif /* CONFIG_ELF_CORE */
49331
49332 +#ifdef CONFIG_PAX_MPROTECT
49333 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49334 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49335 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49336 + *
49337 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49338 + * basis because we want to allow the common case and not the special ones.
49339 + */
49340 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49341 +{
49342 + struct elfhdr elf_h;
49343 + struct elf_phdr elf_p;
49344 + unsigned long i;
49345 + unsigned long oldflags;
49346 + bool is_textrel_rw, is_textrel_rx, is_relro;
49347 +
49348 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49349 + return;
49350 +
49351 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49352 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49353 +
49354 +#ifdef CONFIG_PAX_ELFRELOCS
49355 + /* possible TEXTREL */
49356 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49357 + 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);
49358 +#else
49359 + is_textrel_rw = false;
49360 + is_textrel_rx = false;
49361 +#endif
49362 +
49363 + /* possible RELRO */
49364 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49365 +
49366 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49367 + return;
49368 +
49369 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49370 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49371 +
49372 +#ifdef CONFIG_PAX_ETEXECRELOCS
49373 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49374 +#else
49375 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49376 +#endif
49377 +
49378 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49379 + !elf_check_arch(&elf_h) ||
49380 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49381 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49382 + return;
49383 +
49384 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49385 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49386 + return;
49387 + switch (elf_p.p_type) {
49388 + case PT_DYNAMIC:
49389 + if (!is_textrel_rw && !is_textrel_rx)
49390 + continue;
49391 + i = 0UL;
49392 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49393 + elf_dyn dyn;
49394 +
49395 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49396 + return;
49397 + if (dyn.d_tag == DT_NULL)
49398 + return;
49399 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49400 + gr_log_textrel(vma);
49401 + if (is_textrel_rw)
49402 + vma->vm_flags |= VM_MAYWRITE;
49403 + else
49404 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49405 + vma->vm_flags &= ~VM_MAYWRITE;
49406 + return;
49407 + }
49408 + i++;
49409 + }
49410 + return;
49411 +
49412 + case PT_GNU_RELRO:
49413 + if (!is_relro)
49414 + continue;
49415 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49416 + vma->vm_flags &= ~VM_MAYWRITE;
49417 + return;
49418 + }
49419 + }
49420 +}
49421 +#endif
49422 +
49423 static int __init init_elf_binfmt(void)
49424 {
49425 register_binfmt(&elf_format);
49426 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49427 index b563719..3868998 100644
49428 --- a/fs/binfmt_flat.c
49429 +++ b/fs/binfmt_flat.c
49430 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49431 realdatastart = (unsigned long) -ENOMEM;
49432 printk("Unable to allocate RAM for process data, errno %d\n",
49433 (int)-realdatastart);
49434 + down_write(&current->mm->mmap_sem);
49435 vm_munmap(textpos, text_len);
49436 + up_write(&current->mm->mmap_sem);
49437 ret = realdatastart;
49438 goto err;
49439 }
49440 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49441 }
49442 if (IS_ERR_VALUE(result)) {
49443 printk("Unable to read data+bss, errno %d\n", (int)-result);
49444 + down_write(&current->mm->mmap_sem);
49445 vm_munmap(textpos, text_len);
49446 vm_munmap(realdatastart, len);
49447 + up_write(&current->mm->mmap_sem);
49448 ret = result;
49449 goto err;
49450 }
49451 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49452 }
49453 if (IS_ERR_VALUE(result)) {
49454 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49455 + down_write(&current->mm->mmap_sem);
49456 vm_munmap(textpos, text_len + data_len + extra +
49457 MAX_SHARED_LIBS * sizeof(unsigned long));
49458 + up_write(&current->mm->mmap_sem);
49459 ret = result;
49460 goto err;
49461 }
49462 diff --git a/fs/bio.c b/fs/bio.c
49463 index b96fc6c..431d628 100644
49464 --- a/fs/bio.c
49465 +++ b/fs/bio.c
49466 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49467 /*
49468 * Overflow, abort
49469 */
49470 - if (end < start)
49471 + if (end < start || end - start > INT_MAX - nr_pages)
49472 return ERR_PTR(-EINVAL);
49473
49474 nr_pages += end - start;
49475 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49476 /*
49477 * Overflow, abort
49478 */
49479 - if (end < start)
49480 + if (end < start || end - start > INT_MAX - nr_pages)
49481 return ERR_PTR(-EINVAL);
49482
49483 nr_pages += end - start;
49484 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49485 const int read = bio_data_dir(bio) == READ;
49486 struct bio_map_data *bmd = bio->bi_private;
49487 int i;
49488 - char *p = bmd->sgvecs[0].iov_base;
49489 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49490
49491 __bio_for_each_segment(bvec, bio, i, 0) {
49492 char *addr = page_address(bvec->bv_page);
49493 diff --git a/fs/block_dev.c b/fs/block_dev.c
49494 index 883dc49..f27794a 100644
49495 --- a/fs/block_dev.c
49496 +++ b/fs/block_dev.c
49497 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49498 else if (bdev->bd_contains == bdev)
49499 return true; /* is a whole device which isn't held */
49500
49501 - else if (whole->bd_holder == bd_may_claim)
49502 + else if (whole->bd_holder == (void *)bd_may_claim)
49503 return true; /* is a partition of a device that is being partitioned */
49504 else if (whole->bd_holder != NULL)
49505 return false; /* is a partition of a held device */
49506 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49507 index ce1c169..1ef484f 100644
49508 --- a/fs/btrfs/ctree.c
49509 +++ b/fs/btrfs/ctree.c
49510 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49511 free_extent_buffer(buf);
49512 add_root_to_dirty_list(root);
49513 } else {
49514 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49515 - parent_start = parent->start;
49516 - else
49517 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49518 + if (parent)
49519 + parent_start = parent->start;
49520 + else
49521 + parent_start = 0;
49522 + } else
49523 parent_start = 0;
49524
49525 WARN_ON(trans->transid != btrfs_header_generation(parent));
49526 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
49527 index 7c4e6cc..27bd5c2 100644
49528 --- a/fs/btrfs/inode.c
49529 +++ b/fs/btrfs/inode.c
49530 @@ -7314,7 +7314,7 @@ fail:
49531 return -ENOMEM;
49532 }
49533
49534 -static int btrfs_getattr(struct vfsmount *mnt,
49535 +int btrfs_getattr(struct vfsmount *mnt,
49536 struct dentry *dentry, struct kstat *stat)
49537 {
49538 struct inode *inode = dentry->d_inode;
49539 @@ -7328,6 +7328,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
49540 return 0;
49541 }
49542
49543 +EXPORT_SYMBOL(btrfs_getattr);
49544 +
49545 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
49546 +{
49547 + return BTRFS_I(inode)->root->anon_dev;
49548 +}
49549 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
49550 +
49551 /*
49552 * If a file is moved, it will inherit the cow and compression flags of the new
49553 * directory.
49554 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49555 index 338f259..b657640 100644
49556 --- a/fs/btrfs/ioctl.c
49557 +++ b/fs/btrfs/ioctl.c
49558 @@ -3033,9 +3033,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49559 for (i = 0; i < num_types; i++) {
49560 struct btrfs_space_info *tmp;
49561
49562 + /* Don't copy in more than we allocated */
49563 if (!slot_count)
49564 break;
49565
49566 + slot_count--;
49567 +
49568 info = NULL;
49569 rcu_read_lock();
49570 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49571 @@ -3057,10 +3060,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49572 memcpy(dest, &space, sizeof(space));
49573 dest++;
49574 space_args.total_spaces++;
49575 - slot_count--;
49576 }
49577 - if (!slot_count)
49578 - break;
49579 }
49580 up_read(&info->groups_sem);
49581 }
49582 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
49583 index 300e09a..9fe4539 100644
49584 --- a/fs/btrfs/relocation.c
49585 +++ b/fs/btrfs/relocation.c
49586 @@ -1269,7 +1269,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
49587 }
49588 spin_unlock(&rc->reloc_root_tree.lock);
49589
49590 - BUG_ON((struct btrfs_root *)node->data != root);
49591 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
49592
49593 if (!del) {
49594 spin_lock(&rc->reloc_root_tree.lock);
49595 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49596 index d8982e9..29a85fa 100644
49597 --- a/fs/btrfs/super.c
49598 +++ b/fs/btrfs/super.c
49599 @@ -267,7 +267,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49600 function, line, errstr);
49601 return;
49602 }
49603 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49604 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49605 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49606 }
49607 /*
49608 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49609 index 622f469..e8d2d55 100644
49610 --- a/fs/cachefiles/bind.c
49611 +++ b/fs/cachefiles/bind.c
49612 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49613 args);
49614
49615 /* start by checking things over */
49616 - ASSERT(cache->fstop_percent >= 0 &&
49617 - cache->fstop_percent < cache->fcull_percent &&
49618 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49619 cache->fcull_percent < cache->frun_percent &&
49620 cache->frun_percent < 100);
49621
49622 - ASSERT(cache->bstop_percent >= 0 &&
49623 - cache->bstop_percent < cache->bcull_percent &&
49624 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49625 cache->bcull_percent < cache->brun_percent &&
49626 cache->brun_percent < 100);
49627
49628 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49629 index 0a1467b..6a53245 100644
49630 --- a/fs/cachefiles/daemon.c
49631 +++ b/fs/cachefiles/daemon.c
49632 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49633 if (n > buflen)
49634 return -EMSGSIZE;
49635
49636 - if (copy_to_user(_buffer, buffer, n) != 0)
49637 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49638 return -EFAULT;
49639
49640 return n;
49641 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49642 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49643 return -EIO;
49644
49645 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49646 + if (datalen > PAGE_SIZE - 1)
49647 return -EOPNOTSUPP;
49648
49649 /* drag the command string into the kernel so we can parse it */
49650 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49651 if (args[0] != '%' || args[1] != '\0')
49652 return -EINVAL;
49653
49654 - if (fstop < 0 || fstop >= cache->fcull_percent)
49655 + if (fstop >= cache->fcull_percent)
49656 return cachefiles_daemon_range_error(cache, args);
49657
49658 cache->fstop_percent = fstop;
49659 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49660 if (args[0] != '%' || args[1] != '\0')
49661 return -EINVAL;
49662
49663 - if (bstop < 0 || bstop >= cache->bcull_percent)
49664 + if (bstop >= cache->bcull_percent)
49665 return cachefiles_daemon_range_error(cache, args);
49666
49667 cache->bstop_percent = bstop;
49668 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49669 index 4938251..7e01445 100644
49670 --- a/fs/cachefiles/internal.h
49671 +++ b/fs/cachefiles/internal.h
49672 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49673 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49674 struct rb_root active_nodes; /* active nodes (can't be culled) */
49675 rwlock_t active_lock; /* lock for active_nodes */
49676 - atomic_t gravecounter; /* graveyard uniquifier */
49677 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49678 unsigned frun_percent; /* when to stop culling (% files) */
49679 unsigned fcull_percent; /* when to start culling (% files) */
49680 unsigned fstop_percent; /* when to stop allocating (% files) */
49681 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49682 * proc.c
49683 */
49684 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49685 -extern atomic_t cachefiles_lookup_histogram[HZ];
49686 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49687 -extern atomic_t cachefiles_create_histogram[HZ];
49688 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49689 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49690 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49691
49692 extern int __init cachefiles_proc_init(void);
49693 extern void cachefiles_proc_cleanup(void);
49694 static inline
49695 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49696 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49697 {
49698 unsigned long jif = jiffies - start_jif;
49699 if (jif >= HZ)
49700 jif = HZ - 1;
49701 - atomic_inc(&histogram[jif]);
49702 + atomic_inc_unchecked(&histogram[jif]);
49703 }
49704
49705 #else
49706 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49707 index 8c01c5fc..15f982e 100644
49708 --- a/fs/cachefiles/namei.c
49709 +++ b/fs/cachefiles/namei.c
49710 @@ -317,7 +317,7 @@ try_again:
49711 /* first step is to make up a grave dentry in the graveyard */
49712 sprintf(nbuffer, "%08x%08x",
49713 (uint32_t) get_seconds(),
49714 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49715 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49716
49717 /* do the multiway lock magic */
49718 trap = lock_rename(cache->graveyard, dir);
49719 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49720 index eccd339..4c1d995 100644
49721 --- a/fs/cachefiles/proc.c
49722 +++ b/fs/cachefiles/proc.c
49723 @@ -14,9 +14,9 @@
49724 #include <linux/seq_file.h>
49725 #include "internal.h"
49726
49727 -atomic_t cachefiles_lookup_histogram[HZ];
49728 -atomic_t cachefiles_mkdir_histogram[HZ];
49729 -atomic_t cachefiles_create_histogram[HZ];
49730 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49731 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49732 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49733
49734 /*
49735 * display the latency histogram
49736 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49737 return 0;
49738 default:
49739 index = (unsigned long) v - 3;
49740 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49741 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49742 - z = atomic_read(&cachefiles_create_histogram[index]);
49743 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49744 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49745 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49746 if (x == 0 && y == 0 && z == 0)
49747 return 0;
49748
49749 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49750 index 4809922..aab2c39 100644
49751 --- a/fs/cachefiles/rdwr.c
49752 +++ b/fs/cachefiles/rdwr.c
49753 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49754 old_fs = get_fs();
49755 set_fs(KERNEL_DS);
49756 ret = file->f_op->write(
49757 - file, (const void __user *) data, len, &pos);
49758 + file, (const void __force_user *) data, len, &pos);
49759 set_fs(old_fs);
49760 kunmap(page);
49761 if (ret != len)
49762 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49763 index 8c1aabe..bbf856a 100644
49764 --- a/fs/ceph/dir.c
49765 +++ b/fs/ceph/dir.c
49766 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49767 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49768 struct ceph_mds_client *mdsc = fsc->mdsc;
49769 unsigned frag = fpos_frag(filp->f_pos);
49770 - int off = fpos_off(filp->f_pos);
49771 + unsigned int off = fpos_off(filp->f_pos);
49772 int err;
49773 u32 ftype;
49774 struct ceph_mds_reply_info_parsed *rinfo;
49775 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49776 index d9ea6ed..1e6c8ac 100644
49777 --- a/fs/cifs/cifs_debug.c
49778 +++ b/fs/cifs/cifs_debug.c
49779 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49780
49781 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49782 #ifdef CONFIG_CIFS_STATS2
49783 - atomic_set(&totBufAllocCount, 0);
49784 - atomic_set(&totSmBufAllocCount, 0);
49785 + atomic_set_unchecked(&totBufAllocCount, 0);
49786 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49787 #endif /* CONFIG_CIFS_STATS2 */
49788 spin_lock(&cifs_tcp_ses_lock);
49789 list_for_each(tmp1, &cifs_tcp_ses_list) {
49790 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49791 tcon = list_entry(tmp3,
49792 struct cifs_tcon,
49793 tcon_list);
49794 - atomic_set(&tcon->num_smbs_sent, 0);
49795 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49796 if (server->ops->clear_stats)
49797 server->ops->clear_stats(tcon);
49798 }
49799 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49800 smBufAllocCount.counter, cifs_min_small);
49801 #ifdef CONFIG_CIFS_STATS2
49802 seq_printf(m, "Total Large %d Small %d Allocations\n",
49803 - atomic_read(&totBufAllocCount),
49804 - atomic_read(&totSmBufAllocCount));
49805 + atomic_read_unchecked(&totBufAllocCount),
49806 + atomic_read_unchecked(&totSmBufAllocCount));
49807 #endif /* CONFIG_CIFS_STATS2 */
49808
49809 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49810 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49811 if (tcon->need_reconnect)
49812 seq_puts(m, "\tDISCONNECTED ");
49813 seq_printf(m, "\nSMBs: %d",
49814 - atomic_read(&tcon->num_smbs_sent));
49815 + atomic_read_unchecked(&tcon->num_smbs_sent));
49816 if (server->ops->print_stats)
49817 server->ops->print_stats(m, tcon);
49818 }
49819 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49820 index b9db388..9a73d6d 100644
49821 --- a/fs/cifs/cifsfs.c
49822 +++ b/fs/cifs/cifsfs.c
49823 @@ -1026,7 +1026,7 @@ cifs_init_request_bufs(void)
49824 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49825 cifs_req_cachep = kmem_cache_create("cifs_request",
49826 CIFSMaxBufSize + max_hdr_size, 0,
49827 - SLAB_HWCACHE_ALIGN, NULL);
49828 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49829 if (cifs_req_cachep == NULL)
49830 return -ENOMEM;
49831
49832 @@ -1053,7 +1053,7 @@ cifs_init_request_bufs(void)
49833 efficient to alloc 1 per page off the slab compared to 17K (5page)
49834 alloc of large cifs buffers even when page debugging is on */
49835 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49836 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49837 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49838 NULL);
49839 if (cifs_sm_req_cachep == NULL) {
49840 mempool_destroy(cifs_req_poolp);
49841 @@ -1138,8 +1138,8 @@ init_cifs(void)
49842 atomic_set(&bufAllocCount, 0);
49843 atomic_set(&smBufAllocCount, 0);
49844 #ifdef CONFIG_CIFS_STATS2
49845 - atomic_set(&totBufAllocCount, 0);
49846 - atomic_set(&totSmBufAllocCount, 0);
49847 + atomic_set_unchecked(&totBufAllocCount, 0);
49848 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49849 #endif /* CONFIG_CIFS_STATS2 */
49850
49851 atomic_set(&midCount, 0);
49852 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49853 index e6899ce..d6b2920 100644
49854 --- a/fs/cifs/cifsglob.h
49855 +++ b/fs/cifs/cifsglob.h
49856 @@ -751,35 +751,35 @@ struct cifs_tcon {
49857 __u16 Flags; /* optional support bits */
49858 enum statusEnum tidStatus;
49859 #ifdef CONFIG_CIFS_STATS
49860 - atomic_t num_smbs_sent;
49861 + atomic_unchecked_t num_smbs_sent;
49862 union {
49863 struct {
49864 - atomic_t num_writes;
49865 - atomic_t num_reads;
49866 - atomic_t num_flushes;
49867 - atomic_t num_oplock_brks;
49868 - atomic_t num_opens;
49869 - atomic_t num_closes;
49870 - atomic_t num_deletes;
49871 - atomic_t num_mkdirs;
49872 - atomic_t num_posixopens;
49873 - atomic_t num_posixmkdirs;
49874 - atomic_t num_rmdirs;
49875 - atomic_t num_renames;
49876 - atomic_t num_t2renames;
49877 - atomic_t num_ffirst;
49878 - atomic_t num_fnext;
49879 - atomic_t num_fclose;
49880 - atomic_t num_hardlinks;
49881 - atomic_t num_symlinks;
49882 - atomic_t num_locks;
49883 - atomic_t num_acl_get;
49884 - atomic_t num_acl_set;
49885 + atomic_unchecked_t num_writes;
49886 + atomic_unchecked_t num_reads;
49887 + atomic_unchecked_t num_flushes;
49888 + atomic_unchecked_t num_oplock_brks;
49889 + atomic_unchecked_t num_opens;
49890 + atomic_unchecked_t num_closes;
49891 + atomic_unchecked_t num_deletes;
49892 + atomic_unchecked_t num_mkdirs;
49893 + atomic_unchecked_t num_posixopens;
49894 + atomic_unchecked_t num_posixmkdirs;
49895 + atomic_unchecked_t num_rmdirs;
49896 + atomic_unchecked_t num_renames;
49897 + atomic_unchecked_t num_t2renames;
49898 + atomic_unchecked_t num_ffirst;
49899 + atomic_unchecked_t num_fnext;
49900 + atomic_unchecked_t num_fclose;
49901 + atomic_unchecked_t num_hardlinks;
49902 + atomic_unchecked_t num_symlinks;
49903 + atomic_unchecked_t num_locks;
49904 + atomic_unchecked_t num_acl_get;
49905 + atomic_unchecked_t num_acl_set;
49906 } cifs_stats;
49907 #ifdef CONFIG_CIFS_SMB2
49908 struct {
49909 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49910 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49911 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49912 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49913 } smb2_stats;
49914 #endif /* CONFIG_CIFS_SMB2 */
49915 } stats;
49916 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49917 }
49918
49919 #ifdef CONFIG_CIFS_STATS
49920 -#define cifs_stats_inc atomic_inc
49921 +#define cifs_stats_inc atomic_inc_unchecked
49922
49923 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49924 unsigned int bytes)
49925 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49926 /* Various Debug counters */
49927 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49928 #ifdef CONFIG_CIFS_STATS2
49929 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49930 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49931 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49932 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49933 #endif
49934 GLOBAL_EXTERN atomic_t smBufAllocCount;
49935 GLOBAL_EXTERN atomic_t midCount;
49936 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49937 index 51dc2fb..1e12a33 100644
49938 --- a/fs/cifs/link.c
49939 +++ b/fs/cifs/link.c
49940 @@ -616,7 +616,7 @@ symlink_exit:
49941
49942 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49943 {
49944 - char *p = nd_get_link(nd);
49945 + const char *p = nd_get_link(nd);
49946 if (!IS_ERR(p))
49947 kfree(p);
49948 }
49949 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49950 index 3a00c0d..42d901c 100644
49951 --- a/fs/cifs/misc.c
49952 +++ b/fs/cifs/misc.c
49953 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49954 memset(ret_buf, 0, buf_size + 3);
49955 atomic_inc(&bufAllocCount);
49956 #ifdef CONFIG_CIFS_STATS2
49957 - atomic_inc(&totBufAllocCount);
49958 + atomic_inc_unchecked(&totBufAllocCount);
49959 #endif /* CONFIG_CIFS_STATS2 */
49960 }
49961
49962 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49963 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49964 atomic_inc(&smBufAllocCount);
49965 #ifdef CONFIG_CIFS_STATS2
49966 - atomic_inc(&totSmBufAllocCount);
49967 + atomic_inc_unchecked(&totSmBufAllocCount);
49968 #endif /* CONFIG_CIFS_STATS2 */
49969
49970 }
49971 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
49972 index 47bc5a8..10decbe 100644
49973 --- a/fs/cifs/smb1ops.c
49974 +++ b/fs/cifs/smb1ops.c
49975 @@ -586,27 +586,27 @@ static void
49976 cifs_clear_stats(struct cifs_tcon *tcon)
49977 {
49978 #ifdef CONFIG_CIFS_STATS
49979 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
49980 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
49981 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
49982 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49983 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
49984 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
49985 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49986 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
49987 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
49988 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
49989 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
49990 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
49991 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
49992 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
49993 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
49994 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
49995 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
49996 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
49997 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
49998 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
49999 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
50000 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
50001 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
50002 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
50003 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50004 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
50005 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
50006 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50007 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
50008 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
50009 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
50010 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
50011 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
50012 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
50013 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
50014 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
50015 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
50016 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
50017 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
50018 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
50019 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
50020 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
50021 #endif
50022 }
50023
50024 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50025 {
50026 #ifdef CONFIG_CIFS_STATS
50027 seq_printf(m, " Oplocks breaks: %d",
50028 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
50029 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
50030 seq_printf(m, "\nReads: %d Bytes: %llu",
50031 - atomic_read(&tcon->stats.cifs_stats.num_reads),
50032 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
50033 (long long)(tcon->bytes_read));
50034 seq_printf(m, "\nWrites: %d Bytes: %llu",
50035 - atomic_read(&tcon->stats.cifs_stats.num_writes),
50036 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
50037 (long long)(tcon->bytes_written));
50038 seq_printf(m, "\nFlushes: %d",
50039 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
50040 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
50041 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
50042 - atomic_read(&tcon->stats.cifs_stats.num_locks),
50043 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
50044 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
50045 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
50046 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
50047 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
50048 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
50049 - atomic_read(&tcon->stats.cifs_stats.num_opens),
50050 - atomic_read(&tcon->stats.cifs_stats.num_closes),
50051 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
50052 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
50053 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
50054 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
50055 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
50056 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
50057 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
50058 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
50059 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
50060 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
50061 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
50062 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
50063 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
50064 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
50065 seq_printf(m, "\nRenames: %d T2 Renames %d",
50066 - atomic_read(&tcon->stats.cifs_stats.num_renames),
50067 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
50068 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
50069 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
50070 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
50071 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
50072 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
50073 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
50074 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
50075 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
50076 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
50077 #endif
50078 }
50079
50080 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
50081 index bceffe7..cd1ae59 100644
50082 --- a/fs/cifs/smb2ops.c
50083 +++ b/fs/cifs/smb2ops.c
50084 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
50085 #ifdef CONFIG_CIFS_STATS
50086 int i;
50087 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
50088 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50089 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50090 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50091 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50092 }
50093 #endif
50094 }
50095 @@ -284,66 +284,66 @@ static void
50096 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50097 {
50098 #ifdef CONFIG_CIFS_STATS
50099 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50100 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50101 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50102 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50103 seq_printf(m, "\nNegotiates: %d sent %d failed",
50104 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
50105 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
50106 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
50107 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
50108 seq_printf(m, "\nSessionSetups: %d sent %d failed",
50109 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50110 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50111 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50112 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50113 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50114 seq_printf(m, "\nLogoffs: %d sent %d failed",
50115 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50116 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50117 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50118 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50119 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50120 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50121 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50122 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50123 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50124 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50125 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50126 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50127 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50128 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50129 seq_printf(m, "\nCreates: %d sent %d failed",
50130 - atomic_read(&sent[SMB2_CREATE_HE]),
50131 - atomic_read(&failed[SMB2_CREATE_HE]));
50132 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50133 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50134 seq_printf(m, "\nCloses: %d sent %d failed",
50135 - atomic_read(&sent[SMB2_CLOSE_HE]),
50136 - atomic_read(&failed[SMB2_CLOSE_HE]));
50137 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50138 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50139 seq_printf(m, "\nFlushes: %d sent %d failed",
50140 - atomic_read(&sent[SMB2_FLUSH_HE]),
50141 - atomic_read(&failed[SMB2_FLUSH_HE]));
50142 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50143 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50144 seq_printf(m, "\nReads: %d sent %d failed",
50145 - atomic_read(&sent[SMB2_READ_HE]),
50146 - atomic_read(&failed[SMB2_READ_HE]));
50147 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50148 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50149 seq_printf(m, "\nWrites: %d sent %d failed",
50150 - atomic_read(&sent[SMB2_WRITE_HE]),
50151 - atomic_read(&failed[SMB2_WRITE_HE]));
50152 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50153 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50154 seq_printf(m, "\nLocks: %d sent %d failed",
50155 - atomic_read(&sent[SMB2_LOCK_HE]),
50156 - atomic_read(&failed[SMB2_LOCK_HE]));
50157 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50158 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50159 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50160 - atomic_read(&sent[SMB2_IOCTL_HE]),
50161 - atomic_read(&failed[SMB2_IOCTL_HE]));
50162 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50163 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50164 seq_printf(m, "\nCancels: %d sent %d failed",
50165 - atomic_read(&sent[SMB2_CANCEL_HE]),
50166 - atomic_read(&failed[SMB2_CANCEL_HE]));
50167 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50168 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50169 seq_printf(m, "\nEchos: %d sent %d failed",
50170 - atomic_read(&sent[SMB2_ECHO_HE]),
50171 - atomic_read(&failed[SMB2_ECHO_HE]));
50172 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50173 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50174 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50175 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50176 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50177 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50178 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50179 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50180 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50181 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50182 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50183 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50184 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50185 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50186 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50187 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50188 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50189 seq_printf(m, "\nSetInfos: %d sent %d failed",
50190 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50191 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50192 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50193 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50194 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50195 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50196 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50197 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50198 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50199 #endif
50200 }
50201
50202 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50203 index 41d9d07..dbb4772 100644
50204 --- a/fs/cifs/smb2pdu.c
50205 +++ b/fs/cifs/smb2pdu.c
50206 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50207 default:
50208 cERROR(1, "info level %u isn't supported",
50209 srch_inf->info_level);
50210 - rc = -EINVAL;
50211 - goto qdir_exit;
50212 + return -EINVAL;
50213 }
50214
50215 req->FileIndex = cpu_to_le32(index);
50216 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50217 index 958ae0e..505c9d0 100644
50218 --- a/fs/coda/cache.c
50219 +++ b/fs/coda/cache.c
50220 @@ -24,7 +24,7 @@
50221 #include "coda_linux.h"
50222 #include "coda_cache.h"
50223
50224 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50225 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50226
50227 /* replace or extend an acl cache hit */
50228 void coda_cache_enter(struct inode *inode, int mask)
50229 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50230 struct coda_inode_info *cii = ITOC(inode);
50231
50232 spin_lock(&cii->c_lock);
50233 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50234 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50235 if (cii->c_uid != current_fsuid()) {
50236 cii->c_uid = current_fsuid();
50237 cii->c_cached_perm = mask;
50238 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50239 {
50240 struct coda_inode_info *cii = ITOC(inode);
50241 spin_lock(&cii->c_lock);
50242 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50243 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50244 spin_unlock(&cii->c_lock);
50245 }
50246
50247 /* remove all acl caches */
50248 void coda_cache_clear_all(struct super_block *sb)
50249 {
50250 - atomic_inc(&permission_epoch);
50251 + atomic_inc_unchecked(&permission_epoch);
50252 }
50253
50254
50255 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50256 spin_lock(&cii->c_lock);
50257 hit = (mask & cii->c_cached_perm) == mask &&
50258 cii->c_uid == current_fsuid() &&
50259 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50260 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50261 spin_unlock(&cii->c_lock);
50262
50263 return hit;
50264 diff --git a/fs/compat.c b/fs/compat.c
50265 index a06dcbc..dacb6d3 100644
50266 --- a/fs/compat.c
50267 +++ b/fs/compat.c
50268 @@ -54,7 +54,7 @@
50269 #include <asm/ioctls.h>
50270 #include "internal.h"
50271
50272 -int compat_log = 1;
50273 +int compat_log = 0;
50274
50275 int compat_printk(const char *fmt, ...)
50276 {
50277 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50278
50279 set_fs(KERNEL_DS);
50280 /* The __user pointer cast is valid because of the set_fs() */
50281 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50282 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50283 set_fs(oldfs);
50284 /* truncating is ok because it's a user address */
50285 if (!ret)
50286 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50287 goto out;
50288
50289 ret = -EINVAL;
50290 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50291 + if (nr_segs > UIO_MAXIOV)
50292 goto out;
50293 if (nr_segs > fast_segs) {
50294 ret = -ENOMEM;
50295 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
50296
50297 struct compat_readdir_callback {
50298 struct compat_old_linux_dirent __user *dirent;
50299 + struct file * file;
50300 int result;
50301 };
50302
50303 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50304 buf->result = -EOVERFLOW;
50305 return -EOVERFLOW;
50306 }
50307 +
50308 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50309 + return 0;
50310 +
50311 buf->result++;
50312 dirent = buf->dirent;
50313 if (!access_ok(VERIFY_WRITE, dirent,
50314 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50315
50316 buf.result = 0;
50317 buf.dirent = dirent;
50318 + buf.file = f.file;
50319
50320 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50321 if (buf.result)
50322 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
50323 struct compat_getdents_callback {
50324 struct compat_linux_dirent __user *current_dir;
50325 struct compat_linux_dirent __user *previous;
50326 + struct file * file;
50327 int count;
50328 int error;
50329 };
50330 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50331 buf->error = -EOVERFLOW;
50332 return -EOVERFLOW;
50333 }
50334 +
50335 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50336 + return 0;
50337 +
50338 dirent = buf->previous;
50339 if (dirent) {
50340 if (__put_user(offset, &dirent->d_off))
50341 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50342 buf.previous = NULL;
50343 buf.count = count;
50344 buf.error = 0;
50345 + buf.file = f.file;
50346
50347 error = vfs_readdir(f.file, compat_filldir, &buf);
50348 if (error >= 0)
50349 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50350 struct compat_getdents_callback64 {
50351 struct linux_dirent64 __user *current_dir;
50352 struct linux_dirent64 __user *previous;
50353 + struct file * file;
50354 int count;
50355 int error;
50356 };
50357 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50358 buf->error = -EINVAL; /* only used if we fail.. */
50359 if (reclen > buf->count)
50360 return -EINVAL;
50361 +
50362 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50363 + return 0;
50364 +
50365 dirent = buf->previous;
50366
50367 if (dirent) {
50368 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
50369 buf.previous = NULL;
50370 buf.count = count;
50371 buf.error = 0;
50372 + buf.file = f.file;
50373
50374 error = vfs_readdir(f.file, compat_filldir64, &buf);
50375 if (error >= 0)
50376 error = buf.error;
50377 lastdirent = buf.previous;
50378 if (lastdirent) {
50379 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50380 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50381 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50382 error = -EFAULT;
50383 else
50384 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50385 index a81147e..20bf2b5 100644
50386 --- a/fs/compat_binfmt_elf.c
50387 +++ b/fs/compat_binfmt_elf.c
50388 @@ -30,11 +30,13 @@
50389 #undef elf_phdr
50390 #undef elf_shdr
50391 #undef elf_note
50392 +#undef elf_dyn
50393 #undef elf_addr_t
50394 #define elfhdr elf32_hdr
50395 #define elf_phdr elf32_phdr
50396 #define elf_shdr elf32_shdr
50397 #define elf_note elf32_note
50398 +#define elf_dyn Elf32_Dyn
50399 #define elf_addr_t Elf32_Addr
50400
50401 /*
50402 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50403 index e2f57a0..3c78771 100644
50404 --- a/fs/compat_ioctl.c
50405 +++ b/fs/compat_ioctl.c
50406 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50407 return -EFAULT;
50408 if (__get_user(udata, &ss32->iomem_base))
50409 return -EFAULT;
50410 - ss.iomem_base = compat_ptr(udata);
50411 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50412 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50413 __get_user(ss.port_high, &ss32->port_high))
50414 return -EFAULT;
50415 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
50416 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50417 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50418 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50419 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50420 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50421 return -EFAULT;
50422
50423 return ioctl_preallocate(file, p);
50424 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50425 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50426 {
50427 unsigned int a, b;
50428 - a = *(unsigned int *)p;
50429 - b = *(unsigned int *)q;
50430 + a = *(const unsigned int *)p;
50431 + b = *(const unsigned int *)q;
50432 if (a > b)
50433 return 1;
50434 if (a < b)
50435 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50436 index 712b10f..c33c4ca 100644
50437 --- a/fs/configfs/dir.c
50438 +++ b/fs/configfs/dir.c
50439 @@ -1037,10 +1037,11 @@ static int configfs_dump(struct configfs_dirent *sd, int level)
50440 static int configfs_depend_prep(struct dentry *origin,
50441 struct config_item *target)
50442 {
50443 - struct configfs_dirent *child_sd, *sd = origin->d_fsdata;
50444 + struct configfs_dirent *child_sd, *sd;
50445 int ret = 0;
50446
50447 - BUG_ON(!origin || !sd);
50448 + BUG_ON(!origin || !origin->d_fsdata);
50449 + sd = origin->d_fsdata;
50450
50451 if (sd->s_element == target) /* Boo-yah */
50452 goto out;
50453 @@ -1564,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50454 }
50455 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50456 struct configfs_dirent *next;
50457 - const char * name;
50458 + const unsigned char * name;
50459 + char d_name[sizeof(next->s_dentry->d_iname)];
50460 int len;
50461 struct inode *inode = NULL;
50462
50463 @@ -1574,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50464 continue;
50465
50466 name = configfs_get_name(next);
50467 - len = strlen(name);
50468 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50469 + len = next->s_dentry->d_name.len;
50470 + memcpy(d_name, name, len);
50471 + name = d_name;
50472 + } else
50473 + len = strlen(name);
50474
50475 /*
50476 * We'll have a dentry and an inode for
50477 diff --git a/fs/coredump.c b/fs/coredump.c
50478 index 1774932..5812106 100644
50479 --- a/fs/coredump.c
50480 +++ b/fs/coredump.c
50481 @@ -52,7 +52,7 @@ struct core_name {
50482 char *corename;
50483 int used, size;
50484 };
50485 -static atomic_t call_count = ATOMIC_INIT(1);
50486 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50487
50488 /* The maximal length of core_pattern is also specified in sysctl.c */
50489
50490 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50491 {
50492 char *old_corename = cn->corename;
50493
50494 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50495 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50496 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50497
50498 if (!cn->corename) {
50499 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50500 int pid_in_pattern = 0;
50501 int err = 0;
50502
50503 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50504 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50505 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50506 cn->used = 0;
50507
50508 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
50509 pipe = file->f_path.dentry->d_inode->i_pipe;
50510
50511 pipe_lock(pipe);
50512 - pipe->readers++;
50513 - pipe->writers--;
50514 + atomic_inc(&pipe->readers);
50515 + atomic_dec(&pipe->writers);
50516
50517 - while ((pipe->readers > 1) && (!signal_pending(current))) {
50518 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
50519 wake_up_interruptible_sync(&pipe->wait);
50520 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50521 pipe_wait(pipe);
50522 }
50523
50524 - pipe->readers--;
50525 - pipe->writers++;
50526 + atomic_dec(&pipe->readers);
50527 + atomic_inc(&pipe->writers);
50528 pipe_unlock(pipe);
50529
50530 }
50531 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
50532 int ispipe;
50533 struct files_struct *displaced;
50534 bool need_nonrelative = false;
50535 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50536 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50537 + long signr = siginfo->si_signo;
50538 struct coredump_params cprm = {
50539 .siginfo = siginfo,
50540 .regs = signal_pt_regs(),
50541 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50542 .mm_flags = mm->flags,
50543 };
50544
50545 - audit_core_dumps(siginfo->si_signo);
50546 + audit_core_dumps(signr);
50547 +
50548 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50549 + gr_handle_brute_attach(cprm.mm_flags);
50550
50551 binfmt = mm->binfmt;
50552 if (!binfmt || !binfmt->core_dump)
50553 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50554 need_nonrelative = true;
50555 }
50556
50557 - retval = coredump_wait(siginfo->si_signo, &core_state);
50558 + retval = coredump_wait(signr, &core_state);
50559 if (retval < 0)
50560 goto fail_creds;
50561
50562 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50563 }
50564 cprm.limit = RLIM_INFINITY;
50565
50566 - dump_count = atomic_inc_return(&core_dump_count);
50567 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50568 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50569 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50570 task_tgid_vnr(current), current->comm);
50571 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50572 } else {
50573 struct inode *inode;
50574
50575 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50576 +
50577 if (cprm.limit < binfmt->min_coredump)
50578 goto fail_unlock;
50579
50580 @@ -640,7 +646,7 @@ close_fail:
50581 filp_close(cprm.file, NULL);
50582 fail_dropcount:
50583 if (ispipe)
50584 - atomic_dec(&core_dump_count);
50585 + atomic_dec_unchecked(&core_dump_count);
50586 fail_unlock:
50587 kfree(cn.corename);
50588 fail_corename:
50589 @@ -659,7 +665,7 @@ fail:
50590 */
50591 int dump_write(struct file *file, const void *addr, int nr)
50592 {
50593 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50594 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50595 }
50596 EXPORT_SYMBOL(dump_write);
50597
50598 diff --git a/fs/dcache.c b/fs/dcache.c
50599 index c3bbf85..5b71101 100644
50600 --- a/fs/dcache.c
50601 +++ b/fs/dcache.c
50602 @@ -3139,7 +3139,7 @@ void __init vfs_caches_init(unsigned long mempages)
50603 mempages -= reserve;
50604
50605 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50606 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50607 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50608
50609 dcache_init();
50610 inode_init();
50611 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50612 index a5f12b7..4ee8a6f 100644
50613 --- a/fs/debugfs/inode.c
50614 +++ b/fs/debugfs/inode.c
50615 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50616 */
50617 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50618 {
50619 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50620 + return __create_file(name, S_IFDIR | S_IRWXU,
50621 +#else
50622 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50623 +#endif
50624 parent, NULL, NULL);
50625 }
50626 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50627 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50628 index cc7709e..7e7211f 100644
50629 --- a/fs/ecryptfs/inode.c
50630 +++ b/fs/ecryptfs/inode.c
50631 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50632 old_fs = get_fs();
50633 set_fs(get_ds());
50634 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50635 - (char __user *)lower_buf,
50636 + (char __force_user *)lower_buf,
50637 PATH_MAX);
50638 set_fs(old_fs);
50639 if (rc < 0)
50640 @@ -706,7 +706,7 @@ out:
50641 static void
50642 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50643 {
50644 - char *buf = nd_get_link(nd);
50645 + const char *buf = nd_get_link(nd);
50646 if (!IS_ERR(buf)) {
50647 /* Free the char* */
50648 kfree(buf);
50649 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50650 index 412e6ed..d8263e8 100644
50651 --- a/fs/ecryptfs/miscdev.c
50652 +++ b/fs/ecryptfs/miscdev.c
50653 @@ -80,13 +80,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50654 int rc;
50655
50656 mutex_lock(&ecryptfs_daemon_hash_mux);
50657 - rc = try_module_get(THIS_MODULE);
50658 - if (rc == 0) {
50659 - rc = -EIO;
50660 - printk(KERN_ERR "%s: Error attempting to increment module use "
50661 - "count; rc = [%d]\n", __func__, rc);
50662 - goto out_unlock_daemon_list;
50663 - }
50664 rc = ecryptfs_find_daemon_by_euid(&daemon);
50665 if (!rc) {
50666 rc = -EINVAL;
50667 @@ -96,7 +89,7 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50668 if (rc) {
50669 printk(KERN_ERR "%s: Error attempting to spawn daemon; "
50670 "rc = [%d]\n", __func__, rc);
50671 - goto out_module_put_unlock_daemon_list;
50672 + goto out_unlock_daemon_list;
50673 }
50674 mutex_lock(&daemon->mux);
50675 if (daemon->flags & ECRYPTFS_DAEMON_MISCDEV_OPEN) {
50676 @@ -108,9 +101,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50677 atomic_inc(&ecryptfs_num_miscdev_opens);
50678 out_unlock_daemon:
50679 mutex_unlock(&daemon->mux);
50680 -out_module_put_unlock_daemon_list:
50681 - if (rc)
50682 - module_put(THIS_MODULE);
50683 out_unlock_daemon_list:
50684 mutex_unlock(&ecryptfs_daemon_hash_mux);
50685 return rc;
50686 @@ -147,7 +137,6 @@ ecryptfs_miscdev_release(struct inode *inode, struct file *file)
50687 "bug.\n", __func__, rc);
50688 BUG();
50689 }
50690 - module_put(THIS_MODULE);
50691 return rc;
50692 }
50693
50694 @@ -315,7 +304,7 @@ check_list:
50695 goto out_unlock_msg_ctx;
50696 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50697 if (msg_ctx->msg) {
50698 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50699 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50700 goto out_unlock_msg_ctx;
50701 i += packet_length_size;
50702 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50703 @@ -471,6 +460,7 @@ out_free:
50704
50705
50706 static const struct file_operations ecryptfs_miscdev_fops = {
50707 + .owner = THIS_MODULE,
50708 .open = ecryptfs_miscdev_open,
50709 .poll = ecryptfs_miscdev_poll,
50710 .read = ecryptfs_miscdev_read,
50711 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50712 index b2a34a1..162fa69 100644
50713 --- a/fs/ecryptfs/read_write.c
50714 +++ b/fs/ecryptfs/read_write.c
50715 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
50716 return -EIO;
50717 fs_save = get_fs();
50718 set_fs(get_ds());
50719 - rc = vfs_write(lower_file, data, size, &offset);
50720 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
50721 set_fs(fs_save);
50722 mark_inode_dirty_sync(ecryptfs_inode);
50723 return rc;
50724 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50725 return -EIO;
50726 fs_save = get_fs();
50727 set_fs(get_ds());
50728 - rc = vfs_read(lower_file, data, size, &offset);
50729 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50730 set_fs(fs_save);
50731 return rc;
50732 }
50733 diff --git a/fs/exec.c b/fs/exec.c
50734 index 20df02c..1b1d946 100644
50735 --- a/fs/exec.c
50736 +++ b/fs/exec.c
50737 @@ -55,6 +55,17 @@
50738 #include <linux/pipe_fs_i.h>
50739 #include <linux/oom.h>
50740 #include <linux/compat.h>
50741 +#include <linux/random.h>
50742 +#include <linux/seq_file.h>
50743 +#include <linux/coredump.h>
50744 +#include <linux/mman.h>
50745 +
50746 +#ifdef CONFIG_PAX_REFCOUNT
50747 +#include <linux/kallsyms.h>
50748 +#include <linux/kdebug.h>
50749 +#endif
50750 +
50751 +#include <trace/events/fs.h>
50752
50753 #include <asm/uaccess.h>
50754 #include <asm/mmu_context.h>
50755 @@ -66,6 +77,18 @@
50756
50757 #include <trace/events/sched.h>
50758
50759 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50760 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50761 +{
50762 + 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");
50763 +}
50764 +#endif
50765 +
50766 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50767 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50768 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50769 +#endif
50770 +
50771 int suid_dumpable = 0;
50772
50773 static LIST_HEAD(formats);
50774 @@ -75,8 +98,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50775 {
50776 BUG_ON(!fmt);
50777 write_lock(&binfmt_lock);
50778 - insert ? list_add(&fmt->lh, &formats) :
50779 - list_add_tail(&fmt->lh, &formats);
50780 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50781 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50782 write_unlock(&binfmt_lock);
50783 }
50784
50785 @@ -85,7 +108,7 @@ EXPORT_SYMBOL(__register_binfmt);
50786 void unregister_binfmt(struct linux_binfmt * fmt)
50787 {
50788 write_lock(&binfmt_lock);
50789 - list_del(&fmt->lh);
50790 + pax_list_del((struct list_head *)&fmt->lh);
50791 write_unlock(&binfmt_lock);
50792 }
50793
50794 @@ -180,18 +203,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50795 int write)
50796 {
50797 struct page *page;
50798 - int ret;
50799
50800 -#ifdef CONFIG_STACK_GROWSUP
50801 - if (write) {
50802 - ret = expand_downwards(bprm->vma, pos);
50803 - if (ret < 0)
50804 - return NULL;
50805 - }
50806 -#endif
50807 - ret = get_user_pages(current, bprm->mm, pos,
50808 - 1, write, 1, &page, NULL);
50809 - if (ret <= 0)
50810 + if (0 > expand_downwards(bprm->vma, pos))
50811 + return NULL;
50812 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50813 return NULL;
50814
50815 if (write) {
50816 @@ -207,6 +222,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50817 if (size <= ARG_MAX)
50818 return page;
50819
50820 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50821 + // only allow 512KB for argv+env on suid/sgid binaries
50822 + // to prevent easy ASLR exhaustion
50823 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50824 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50825 + (size > (512 * 1024))) {
50826 + put_page(page);
50827 + return NULL;
50828 + }
50829 +#endif
50830 +
50831 /*
50832 * Limit to 1/4-th the stack size for the argv+env strings.
50833 * This ensures that:
50834 @@ -266,6 +292,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50835 vma->vm_end = STACK_TOP_MAX;
50836 vma->vm_start = vma->vm_end - PAGE_SIZE;
50837 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50838 +
50839 +#ifdef CONFIG_PAX_SEGMEXEC
50840 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50841 +#endif
50842 +
50843 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50844 INIT_LIST_HEAD(&vma->anon_vma_chain);
50845
50846 @@ -276,6 +307,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50847 mm->stack_vm = mm->total_vm = 1;
50848 up_write(&mm->mmap_sem);
50849 bprm->p = vma->vm_end - sizeof(void *);
50850 +
50851 +#ifdef CONFIG_PAX_RANDUSTACK
50852 + if (randomize_va_space)
50853 + bprm->p ^= random32() & ~PAGE_MASK;
50854 +#endif
50855 +
50856 return 0;
50857 err:
50858 up_write(&mm->mmap_sem);
50859 @@ -396,7 +433,7 @@ struct user_arg_ptr {
50860 } ptr;
50861 };
50862
50863 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50864 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50865 {
50866 const char __user *native;
50867
50868 @@ -405,14 +442,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50869 compat_uptr_t compat;
50870
50871 if (get_user(compat, argv.ptr.compat + nr))
50872 - return ERR_PTR(-EFAULT);
50873 + return (const char __force_user *)ERR_PTR(-EFAULT);
50874
50875 return compat_ptr(compat);
50876 }
50877 #endif
50878
50879 if (get_user(native, argv.ptr.native + nr))
50880 - return ERR_PTR(-EFAULT);
50881 + return (const char __force_user *)ERR_PTR(-EFAULT);
50882
50883 return native;
50884 }
50885 @@ -431,7 +468,7 @@ static int count(struct user_arg_ptr argv, int max)
50886 if (!p)
50887 break;
50888
50889 - if (IS_ERR(p))
50890 + if (IS_ERR((const char __force_kernel *)p))
50891 return -EFAULT;
50892
50893 if (i >= max)
50894 @@ -466,7 +503,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50895
50896 ret = -EFAULT;
50897 str = get_user_arg_ptr(argv, argc);
50898 - if (IS_ERR(str))
50899 + if (IS_ERR((const char __force_kernel *)str))
50900 goto out;
50901
50902 len = strnlen_user(str, MAX_ARG_STRLEN);
50903 @@ -548,7 +585,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50904 int r;
50905 mm_segment_t oldfs = get_fs();
50906 struct user_arg_ptr argv = {
50907 - .ptr.native = (const char __user *const __user *)__argv,
50908 + .ptr.native = (const char __force_user *const __force_user *)__argv,
50909 };
50910
50911 set_fs(KERNEL_DS);
50912 @@ -583,7 +620,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50913 unsigned long new_end = old_end - shift;
50914 struct mmu_gather tlb;
50915
50916 - BUG_ON(new_start > new_end);
50917 + if (new_start >= new_end || new_start < mmap_min_addr)
50918 + return -ENOMEM;
50919
50920 /*
50921 * ensure there are no vmas between where we want to go
50922 @@ -592,6 +630,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50923 if (vma != find_vma(mm, new_start))
50924 return -EFAULT;
50925
50926 +#ifdef CONFIG_PAX_SEGMEXEC
50927 + BUG_ON(pax_find_mirror_vma(vma));
50928 +#endif
50929 +
50930 /*
50931 * cover the whole range: [new_start, old_end)
50932 */
50933 @@ -672,10 +714,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50934 stack_top = arch_align_stack(stack_top);
50935 stack_top = PAGE_ALIGN(stack_top);
50936
50937 - if (unlikely(stack_top < mmap_min_addr) ||
50938 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50939 - return -ENOMEM;
50940 -
50941 stack_shift = vma->vm_end - stack_top;
50942
50943 bprm->p -= stack_shift;
50944 @@ -687,8 +725,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50945 bprm->exec -= stack_shift;
50946
50947 down_write(&mm->mmap_sem);
50948 +
50949 + /* Move stack pages down in memory. */
50950 + if (stack_shift) {
50951 + ret = shift_arg_pages(vma, stack_shift);
50952 + if (ret)
50953 + goto out_unlock;
50954 + }
50955 +
50956 vm_flags = VM_STACK_FLAGS;
50957
50958 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50959 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50960 + vm_flags &= ~VM_EXEC;
50961 +
50962 +#ifdef CONFIG_PAX_MPROTECT
50963 + if (mm->pax_flags & MF_PAX_MPROTECT)
50964 + vm_flags &= ~VM_MAYEXEC;
50965 +#endif
50966 +
50967 + }
50968 +#endif
50969 +
50970 /*
50971 * Adjust stack execute permissions; explicitly enable for
50972 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50973 @@ -707,13 +765,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50974 goto out_unlock;
50975 BUG_ON(prev != vma);
50976
50977 - /* Move stack pages down in memory. */
50978 - if (stack_shift) {
50979 - ret = shift_arg_pages(vma, stack_shift);
50980 - if (ret)
50981 - goto out_unlock;
50982 - }
50983 -
50984 /* mprotect_fixup is overkill to remove the temporary stack flags */
50985 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50986
50987 @@ -737,6 +788,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50988 #endif
50989 current->mm->start_stack = bprm->p;
50990 ret = expand_stack(vma, stack_base);
50991 +
50992 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50993 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50994 + unsigned long size, flags, vm_flags;
50995 +
50996 + size = STACK_TOP - vma->vm_end;
50997 + flags = MAP_FIXED | MAP_PRIVATE;
50998 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50999 +
51000 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, flags, vm_flags, 0);
51001 +
51002 +#ifdef CONFIG_X86
51003 + if (!ret) {
51004 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
51005 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), flags, vm_flags, 0);
51006 + }
51007 +#endif
51008 +
51009 + }
51010 +#endif
51011 +
51012 if (ret)
51013 ret = -EFAULT;
51014
51015 @@ -772,6 +844,8 @@ struct file *open_exec(const char *name)
51016
51017 fsnotify_open(file);
51018
51019 + trace_open_exec(name);
51020 +
51021 err = deny_write_access(file);
51022 if (err)
51023 goto exit;
51024 @@ -795,7 +869,7 @@ int kernel_read(struct file *file, loff_t offset,
51025 old_fs = get_fs();
51026 set_fs(get_ds());
51027 /* The cast to a user pointer is valid due to the set_fs() */
51028 - result = vfs_read(file, (void __user *)addr, count, &pos);
51029 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
51030 set_fs(old_fs);
51031 return result;
51032 }
51033 @@ -1247,7 +1321,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
51034 }
51035 rcu_read_unlock();
51036
51037 - if (p->fs->users > n_fs) {
51038 + if (atomic_read(&p->fs->users) > n_fs) {
51039 bprm->unsafe |= LSM_UNSAFE_SHARE;
51040 } else {
51041 res = -EAGAIN;
51042 @@ -1447,6 +1521,31 @@ int search_binary_handler(struct linux_binprm *bprm)
51043
51044 EXPORT_SYMBOL(search_binary_handler);
51045
51046 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51047 +static DEFINE_PER_CPU(u64, exec_counter);
51048 +static int __init init_exec_counters(void)
51049 +{
51050 + unsigned int cpu;
51051 +
51052 + for_each_possible_cpu(cpu) {
51053 + per_cpu(exec_counter, cpu) = (u64)cpu;
51054 + }
51055 +
51056 + return 0;
51057 +}
51058 +early_initcall(init_exec_counters);
51059 +static inline void increment_exec_counter(void)
51060 +{
51061 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
51062 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
51063 +}
51064 +#else
51065 +static inline void increment_exec_counter(void) {}
51066 +#endif
51067 +
51068 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
51069 + struct user_arg_ptr argv);
51070 +
51071 /*
51072 * sys_execve() executes a new program.
51073 */
51074 @@ -1454,6 +1553,11 @@ static int do_execve_common(const char *filename,
51075 struct user_arg_ptr argv,
51076 struct user_arg_ptr envp)
51077 {
51078 +#ifdef CONFIG_GRKERNSEC
51079 + struct file *old_exec_file;
51080 + struct acl_subject_label *old_acl;
51081 + struct rlimit old_rlim[RLIM_NLIMITS];
51082 +#endif
51083 struct linux_binprm *bprm;
51084 struct file *file;
51085 struct files_struct *displaced;
51086 @@ -1461,6 +1565,8 @@ static int do_execve_common(const char *filename,
51087 int retval;
51088 const struct cred *cred = current_cred();
51089
51090 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
51091 +
51092 /*
51093 * We move the actual failure in case of RLIMIT_NPROC excess from
51094 * set*uid() to execve() because too many poorly written programs
51095 @@ -1501,12 +1607,27 @@ static int do_execve_common(const char *filename,
51096 if (IS_ERR(file))
51097 goto out_unmark;
51098
51099 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
51100 + retval = -EPERM;
51101 + goto out_file;
51102 + }
51103 +
51104 sched_exec();
51105
51106 bprm->file = file;
51107 bprm->filename = filename;
51108 bprm->interp = filename;
51109
51110 + if (gr_process_user_ban()) {
51111 + retval = -EPERM;
51112 + goto out_file;
51113 + }
51114 +
51115 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
51116 + retval = -EACCES;
51117 + goto out_file;
51118 + }
51119 +
51120 retval = bprm_mm_init(bprm);
51121 if (retval)
51122 goto out_file;
51123 @@ -1523,24 +1644,65 @@ static int do_execve_common(const char *filename,
51124 if (retval < 0)
51125 goto out;
51126
51127 +#ifdef CONFIG_GRKERNSEC
51128 + old_acl = current->acl;
51129 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
51130 + old_exec_file = current->exec_file;
51131 + get_file(file);
51132 + current->exec_file = file;
51133 +#endif
51134 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51135 + /* limit suid stack to 8MB
51136 + * we saved the old limits above and will restore them if this exec fails
51137 + */
51138 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
51139 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
51140 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
51141 +#endif
51142 +
51143 + if (!gr_tpe_allow(file)) {
51144 + retval = -EACCES;
51145 + goto out_fail;
51146 + }
51147 +
51148 + if (gr_check_crash_exec(file)) {
51149 + retval = -EACCES;
51150 + goto out_fail;
51151 + }
51152 +
51153 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
51154 + bprm->unsafe);
51155 + if (retval < 0)
51156 + goto out_fail;
51157 +
51158 retval = copy_strings_kernel(1, &bprm->filename, bprm);
51159 if (retval < 0)
51160 - goto out;
51161 + goto out_fail;
51162
51163 bprm->exec = bprm->p;
51164 retval = copy_strings(bprm->envc, envp, bprm);
51165 if (retval < 0)
51166 - goto out;
51167 + goto out_fail;
51168
51169 retval = copy_strings(bprm->argc, argv, bprm);
51170 if (retval < 0)
51171 - goto out;
51172 + goto out_fail;
51173 +
51174 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
51175 +
51176 + gr_handle_exec_args(bprm, argv);
51177
51178 retval = search_binary_handler(bprm);
51179 if (retval < 0)
51180 - goto out;
51181 + goto out_fail;
51182 +#ifdef CONFIG_GRKERNSEC
51183 + if (old_exec_file)
51184 + fput(old_exec_file);
51185 +#endif
51186
51187 /* execve succeeded */
51188 +
51189 + increment_exec_counter();
51190 current->fs->in_exec = 0;
51191 current->in_execve = 0;
51192 acct_update_integrals(current);
51193 @@ -1549,6 +1711,14 @@ static int do_execve_common(const char *filename,
51194 put_files_struct(displaced);
51195 return retval;
51196
51197 +out_fail:
51198 +#ifdef CONFIG_GRKERNSEC
51199 + current->acl = old_acl;
51200 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51201 + fput(current->exec_file);
51202 + current->exec_file = old_exec_file;
51203 +#endif
51204 +
51205 out:
51206 if (bprm->mm) {
51207 acct_arg_size(bprm, 0);
51208 @@ -1697,3 +1867,253 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51209 return error;
51210 }
51211 #endif
51212 +
51213 +int pax_check_flags(unsigned long *flags)
51214 +{
51215 + int retval = 0;
51216 +
51217 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51218 + if (*flags & MF_PAX_SEGMEXEC)
51219 + {
51220 + *flags &= ~MF_PAX_SEGMEXEC;
51221 + retval = -EINVAL;
51222 + }
51223 +#endif
51224 +
51225 + if ((*flags & MF_PAX_PAGEEXEC)
51226 +
51227 +#ifdef CONFIG_PAX_PAGEEXEC
51228 + && (*flags & MF_PAX_SEGMEXEC)
51229 +#endif
51230 +
51231 + )
51232 + {
51233 + *flags &= ~MF_PAX_PAGEEXEC;
51234 + retval = -EINVAL;
51235 + }
51236 +
51237 + if ((*flags & MF_PAX_MPROTECT)
51238 +
51239 +#ifdef CONFIG_PAX_MPROTECT
51240 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51241 +#endif
51242 +
51243 + )
51244 + {
51245 + *flags &= ~MF_PAX_MPROTECT;
51246 + retval = -EINVAL;
51247 + }
51248 +
51249 + if ((*flags & MF_PAX_EMUTRAMP)
51250 +
51251 +#ifdef CONFIG_PAX_EMUTRAMP
51252 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51253 +#endif
51254 +
51255 + )
51256 + {
51257 + *flags &= ~MF_PAX_EMUTRAMP;
51258 + retval = -EINVAL;
51259 + }
51260 +
51261 + return retval;
51262 +}
51263 +
51264 +EXPORT_SYMBOL(pax_check_flags);
51265 +
51266 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51267 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51268 +{
51269 + struct task_struct *tsk = current;
51270 + struct mm_struct *mm = current->mm;
51271 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51272 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51273 + char *path_exec = NULL;
51274 + char *path_fault = NULL;
51275 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51276 + siginfo_t info = { };
51277 +
51278 + if (buffer_exec && buffer_fault) {
51279 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51280 +
51281 + down_read(&mm->mmap_sem);
51282 + vma = mm->mmap;
51283 + while (vma && (!vma_exec || !vma_fault)) {
51284 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51285 + vma_exec = vma;
51286 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51287 + vma_fault = vma;
51288 + vma = vma->vm_next;
51289 + }
51290 + if (vma_exec) {
51291 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51292 + if (IS_ERR(path_exec))
51293 + path_exec = "<path too long>";
51294 + else {
51295 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
51296 + if (path_exec) {
51297 + *path_exec = 0;
51298 + path_exec = buffer_exec;
51299 + } else
51300 + path_exec = "<path too long>";
51301 + }
51302 + }
51303 + if (vma_fault) {
51304 + start = vma_fault->vm_start;
51305 + end = vma_fault->vm_end;
51306 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51307 + if (vma_fault->vm_file) {
51308 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51309 + if (IS_ERR(path_fault))
51310 + path_fault = "<path too long>";
51311 + else {
51312 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
51313 + if (path_fault) {
51314 + *path_fault = 0;
51315 + path_fault = buffer_fault;
51316 + } else
51317 + path_fault = "<path too long>";
51318 + }
51319 + } else
51320 + path_fault = "<anonymous mapping>";
51321 + }
51322 + up_read(&mm->mmap_sem);
51323 + }
51324 + if (tsk->signal->curr_ip)
51325 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51326 + else
51327 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51328 + 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),
51329 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51330 + free_page((unsigned long)buffer_exec);
51331 + free_page((unsigned long)buffer_fault);
51332 + pax_report_insns(regs, pc, sp);
51333 + info.si_signo = SIGKILL;
51334 + info.si_errno = 0;
51335 + info.si_code = SI_KERNEL;
51336 + info.si_pid = 0;
51337 + info.si_uid = 0;
51338 + do_coredump(&info);
51339 +}
51340 +#endif
51341 +
51342 +#ifdef CONFIG_PAX_REFCOUNT
51343 +void pax_report_refcount_overflow(struct pt_regs *regs)
51344 +{
51345 + if (current->signal->curr_ip)
51346 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51347 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51348 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51349 + else
51350 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51351 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51352 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51353 + show_regs(regs);
51354 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51355 +}
51356 +#endif
51357 +
51358 +#ifdef CONFIG_PAX_USERCOPY
51359 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51360 +static noinline int check_stack_object(const void *obj, unsigned long len)
51361 +{
51362 + const void * const stack = task_stack_page(current);
51363 + const void * const stackend = stack + THREAD_SIZE;
51364 +
51365 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51366 + const void *frame = NULL;
51367 + const void *oldframe;
51368 +#endif
51369 +
51370 + if (obj + len < obj)
51371 + return -1;
51372 +
51373 + if (obj + len <= stack || stackend <= obj)
51374 + return 0;
51375 +
51376 + if (obj < stack || stackend < obj + len)
51377 + return -1;
51378 +
51379 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51380 + oldframe = __builtin_frame_address(1);
51381 + if (oldframe)
51382 + frame = __builtin_frame_address(2);
51383 + /*
51384 + low ----------------------------------------------> high
51385 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51386 + ^----------------^
51387 + allow copies only within here
51388 + */
51389 + while (stack <= frame && frame < stackend) {
51390 + /* if obj + len extends past the last frame, this
51391 + check won't pass and the next frame will be 0,
51392 + causing us to bail out and correctly report
51393 + the copy as invalid
51394 + */
51395 + if (obj + len <= frame)
51396 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51397 + oldframe = frame;
51398 + frame = *(const void * const *)frame;
51399 + }
51400 + return -1;
51401 +#else
51402 + return 1;
51403 +#endif
51404 +}
51405 +
51406 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51407 +{
51408 + if (current->signal->curr_ip)
51409 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51410 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51411 + else
51412 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51413 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51414 + dump_stack();
51415 + gr_handle_kernel_exploit();
51416 + do_group_exit(SIGKILL);
51417 +}
51418 +#endif
51419 +
51420 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51421 +{
51422 +
51423 +#ifdef CONFIG_PAX_USERCOPY
51424 + const char *type;
51425 +
51426 + if (!n)
51427 + return;
51428 +
51429 + type = check_heap_object(ptr, n);
51430 + if (!type) {
51431 + if (check_stack_object(ptr, n) != -1)
51432 + return;
51433 + type = "<process stack>";
51434 + }
51435 +
51436 + pax_report_usercopy(ptr, n, to_user, type);
51437 +#endif
51438 +
51439 +}
51440 +EXPORT_SYMBOL(__check_object_size);
51441 +
51442 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51443 +void pax_track_stack(void)
51444 +{
51445 + unsigned long sp = (unsigned long)&sp;
51446 + if (sp < current_thread_info()->lowest_stack &&
51447 + sp > (unsigned long)task_stack_page(current))
51448 + current_thread_info()->lowest_stack = sp;
51449 +}
51450 +EXPORT_SYMBOL(pax_track_stack);
51451 +#endif
51452 +
51453 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51454 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51455 +{
51456 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51457 + dump_stack();
51458 + do_group_exit(SIGKILL);
51459 +}
51460 +EXPORT_SYMBOL(report_size_overflow);
51461 +#endif
51462 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51463 index 2616d0e..2ffdec9 100644
51464 --- a/fs/ext2/balloc.c
51465 +++ b/fs/ext2/balloc.c
51466 @@ -1190,10 +1190,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51467
51468 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51469 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51470 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51471 + if (free_blocks < root_blocks + 1 &&
51472 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51473 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51474 - !in_group_p (sbi->s_resgid))) {
51475 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51476 return 0;
51477 }
51478 return 1;
51479 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51480 index 22548f5..41521d8 100644
51481 --- a/fs/ext3/balloc.c
51482 +++ b/fs/ext3/balloc.c
51483 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51484
51485 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51486 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51487 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51488 + if (free_blocks < root_blocks + 1 &&
51489 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51490 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51491 - !in_group_p (sbi->s_resgid))) {
51492 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51493 return 0;
51494 }
51495 return 1;
51496 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51497 index 92e68b3..115d987 100644
51498 --- a/fs/ext4/balloc.c
51499 +++ b/fs/ext4/balloc.c
51500 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51501 /* Hm, nope. Are (enough) root reserved clusters available? */
51502 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51503 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51504 - capable(CAP_SYS_RESOURCE) ||
51505 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51506 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51507 + capable_nolog(CAP_SYS_RESOURCE)) {
51508
51509 if (free_clusters >= (nclusters + dirty_clusters))
51510 return 1;
51511 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51512 index bbcd6a0..2824592 100644
51513 --- a/fs/ext4/ext4.h
51514 +++ b/fs/ext4/ext4.h
51515 @@ -1265,19 +1265,19 @@ struct ext4_sb_info {
51516 unsigned long s_mb_last_start;
51517
51518 /* stats for buddy allocator */
51519 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51520 - atomic_t s_bal_success; /* we found long enough chunks */
51521 - atomic_t s_bal_allocated; /* in blocks */
51522 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51523 - atomic_t s_bal_goals; /* goal hits */
51524 - atomic_t s_bal_breaks; /* too long searches */
51525 - atomic_t s_bal_2orders; /* 2^order hits */
51526 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51527 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51528 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51529 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51530 + atomic_unchecked_t s_bal_goals; /* goal hits */
51531 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51532 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51533 spinlock_t s_bal_lock;
51534 unsigned long s_mb_buddies_generated;
51535 unsigned long long s_mb_generation_time;
51536 - atomic_t s_mb_lost_chunks;
51537 - atomic_t s_mb_preallocated;
51538 - atomic_t s_mb_discarded;
51539 + atomic_unchecked_t s_mb_lost_chunks;
51540 + atomic_unchecked_t s_mb_preallocated;
51541 + atomic_unchecked_t s_mb_discarded;
51542 atomic_t s_lock_busy;
51543
51544 /* locality groups */
51545 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51546 index 82f8c2d..ce7c889 100644
51547 --- a/fs/ext4/mballoc.c
51548 +++ b/fs/ext4/mballoc.c
51549 @@ -1747,7 +1747,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51550 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51551
51552 if (EXT4_SB(sb)->s_mb_stats)
51553 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51554 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51555
51556 break;
51557 }
51558 @@ -2044,7 +2044,7 @@ repeat:
51559 ac->ac_status = AC_STATUS_CONTINUE;
51560 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51561 cr = 3;
51562 - atomic_inc(&sbi->s_mb_lost_chunks);
51563 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51564 goto repeat;
51565 }
51566 }
51567 @@ -2552,25 +2552,25 @@ int ext4_mb_release(struct super_block *sb)
51568 if (sbi->s_mb_stats) {
51569 ext4_msg(sb, KERN_INFO,
51570 "mballoc: %u blocks %u reqs (%u success)",
51571 - atomic_read(&sbi->s_bal_allocated),
51572 - atomic_read(&sbi->s_bal_reqs),
51573 - atomic_read(&sbi->s_bal_success));
51574 + atomic_read_unchecked(&sbi->s_bal_allocated),
51575 + atomic_read_unchecked(&sbi->s_bal_reqs),
51576 + atomic_read_unchecked(&sbi->s_bal_success));
51577 ext4_msg(sb, KERN_INFO,
51578 "mballoc: %u extents scanned, %u goal hits, "
51579 "%u 2^N hits, %u breaks, %u lost",
51580 - atomic_read(&sbi->s_bal_ex_scanned),
51581 - atomic_read(&sbi->s_bal_goals),
51582 - atomic_read(&sbi->s_bal_2orders),
51583 - atomic_read(&sbi->s_bal_breaks),
51584 - atomic_read(&sbi->s_mb_lost_chunks));
51585 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51586 + atomic_read_unchecked(&sbi->s_bal_goals),
51587 + atomic_read_unchecked(&sbi->s_bal_2orders),
51588 + atomic_read_unchecked(&sbi->s_bal_breaks),
51589 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51590 ext4_msg(sb, KERN_INFO,
51591 "mballoc: %lu generated and it took %Lu",
51592 sbi->s_mb_buddies_generated,
51593 sbi->s_mb_generation_time);
51594 ext4_msg(sb, KERN_INFO,
51595 "mballoc: %u preallocated, %u discarded",
51596 - atomic_read(&sbi->s_mb_preallocated),
51597 - atomic_read(&sbi->s_mb_discarded));
51598 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51599 + atomic_read_unchecked(&sbi->s_mb_discarded));
51600 }
51601
51602 free_percpu(sbi->s_locality_groups);
51603 @@ -3060,16 +3060,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51604 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51605
51606 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51607 - atomic_inc(&sbi->s_bal_reqs);
51608 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51609 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51610 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51611 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51612 - atomic_inc(&sbi->s_bal_success);
51613 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51614 + atomic_inc_unchecked(&sbi->s_bal_success);
51615 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51616 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51617 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51618 - atomic_inc(&sbi->s_bal_goals);
51619 + atomic_inc_unchecked(&sbi->s_bal_goals);
51620 if (ac->ac_found > sbi->s_mb_max_to_scan)
51621 - atomic_inc(&sbi->s_bal_breaks);
51622 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51623 }
51624
51625 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51626 @@ -3469,7 +3469,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51627 trace_ext4_mb_new_inode_pa(ac, pa);
51628
51629 ext4_mb_use_inode_pa(ac, pa);
51630 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51631 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51632
51633 ei = EXT4_I(ac->ac_inode);
51634 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51635 @@ -3529,7 +3529,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51636 trace_ext4_mb_new_group_pa(ac, pa);
51637
51638 ext4_mb_use_group_pa(ac, pa);
51639 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51640 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51641
51642 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51643 lg = ac->ac_lg;
51644 @@ -3618,7 +3618,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51645 * from the bitmap and continue.
51646 */
51647 }
51648 - atomic_add(free, &sbi->s_mb_discarded);
51649 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51650
51651 return err;
51652 }
51653 @@ -3636,7 +3636,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51654 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51655 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51656 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51657 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51658 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51659 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51660
51661 return 0;
51662 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51663 index 24c767d..893aa55 100644
51664 --- a/fs/ext4/super.c
51665 +++ b/fs/ext4/super.c
51666 @@ -2429,7 +2429,7 @@ struct ext4_attr {
51667 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51668 const char *, size_t);
51669 int offset;
51670 -};
51671 +} __do_const;
51672
51673 static int parse_strtoul(const char *buf,
51674 unsigned long max, unsigned long *value)
51675 diff --git a/fs/fcntl.c b/fs/fcntl.c
51676 index 71a600a..20d87b1 100644
51677 --- a/fs/fcntl.c
51678 +++ b/fs/fcntl.c
51679 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51680 if (err)
51681 return err;
51682
51683 + if (gr_handle_chroot_fowner(pid, type))
51684 + return -ENOENT;
51685 + if (gr_check_protected_task_fowner(pid, type))
51686 + return -EACCES;
51687 +
51688 f_modown(filp, pid, type, force);
51689 return 0;
51690 }
51691 diff --git a/fs/fhandle.c b/fs/fhandle.c
51692 index 999ff5c..41f4109 100644
51693 --- a/fs/fhandle.c
51694 +++ b/fs/fhandle.c
51695 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51696 } else
51697 retval = 0;
51698 /* copy the mount id */
51699 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51700 - sizeof(*mnt_id)) ||
51701 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51702 copy_to_user(ufh, handle,
51703 sizeof(struct file_handle) + handle_bytes))
51704 retval = -EFAULT;
51705 diff --git a/fs/fifo.c b/fs/fifo.c
51706 index cf6f434..3d7942c 100644
51707 --- a/fs/fifo.c
51708 +++ b/fs/fifo.c
51709 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51710 */
51711 filp->f_op = &read_pipefifo_fops;
51712 pipe->r_counter++;
51713 - if (pipe->readers++ == 0)
51714 + if (atomic_inc_return(&pipe->readers) == 1)
51715 wake_up_partner(inode);
51716
51717 - if (!pipe->writers) {
51718 + if (!atomic_read(&pipe->writers)) {
51719 if ((filp->f_flags & O_NONBLOCK)) {
51720 /* suppress POLLHUP until we have
51721 * seen a writer */
51722 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51723 * errno=ENXIO when there is no process reading the FIFO.
51724 */
51725 ret = -ENXIO;
51726 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51727 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51728 goto err;
51729
51730 filp->f_op = &write_pipefifo_fops;
51731 pipe->w_counter++;
51732 - if (!pipe->writers++)
51733 + if (atomic_inc_return(&pipe->writers) == 1)
51734 wake_up_partner(inode);
51735
51736 - if (!pipe->readers) {
51737 + if (!atomic_read(&pipe->readers)) {
51738 if (wait_for_partner(inode, &pipe->r_counter))
51739 goto err_wr;
51740 }
51741 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51742 */
51743 filp->f_op = &rdwr_pipefifo_fops;
51744
51745 - pipe->readers++;
51746 - pipe->writers++;
51747 + atomic_inc(&pipe->readers);
51748 + atomic_inc(&pipe->writers);
51749 pipe->r_counter++;
51750 pipe->w_counter++;
51751 - if (pipe->readers == 1 || pipe->writers == 1)
51752 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51753 wake_up_partner(inode);
51754 break;
51755
51756 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51757 return 0;
51758
51759 err_rd:
51760 - if (!--pipe->readers)
51761 + if (atomic_dec_and_test(&pipe->readers))
51762 wake_up_interruptible(&pipe->wait);
51763 ret = -ERESTARTSYS;
51764 goto err;
51765
51766 err_wr:
51767 - if (!--pipe->writers)
51768 + if (atomic_dec_and_test(&pipe->writers))
51769 wake_up_interruptible(&pipe->wait);
51770 ret = -ERESTARTSYS;
51771 goto err;
51772
51773 err:
51774 - if (!pipe->readers && !pipe->writers)
51775 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51776 free_pipe_info(inode);
51777
51778 err_nocleanup:
51779 diff --git a/fs/file.c b/fs/file.c
51780 index 2b3570b..c57924b 100644
51781 --- a/fs/file.c
51782 +++ b/fs/file.c
51783 @@ -16,6 +16,7 @@
51784 #include <linux/slab.h>
51785 #include <linux/vmalloc.h>
51786 #include <linux/file.h>
51787 +#include <linux/security.h>
51788 #include <linux/fdtable.h>
51789 #include <linux/bitops.h>
51790 #include <linux/interrupt.h>
51791 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51792 if (!file)
51793 return __close_fd(files, fd);
51794
51795 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51796 if (fd >= rlimit(RLIMIT_NOFILE))
51797 return -EBADF;
51798
51799 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51800 if (unlikely(oldfd == newfd))
51801 return -EINVAL;
51802
51803 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51804 if (newfd >= rlimit(RLIMIT_NOFILE))
51805 return -EBADF;
51806
51807 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51808 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51809 {
51810 int err;
51811 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51812 if (from >= rlimit(RLIMIT_NOFILE))
51813 return -EINVAL;
51814 err = alloc_fd(from, flags);
51815 diff --git a/fs/filesystems.c b/fs/filesystems.c
51816 index da165f6..3671bdb 100644
51817 --- a/fs/filesystems.c
51818 +++ b/fs/filesystems.c
51819 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
51820 int len = dot ? dot - name : strlen(name);
51821
51822 fs = __get_fs_type(name, len);
51823 +
51824 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51825 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
51826 +#else
51827 if (!fs && (request_module("%.*s", len, name) == 0))
51828 +#endif
51829 fs = __get_fs_type(name, len);
51830
51831 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51832 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51833 index fe6ca58..65318cf 100644
51834 --- a/fs/fs_struct.c
51835 +++ b/fs/fs_struct.c
51836 @@ -4,6 +4,7 @@
51837 #include <linux/path.h>
51838 #include <linux/slab.h>
51839 #include <linux/fs_struct.h>
51840 +#include <linux/grsecurity.h>
51841 #include "internal.h"
51842
51843 /*
51844 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
51845 write_seqcount_begin(&fs->seq);
51846 old_root = fs->root;
51847 fs->root = *path;
51848 + gr_set_chroot_entries(current, path);
51849 write_seqcount_end(&fs->seq);
51850 spin_unlock(&fs->lock);
51851 if (old_root.dentry)
51852 @@ -53,6 +55,21 @@ static inline int replace_path(struct path *p, const struct path *old, const str
51853 return 1;
51854 }
51855
51856 +static inline int replace_root_path(struct task_struct *task, struct path *p, const struct path *old, struct path *new)
51857 +{
51858 + if (likely(p->dentry != old->dentry || p->mnt != old->mnt))
51859 + return 0;
51860 + *p = *new;
51861 +
51862 + /* This function is only called from pivot_root(). Leave our
51863 + gr_chroot_dentry and is_chrooted flags as-is, so that a
51864 + pivoted root isn't treated as a chroot
51865 + */
51866 + //gr_set_chroot_entries(task, new);
51867 +
51868 + return 1;
51869 +}
51870 +
51871 void chroot_fs_refs(struct path *old_root, struct path *new_root)
51872 {
51873 struct task_struct *g, *p;
51874 @@ -67,7 +84,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
51875 int hits = 0;
51876 spin_lock(&fs->lock);
51877 write_seqcount_begin(&fs->seq);
51878 - hits += replace_path(&fs->root, old_root, new_root);
51879 + hits += replace_root_path(p, &fs->root, old_root, new_root);
51880 hits += replace_path(&fs->pwd, old_root, new_root);
51881 write_seqcount_end(&fs->seq);
51882 while (hits--) {
51883 @@ -99,7 +116,8 @@ void exit_fs(struct task_struct *tsk)
51884 task_lock(tsk);
51885 spin_lock(&fs->lock);
51886 tsk->fs = NULL;
51887 - kill = !--fs->users;
51888 + gr_clear_chroot_entries(tsk);
51889 + kill = !atomic_dec_return(&fs->users);
51890 spin_unlock(&fs->lock);
51891 task_unlock(tsk);
51892 if (kill)
51893 @@ -112,7 +130,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51894 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51895 /* We don't need to lock fs - think why ;-) */
51896 if (fs) {
51897 - fs->users = 1;
51898 + atomic_set(&fs->users, 1);
51899 fs->in_exec = 0;
51900 spin_lock_init(&fs->lock);
51901 seqcount_init(&fs->seq);
51902 @@ -121,6 +139,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51903 spin_lock(&old->lock);
51904 fs->root = old->root;
51905 path_get(&fs->root);
51906 + /* instead of calling gr_set_chroot_entries here,
51907 + we call it from every caller of this function
51908 + */
51909 fs->pwd = old->pwd;
51910 path_get(&fs->pwd);
51911 spin_unlock(&old->lock);
51912 @@ -139,8 +160,9 @@ int unshare_fs_struct(void)
51913
51914 task_lock(current);
51915 spin_lock(&fs->lock);
51916 - kill = !--fs->users;
51917 + kill = !atomic_dec_return(&fs->users);
51918 current->fs = new_fs;
51919 + gr_set_chroot_entries(current, &new_fs->root);
51920 spin_unlock(&fs->lock);
51921 task_unlock(current);
51922
51923 @@ -153,13 +175,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51924
51925 int current_umask(void)
51926 {
51927 - return current->fs->umask;
51928 + return current->fs->umask | gr_acl_umask();
51929 }
51930 EXPORT_SYMBOL(current_umask);
51931
51932 /* to be mentioned only in INIT_TASK */
51933 struct fs_struct init_fs = {
51934 - .users = 1,
51935 + .users = ATOMIC_INIT(1),
51936 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51937 .seq = SEQCNT_ZERO,
51938 .umask = 0022,
51939 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51940 index 8dcb114..b1072e2 100644
51941 --- a/fs/fscache/cookie.c
51942 +++ b/fs/fscache/cookie.c
51943 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51944 parent ? (char *) parent->def->name : "<no-parent>",
51945 def->name, netfs_data);
51946
51947 - fscache_stat(&fscache_n_acquires);
51948 + fscache_stat_unchecked(&fscache_n_acquires);
51949
51950 /* if there's no parent cookie, then we don't create one here either */
51951 if (!parent) {
51952 - fscache_stat(&fscache_n_acquires_null);
51953 + fscache_stat_unchecked(&fscache_n_acquires_null);
51954 _leave(" [no parent]");
51955 return NULL;
51956 }
51957 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51958 /* allocate and initialise a cookie */
51959 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51960 if (!cookie) {
51961 - fscache_stat(&fscache_n_acquires_oom);
51962 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51963 _leave(" [ENOMEM]");
51964 return NULL;
51965 }
51966 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51967
51968 switch (cookie->def->type) {
51969 case FSCACHE_COOKIE_TYPE_INDEX:
51970 - fscache_stat(&fscache_n_cookie_index);
51971 + fscache_stat_unchecked(&fscache_n_cookie_index);
51972 break;
51973 case FSCACHE_COOKIE_TYPE_DATAFILE:
51974 - fscache_stat(&fscache_n_cookie_data);
51975 + fscache_stat_unchecked(&fscache_n_cookie_data);
51976 break;
51977 default:
51978 - fscache_stat(&fscache_n_cookie_special);
51979 + fscache_stat_unchecked(&fscache_n_cookie_special);
51980 break;
51981 }
51982
51983 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51984 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51985 atomic_dec(&parent->n_children);
51986 __fscache_cookie_put(cookie);
51987 - fscache_stat(&fscache_n_acquires_nobufs);
51988 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51989 _leave(" = NULL");
51990 return NULL;
51991 }
51992 }
51993
51994 - fscache_stat(&fscache_n_acquires_ok);
51995 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51996 _leave(" = %p", cookie);
51997 return cookie;
51998 }
51999 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
52000 cache = fscache_select_cache_for_object(cookie->parent);
52001 if (!cache) {
52002 up_read(&fscache_addremove_sem);
52003 - fscache_stat(&fscache_n_acquires_no_cache);
52004 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
52005 _leave(" = -ENOMEDIUM [no cache]");
52006 return -ENOMEDIUM;
52007 }
52008 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
52009 object = cache->ops->alloc_object(cache, cookie);
52010 fscache_stat_d(&fscache_n_cop_alloc_object);
52011 if (IS_ERR(object)) {
52012 - fscache_stat(&fscache_n_object_no_alloc);
52013 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
52014 ret = PTR_ERR(object);
52015 goto error;
52016 }
52017
52018 - fscache_stat(&fscache_n_object_alloc);
52019 + fscache_stat_unchecked(&fscache_n_object_alloc);
52020
52021 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
52022
52023 @@ -378,7 +378,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
52024
52025 _enter("{%s}", cookie->def->name);
52026
52027 - fscache_stat(&fscache_n_invalidates);
52028 + fscache_stat_unchecked(&fscache_n_invalidates);
52029
52030 /* Only permit invalidation of data files. Invalidating an index will
52031 * require the caller to release all its attachments to the tree rooted
52032 @@ -437,10 +437,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
52033 struct fscache_object *object;
52034 struct hlist_node *_p;
52035
52036 - fscache_stat(&fscache_n_updates);
52037 + fscache_stat_unchecked(&fscache_n_updates);
52038
52039 if (!cookie) {
52040 - fscache_stat(&fscache_n_updates_null);
52041 + fscache_stat_unchecked(&fscache_n_updates_null);
52042 _leave(" [no cookie]");
52043 return;
52044 }
52045 @@ -474,12 +474,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52046 struct fscache_object *object;
52047 unsigned long event;
52048
52049 - fscache_stat(&fscache_n_relinquishes);
52050 + fscache_stat_unchecked(&fscache_n_relinquishes);
52051 if (retire)
52052 - fscache_stat(&fscache_n_relinquishes_retire);
52053 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
52054
52055 if (!cookie) {
52056 - fscache_stat(&fscache_n_relinquishes_null);
52057 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
52058 _leave(" [no cookie]");
52059 return;
52060 }
52061 @@ -495,7 +495,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52062
52063 /* wait for the cookie to finish being instantiated (or to fail) */
52064 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
52065 - fscache_stat(&fscache_n_relinquishes_waitcrt);
52066 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
52067 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
52068 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
52069 }
52070 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
52071 index ee38fef..0a326d4 100644
52072 --- a/fs/fscache/internal.h
52073 +++ b/fs/fscache/internal.h
52074 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
52075 * stats.c
52076 */
52077 #ifdef CONFIG_FSCACHE_STATS
52078 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52079 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52080 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52081 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52082
52083 -extern atomic_t fscache_n_op_pend;
52084 -extern atomic_t fscache_n_op_run;
52085 -extern atomic_t fscache_n_op_enqueue;
52086 -extern atomic_t fscache_n_op_deferred_release;
52087 -extern atomic_t fscache_n_op_release;
52088 -extern atomic_t fscache_n_op_gc;
52089 -extern atomic_t fscache_n_op_cancelled;
52090 -extern atomic_t fscache_n_op_rejected;
52091 +extern atomic_unchecked_t fscache_n_op_pend;
52092 +extern atomic_unchecked_t fscache_n_op_run;
52093 +extern atomic_unchecked_t fscache_n_op_enqueue;
52094 +extern atomic_unchecked_t fscache_n_op_deferred_release;
52095 +extern atomic_unchecked_t fscache_n_op_release;
52096 +extern atomic_unchecked_t fscache_n_op_gc;
52097 +extern atomic_unchecked_t fscache_n_op_cancelled;
52098 +extern atomic_unchecked_t fscache_n_op_rejected;
52099
52100 -extern atomic_t fscache_n_attr_changed;
52101 -extern atomic_t fscache_n_attr_changed_ok;
52102 -extern atomic_t fscache_n_attr_changed_nobufs;
52103 -extern atomic_t fscache_n_attr_changed_nomem;
52104 -extern atomic_t fscache_n_attr_changed_calls;
52105 +extern atomic_unchecked_t fscache_n_attr_changed;
52106 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
52107 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
52108 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
52109 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
52110
52111 -extern atomic_t fscache_n_allocs;
52112 -extern atomic_t fscache_n_allocs_ok;
52113 -extern atomic_t fscache_n_allocs_wait;
52114 -extern atomic_t fscache_n_allocs_nobufs;
52115 -extern atomic_t fscache_n_allocs_intr;
52116 -extern atomic_t fscache_n_allocs_object_dead;
52117 -extern atomic_t fscache_n_alloc_ops;
52118 -extern atomic_t fscache_n_alloc_op_waits;
52119 +extern atomic_unchecked_t fscache_n_allocs;
52120 +extern atomic_unchecked_t fscache_n_allocs_ok;
52121 +extern atomic_unchecked_t fscache_n_allocs_wait;
52122 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
52123 +extern atomic_unchecked_t fscache_n_allocs_intr;
52124 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
52125 +extern atomic_unchecked_t fscache_n_alloc_ops;
52126 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
52127
52128 -extern atomic_t fscache_n_retrievals;
52129 -extern atomic_t fscache_n_retrievals_ok;
52130 -extern atomic_t fscache_n_retrievals_wait;
52131 -extern atomic_t fscache_n_retrievals_nodata;
52132 -extern atomic_t fscache_n_retrievals_nobufs;
52133 -extern atomic_t fscache_n_retrievals_intr;
52134 -extern atomic_t fscache_n_retrievals_nomem;
52135 -extern atomic_t fscache_n_retrievals_object_dead;
52136 -extern atomic_t fscache_n_retrieval_ops;
52137 -extern atomic_t fscache_n_retrieval_op_waits;
52138 +extern atomic_unchecked_t fscache_n_retrievals;
52139 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52140 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52141 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52142 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52143 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52144 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52145 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52146 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52147 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52148
52149 -extern atomic_t fscache_n_stores;
52150 -extern atomic_t fscache_n_stores_ok;
52151 -extern atomic_t fscache_n_stores_again;
52152 -extern atomic_t fscache_n_stores_nobufs;
52153 -extern atomic_t fscache_n_stores_oom;
52154 -extern atomic_t fscache_n_store_ops;
52155 -extern atomic_t fscache_n_store_calls;
52156 -extern atomic_t fscache_n_store_pages;
52157 -extern atomic_t fscache_n_store_radix_deletes;
52158 -extern atomic_t fscache_n_store_pages_over_limit;
52159 +extern atomic_unchecked_t fscache_n_stores;
52160 +extern atomic_unchecked_t fscache_n_stores_ok;
52161 +extern atomic_unchecked_t fscache_n_stores_again;
52162 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52163 +extern atomic_unchecked_t fscache_n_stores_oom;
52164 +extern atomic_unchecked_t fscache_n_store_ops;
52165 +extern atomic_unchecked_t fscache_n_store_calls;
52166 +extern atomic_unchecked_t fscache_n_store_pages;
52167 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52168 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52169
52170 -extern atomic_t fscache_n_store_vmscan_not_storing;
52171 -extern atomic_t fscache_n_store_vmscan_gone;
52172 -extern atomic_t fscache_n_store_vmscan_busy;
52173 -extern atomic_t fscache_n_store_vmscan_cancelled;
52174 -extern atomic_t fscache_n_store_vmscan_wait;
52175 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52176 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52177 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52178 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52179 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52180
52181 -extern atomic_t fscache_n_marks;
52182 -extern atomic_t fscache_n_uncaches;
52183 +extern atomic_unchecked_t fscache_n_marks;
52184 +extern atomic_unchecked_t fscache_n_uncaches;
52185
52186 -extern atomic_t fscache_n_acquires;
52187 -extern atomic_t fscache_n_acquires_null;
52188 -extern atomic_t fscache_n_acquires_no_cache;
52189 -extern atomic_t fscache_n_acquires_ok;
52190 -extern atomic_t fscache_n_acquires_nobufs;
52191 -extern atomic_t fscache_n_acquires_oom;
52192 +extern atomic_unchecked_t fscache_n_acquires;
52193 +extern atomic_unchecked_t fscache_n_acquires_null;
52194 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52195 +extern atomic_unchecked_t fscache_n_acquires_ok;
52196 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52197 +extern atomic_unchecked_t fscache_n_acquires_oom;
52198
52199 -extern atomic_t fscache_n_invalidates;
52200 -extern atomic_t fscache_n_invalidates_run;
52201 +extern atomic_unchecked_t fscache_n_invalidates;
52202 +extern atomic_unchecked_t fscache_n_invalidates_run;
52203
52204 -extern atomic_t fscache_n_updates;
52205 -extern atomic_t fscache_n_updates_null;
52206 -extern atomic_t fscache_n_updates_run;
52207 +extern atomic_unchecked_t fscache_n_updates;
52208 +extern atomic_unchecked_t fscache_n_updates_null;
52209 +extern atomic_unchecked_t fscache_n_updates_run;
52210
52211 -extern atomic_t fscache_n_relinquishes;
52212 -extern atomic_t fscache_n_relinquishes_null;
52213 -extern atomic_t fscache_n_relinquishes_waitcrt;
52214 -extern atomic_t fscache_n_relinquishes_retire;
52215 +extern atomic_unchecked_t fscache_n_relinquishes;
52216 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52217 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52218 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52219
52220 -extern atomic_t fscache_n_cookie_index;
52221 -extern atomic_t fscache_n_cookie_data;
52222 -extern atomic_t fscache_n_cookie_special;
52223 +extern atomic_unchecked_t fscache_n_cookie_index;
52224 +extern atomic_unchecked_t fscache_n_cookie_data;
52225 +extern atomic_unchecked_t fscache_n_cookie_special;
52226
52227 -extern atomic_t fscache_n_object_alloc;
52228 -extern atomic_t fscache_n_object_no_alloc;
52229 -extern atomic_t fscache_n_object_lookups;
52230 -extern atomic_t fscache_n_object_lookups_negative;
52231 -extern atomic_t fscache_n_object_lookups_positive;
52232 -extern atomic_t fscache_n_object_lookups_timed_out;
52233 -extern atomic_t fscache_n_object_created;
52234 -extern atomic_t fscache_n_object_avail;
52235 -extern atomic_t fscache_n_object_dead;
52236 +extern atomic_unchecked_t fscache_n_object_alloc;
52237 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52238 +extern atomic_unchecked_t fscache_n_object_lookups;
52239 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52240 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52241 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52242 +extern atomic_unchecked_t fscache_n_object_created;
52243 +extern atomic_unchecked_t fscache_n_object_avail;
52244 +extern atomic_unchecked_t fscache_n_object_dead;
52245
52246 -extern atomic_t fscache_n_checkaux_none;
52247 -extern atomic_t fscache_n_checkaux_okay;
52248 -extern atomic_t fscache_n_checkaux_update;
52249 -extern atomic_t fscache_n_checkaux_obsolete;
52250 +extern atomic_unchecked_t fscache_n_checkaux_none;
52251 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52252 +extern atomic_unchecked_t fscache_n_checkaux_update;
52253 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52254
52255 extern atomic_t fscache_n_cop_alloc_object;
52256 extern atomic_t fscache_n_cop_lookup_object;
52257 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52258 atomic_inc(stat);
52259 }
52260
52261 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52262 +{
52263 + atomic_inc_unchecked(stat);
52264 +}
52265 +
52266 static inline void fscache_stat_d(atomic_t *stat)
52267 {
52268 atomic_dec(stat);
52269 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52270
52271 #define __fscache_stat(stat) (NULL)
52272 #define fscache_stat(stat) do {} while (0)
52273 +#define fscache_stat_unchecked(stat) do {} while (0)
52274 #define fscache_stat_d(stat) do {} while (0)
52275 #endif
52276
52277 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52278 index 50d41c1..10ee117 100644
52279 --- a/fs/fscache/object.c
52280 +++ b/fs/fscache/object.c
52281 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52282 /* Invalidate an object on disk */
52283 case FSCACHE_OBJECT_INVALIDATING:
52284 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52285 - fscache_stat(&fscache_n_invalidates_run);
52286 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52287 fscache_stat(&fscache_n_cop_invalidate_object);
52288 fscache_invalidate_object(object);
52289 fscache_stat_d(&fscache_n_cop_invalidate_object);
52290 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52291 /* update the object metadata on disk */
52292 case FSCACHE_OBJECT_UPDATING:
52293 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52294 - fscache_stat(&fscache_n_updates_run);
52295 + fscache_stat_unchecked(&fscache_n_updates_run);
52296 fscache_stat(&fscache_n_cop_update_object);
52297 object->cache->ops->update_object(object);
52298 fscache_stat_d(&fscache_n_cop_update_object);
52299 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52300 spin_lock(&object->lock);
52301 object->state = FSCACHE_OBJECT_DEAD;
52302 spin_unlock(&object->lock);
52303 - fscache_stat(&fscache_n_object_dead);
52304 + fscache_stat_unchecked(&fscache_n_object_dead);
52305 goto terminal_transit;
52306
52307 /* handle the parent cache of this object being withdrawn from
52308 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52309 spin_lock(&object->lock);
52310 object->state = FSCACHE_OBJECT_DEAD;
52311 spin_unlock(&object->lock);
52312 - fscache_stat(&fscache_n_object_dead);
52313 + fscache_stat_unchecked(&fscache_n_object_dead);
52314 goto terminal_transit;
52315
52316 /* complain about the object being woken up once it is
52317 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52318 parent->cookie->def->name, cookie->def->name,
52319 object->cache->tag->name);
52320
52321 - fscache_stat(&fscache_n_object_lookups);
52322 + fscache_stat_unchecked(&fscache_n_object_lookups);
52323 fscache_stat(&fscache_n_cop_lookup_object);
52324 ret = object->cache->ops->lookup_object(object);
52325 fscache_stat_d(&fscache_n_cop_lookup_object);
52326 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52327 if (ret == -ETIMEDOUT) {
52328 /* probably stuck behind another object, so move this one to
52329 * the back of the queue */
52330 - fscache_stat(&fscache_n_object_lookups_timed_out);
52331 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52332 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52333 }
52334
52335 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52336
52337 spin_lock(&object->lock);
52338 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52339 - fscache_stat(&fscache_n_object_lookups_negative);
52340 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52341
52342 /* transit here to allow write requests to begin stacking up
52343 * and read requests to begin returning ENODATA */
52344 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52345 * result, in which case there may be data available */
52346 spin_lock(&object->lock);
52347 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52348 - fscache_stat(&fscache_n_object_lookups_positive);
52349 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52350
52351 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52352
52353 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52354 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52355 } else {
52356 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52357 - fscache_stat(&fscache_n_object_created);
52358 + fscache_stat_unchecked(&fscache_n_object_created);
52359
52360 object->state = FSCACHE_OBJECT_AVAILABLE;
52361 spin_unlock(&object->lock);
52362 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52363 fscache_enqueue_dependents(object);
52364
52365 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52366 - fscache_stat(&fscache_n_object_avail);
52367 + fscache_stat_unchecked(&fscache_n_object_avail);
52368
52369 _leave("");
52370 }
52371 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52372 enum fscache_checkaux result;
52373
52374 if (!object->cookie->def->check_aux) {
52375 - fscache_stat(&fscache_n_checkaux_none);
52376 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52377 return FSCACHE_CHECKAUX_OKAY;
52378 }
52379
52380 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52381 switch (result) {
52382 /* entry okay as is */
52383 case FSCACHE_CHECKAUX_OKAY:
52384 - fscache_stat(&fscache_n_checkaux_okay);
52385 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52386 break;
52387
52388 /* entry requires update */
52389 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52390 - fscache_stat(&fscache_n_checkaux_update);
52391 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52392 break;
52393
52394 /* entry requires deletion */
52395 case FSCACHE_CHECKAUX_OBSOLETE:
52396 - fscache_stat(&fscache_n_checkaux_obsolete);
52397 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52398 break;
52399
52400 default:
52401 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52402 index 762a9ec..2023284 100644
52403 --- a/fs/fscache/operation.c
52404 +++ b/fs/fscache/operation.c
52405 @@ -17,7 +17,7 @@
52406 #include <linux/slab.h>
52407 #include "internal.h"
52408
52409 -atomic_t fscache_op_debug_id;
52410 +atomic_unchecked_t fscache_op_debug_id;
52411 EXPORT_SYMBOL(fscache_op_debug_id);
52412
52413 /**
52414 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52415 ASSERTCMP(atomic_read(&op->usage), >, 0);
52416 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52417
52418 - fscache_stat(&fscache_n_op_enqueue);
52419 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52420 switch (op->flags & FSCACHE_OP_TYPE) {
52421 case FSCACHE_OP_ASYNC:
52422 _debug("queue async");
52423 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52424 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52425 if (op->processor)
52426 fscache_enqueue_operation(op);
52427 - fscache_stat(&fscache_n_op_run);
52428 + fscache_stat_unchecked(&fscache_n_op_run);
52429 }
52430
52431 /*
52432 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52433 if (object->n_in_progress > 0) {
52434 atomic_inc(&op->usage);
52435 list_add_tail(&op->pend_link, &object->pending_ops);
52436 - fscache_stat(&fscache_n_op_pend);
52437 + fscache_stat_unchecked(&fscache_n_op_pend);
52438 } else if (!list_empty(&object->pending_ops)) {
52439 atomic_inc(&op->usage);
52440 list_add_tail(&op->pend_link, &object->pending_ops);
52441 - fscache_stat(&fscache_n_op_pend);
52442 + fscache_stat_unchecked(&fscache_n_op_pend);
52443 fscache_start_operations(object);
52444 } else {
52445 ASSERTCMP(object->n_in_progress, ==, 0);
52446 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52447 object->n_exclusive++; /* reads and writes must wait */
52448 atomic_inc(&op->usage);
52449 list_add_tail(&op->pend_link, &object->pending_ops);
52450 - fscache_stat(&fscache_n_op_pend);
52451 + fscache_stat_unchecked(&fscache_n_op_pend);
52452 ret = 0;
52453 } else {
52454 /* If we're in any other state, there must have been an I/O
52455 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52456 if (object->n_exclusive > 0) {
52457 atomic_inc(&op->usage);
52458 list_add_tail(&op->pend_link, &object->pending_ops);
52459 - fscache_stat(&fscache_n_op_pend);
52460 + fscache_stat_unchecked(&fscache_n_op_pend);
52461 } else if (!list_empty(&object->pending_ops)) {
52462 atomic_inc(&op->usage);
52463 list_add_tail(&op->pend_link, &object->pending_ops);
52464 - fscache_stat(&fscache_n_op_pend);
52465 + fscache_stat_unchecked(&fscache_n_op_pend);
52466 fscache_start_operations(object);
52467 } else {
52468 ASSERTCMP(object->n_exclusive, ==, 0);
52469 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52470 object->n_ops++;
52471 atomic_inc(&op->usage);
52472 list_add_tail(&op->pend_link, &object->pending_ops);
52473 - fscache_stat(&fscache_n_op_pend);
52474 + fscache_stat_unchecked(&fscache_n_op_pend);
52475 ret = 0;
52476 } else if (object->state == FSCACHE_OBJECT_DYING ||
52477 object->state == FSCACHE_OBJECT_LC_DYING ||
52478 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52479 - fscache_stat(&fscache_n_op_rejected);
52480 + fscache_stat_unchecked(&fscache_n_op_rejected);
52481 op->state = FSCACHE_OP_ST_CANCELLED;
52482 ret = -ENOBUFS;
52483 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52484 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52485 ret = -EBUSY;
52486 if (op->state == FSCACHE_OP_ST_PENDING) {
52487 ASSERT(!list_empty(&op->pend_link));
52488 - fscache_stat(&fscache_n_op_cancelled);
52489 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52490 list_del_init(&op->pend_link);
52491 if (do_cancel)
52492 do_cancel(op);
52493 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52494 while (!list_empty(&object->pending_ops)) {
52495 op = list_entry(object->pending_ops.next,
52496 struct fscache_operation, pend_link);
52497 - fscache_stat(&fscache_n_op_cancelled);
52498 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52499 list_del_init(&op->pend_link);
52500
52501 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52502 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52503 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52504 op->state = FSCACHE_OP_ST_DEAD;
52505
52506 - fscache_stat(&fscache_n_op_release);
52507 + fscache_stat_unchecked(&fscache_n_op_release);
52508
52509 if (op->release) {
52510 op->release(op);
52511 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52512 * lock, and defer it otherwise */
52513 if (!spin_trylock(&object->lock)) {
52514 _debug("defer put");
52515 - fscache_stat(&fscache_n_op_deferred_release);
52516 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52517
52518 cache = object->cache;
52519 spin_lock(&cache->op_gc_list_lock);
52520 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52521
52522 _debug("GC DEFERRED REL OBJ%x OP%x",
52523 object->debug_id, op->debug_id);
52524 - fscache_stat(&fscache_n_op_gc);
52525 + fscache_stat_unchecked(&fscache_n_op_gc);
52526
52527 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52528 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52529 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52530 index ff000e5..c44ec6d 100644
52531 --- a/fs/fscache/page.c
52532 +++ b/fs/fscache/page.c
52533 @@ -61,7 +61,7 @@ try_again:
52534 val = radix_tree_lookup(&cookie->stores, page->index);
52535 if (!val) {
52536 rcu_read_unlock();
52537 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52538 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52539 __fscache_uncache_page(cookie, page);
52540 return true;
52541 }
52542 @@ -91,11 +91,11 @@ try_again:
52543 spin_unlock(&cookie->stores_lock);
52544
52545 if (xpage) {
52546 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52547 - fscache_stat(&fscache_n_store_radix_deletes);
52548 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52549 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52550 ASSERTCMP(xpage, ==, page);
52551 } else {
52552 - fscache_stat(&fscache_n_store_vmscan_gone);
52553 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52554 }
52555
52556 wake_up_bit(&cookie->flags, 0);
52557 @@ -110,11 +110,11 @@ page_busy:
52558 * sleeping on memory allocation, so we may need to impose a timeout
52559 * too. */
52560 if (!(gfp & __GFP_WAIT)) {
52561 - fscache_stat(&fscache_n_store_vmscan_busy);
52562 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52563 return false;
52564 }
52565
52566 - fscache_stat(&fscache_n_store_vmscan_wait);
52567 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52568 __fscache_wait_on_page_write(cookie, page);
52569 gfp &= ~__GFP_WAIT;
52570 goto try_again;
52571 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52572 FSCACHE_COOKIE_STORING_TAG);
52573 if (!radix_tree_tag_get(&cookie->stores, page->index,
52574 FSCACHE_COOKIE_PENDING_TAG)) {
52575 - fscache_stat(&fscache_n_store_radix_deletes);
52576 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52577 xpage = radix_tree_delete(&cookie->stores, page->index);
52578 }
52579 spin_unlock(&cookie->stores_lock);
52580 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52581
52582 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52583
52584 - fscache_stat(&fscache_n_attr_changed_calls);
52585 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52586
52587 if (fscache_object_is_active(object)) {
52588 fscache_stat(&fscache_n_cop_attr_changed);
52589 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52590
52591 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52592
52593 - fscache_stat(&fscache_n_attr_changed);
52594 + fscache_stat_unchecked(&fscache_n_attr_changed);
52595
52596 op = kzalloc(sizeof(*op), GFP_KERNEL);
52597 if (!op) {
52598 - fscache_stat(&fscache_n_attr_changed_nomem);
52599 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52600 _leave(" = -ENOMEM");
52601 return -ENOMEM;
52602 }
52603 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52604 if (fscache_submit_exclusive_op(object, op) < 0)
52605 goto nobufs;
52606 spin_unlock(&cookie->lock);
52607 - fscache_stat(&fscache_n_attr_changed_ok);
52608 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52609 fscache_put_operation(op);
52610 _leave(" = 0");
52611 return 0;
52612 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52613 nobufs:
52614 spin_unlock(&cookie->lock);
52615 kfree(op);
52616 - fscache_stat(&fscache_n_attr_changed_nobufs);
52617 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52618 _leave(" = %d", -ENOBUFS);
52619 return -ENOBUFS;
52620 }
52621 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52622 /* allocate a retrieval operation and attempt to submit it */
52623 op = kzalloc(sizeof(*op), GFP_NOIO);
52624 if (!op) {
52625 - fscache_stat(&fscache_n_retrievals_nomem);
52626 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52627 return NULL;
52628 }
52629
52630 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52631 return 0;
52632 }
52633
52634 - fscache_stat(&fscache_n_retrievals_wait);
52635 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52636
52637 jif = jiffies;
52638 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52639 fscache_wait_bit_interruptible,
52640 TASK_INTERRUPTIBLE) != 0) {
52641 - fscache_stat(&fscache_n_retrievals_intr);
52642 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52643 _leave(" = -ERESTARTSYS");
52644 return -ERESTARTSYS;
52645 }
52646 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52647 */
52648 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52649 struct fscache_retrieval *op,
52650 - atomic_t *stat_op_waits,
52651 - atomic_t *stat_object_dead)
52652 + atomic_unchecked_t *stat_op_waits,
52653 + atomic_unchecked_t *stat_object_dead)
52654 {
52655 int ret;
52656
52657 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52658 goto check_if_dead;
52659
52660 _debug(">>> WT");
52661 - fscache_stat(stat_op_waits);
52662 + fscache_stat_unchecked(stat_op_waits);
52663 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52664 fscache_wait_bit_interruptible,
52665 TASK_INTERRUPTIBLE) != 0) {
52666 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52667
52668 check_if_dead:
52669 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52670 - fscache_stat(stat_object_dead);
52671 + fscache_stat_unchecked(stat_object_dead);
52672 _leave(" = -ENOBUFS [cancelled]");
52673 return -ENOBUFS;
52674 }
52675 if (unlikely(fscache_object_is_dead(object))) {
52676 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52677 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52678 - fscache_stat(stat_object_dead);
52679 + fscache_stat_unchecked(stat_object_dead);
52680 return -ENOBUFS;
52681 }
52682 return 0;
52683 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52684
52685 _enter("%p,%p,,,", cookie, page);
52686
52687 - fscache_stat(&fscache_n_retrievals);
52688 + fscache_stat_unchecked(&fscache_n_retrievals);
52689
52690 if (hlist_empty(&cookie->backing_objects))
52691 goto nobufs;
52692 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52693 goto nobufs_unlock_dec;
52694 spin_unlock(&cookie->lock);
52695
52696 - fscache_stat(&fscache_n_retrieval_ops);
52697 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52698
52699 /* pin the netfs read context in case we need to do the actual netfs
52700 * read because we've encountered a cache read failure */
52701 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52702
52703 error:
52704 if (ret == -ENOMEM)
52705 - fscache_stat(&fscache_n_retrievals_nomem);
52706 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52707 else if (ret == -ERESTARTSYS)
52708 - fscache_stat(&fscache_n_retrievals_intr);
52709 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52710 else if (ret == -ENODATA)
52711 - fscache_stat(&fscache_n_retrievals_nodata);
52712 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52713 else if (ret < 0)
52714 - fscache_stat(&fscache_n_retrievals_nobufs);
52715 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52716 else
52717 - fscache_stat(&fscache_n_retrievals_ok);
52718 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52719
52720 fscache_put_retrieval(op);
52721 _leave(" = %d", ret);
52722 @@ -467,7 +467,7 @@ nobufs_unlock:
52723 spin_unlock(&cookie->lock);
52724 kfree(op);
52725 nobufs:
52726 - fscache_stat(&fscache_n_retrievals_nobufs);
52727 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52728 _leave(" = -ENOBUFS");
52729 return -ENOBUFS;
52730 }
52731 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52732
52733 _enter("%p,,%d,,,", cookie, *nr_pages);
52734
52735 - fscache_stat(&fscache_n_retrievals);
52736 + fscache_stat_unchecked(&fscache_n_retrievals);
52737
52738 if (hlist_empty(&cookie->backing_objects))
52739 goto nobufs;
52740 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52741 goto nobufs_unlock_dec;
52742 spin_unlock(&cookie->lock);
52743
52744 - fscache_stat(&fscache_n_retrieval_ops);
52745 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52746
52747 /* pin the netfs read context in case we need to do the actual netfs
52748 * read because we've encountered a cache read failure */
52749 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52750
52751 error:
52752 if (ret == -ENOMEM)
52753 - fscache_stat(&fscache_n_retrievals_nomem);
52754 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52755 else if (ret == -ERESTARTSYS)
52756 - fscache_stat(&fscache_n_retrievals_intr);
52757 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52758 else if (ret == -ENODATA)
52759 - fscache_stat(&fscache_n_retrievals_nodata);
52760 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52761 else if (ret < 0)
52762 - fscache_stat(&fscache_n_retrievals_nobufs);
52763 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52764 else
52765 - fscache_stat(&fscache_n_retrievals_ok);
52766 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52767
52768 fscache_put_retrieval(op);
52769 _leave(" = %d", ret);
52770 @@ -591,7 +591,7 @@ nobufs_unlock:
52771 spin_unlock(&cookie->lock);
52772 kfree(op);
52773 nobufs:
52774 - fscache_stat(&fscache_n_retrievals_nobufs);
52775 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52776 _leave(" = -ENOBUFS");
52777 return -ENOBUFS;
52778 }
52779 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52780
52781 _enter("%p,%p,,,", cookie, page);
52782
52783 - fscache_stat(&fscache_n_allocs);
52784 + fscache_stat_unchecked(&fscache_n_allocs);
52785
52786 if (hlist_empty(&cookie->backing_objects))
52787 goto nobufs;
52788 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52789 goto nobufs_unlock;
52790 spin_unlock(&cookie->lock);
52791
52792 - fscache_stat(&fscache_n_alloc_ops);
52793 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52794
52795 ret = fscache_wait_for_retrieval_activation(
52796 object, op,
52797 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52798
52799 error:
52800 if (ret == -ERESTARTSYS)
52801 - fscache_stat(&fscache_n_allocs_intr);
52802 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52803 else if (ret < 0)
52804 - fscache_stat(&fscache_n_allocs_nobufs);
52805 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52806 else
52807 - fscache_stat(&fscache_n_allocs_ok);
52808 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52809
52810 fscache_put_retrieval(op);
52811 _leave(" = %d", ret);
52812 @@ -677,7 +677,7 @@ nobufs_unlock:
52813 spin_unlock(&cookie->lock);
52814 kfree(op);
52815 nobufs:
52816 - fscache_stat(&fscache_n_allocs_nobufs);
52817 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52818 _leave(" = -ENOBUFS");
52819 return -ENOBUFS;
52820 }
52821 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52822
52823 spin_lock(&cookie->stores_lock);
52824
52825 - fscache_stat(&fscache_n_store_calls);
52826 + fscache_stat_unchecked(&fscache_n_store_calls);
52827
52828 /* find a page to store */
52829 page = NULL;
52830 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52831 page = results[0];
52832 _debug("gang %d [%lx]", n, page->index);
52833 if (page->index > op->store_limit) {
52834 - fscache_stat(&fscache_n_store_pages_over_limit);
52835 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52836 goto superseded;
52837 }
52838
52839 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52840 spin_unlock(&cookie->stores_lock);
52841 spin_unlock(&object->lock);
52842
52843 - fscache_stat(&fscache_n_store_pages);
52844 + fscache_stat_unchecked(&fscache_n_store_pages);
52845 fscache_stat(&fscache_n_cop_write_page);
52846 ret = object->cache->ops->write_page(op, page);
52847 fscache_stat_d(&fscache_n_cop_write_page);
52848 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52849 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52850 ASSERT(PageFsCache(page));
52851
52852 - fscache_stat(&fscache_n_stores);
52853 + fscache_stat_unchecked(&fscache_n_stores);
52854
52855 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52856 _leave(" = -ENOBUFS [invalidating]");
52857 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52858 spin_unlock(&cookie->stores_lock);
52859 spin_unlock(&object->lock);
52860
52861 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52862 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52863 op->store_limit = object->store_limit;
52864
52865 if (fscache_submit_op(object, &op->op) < 0)
52866 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52867
52868 spin_unlock(&cookie->lock);
52869 radix_tree_preload_end();
52870 - fscache_stat(&fscache_n_store_ops);
52871 - fscache_stat(&fscache_n_stores_ok);
52872 + fscache_stat_unchecked(&fscache_n_store_ops);
52873 + fscache_stat_unchecked(&fscache_n_stores_ok);
52874
52875 /* the work queue now carries its own ref on the object */
52876 fscache_put_operation(&op->op);
52877 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52878 return 0;
52879
52880 already_queued:
52881 - fscache_stat(&fscache_n_stores_again);
52882 + fscache_stat_unchecked(&fscache_n_stores_again);
52883 already_pending:
52884 spin_unlock(&cookie->stores_lock);
52885 spin_unlock(&object->lock);
52886 spin_unlock(&cookie->lock);
52887 radix_tree_preload_end();
52888 kfree(op);
52889 - fscache_stat(&fscache_n_stores_ok);
52890 + fscache_stat_unchecked(&fscache_n_stores_ok);
52891 _leave(" = 0");
52892 return 0;
52893
52894 @@ -959,14 +959,14 @@ nobufs:
52895 spin_unlock(&cookie->lock);
52896 radix_tree_preload_end();
52897 kfree(op);
52898 - fscache_stat(&fscache_n_stores_nobufs);
52899 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52900 _leave(" = -ENOBUFS");
52901 return -ENOBUFS;
52902
52903 nomem_free:
52904 kfree(op);
52905 nomem:
52906 - fscache_stat(&fscache_n_stores_oom);
52907 + fscache_stat_unchecked(&fscache_n_stores_oom);
52908 _leave(" = -ENOMEM");
52909 return -ENOMEM;
52910 }
52911 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52912 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52913 ASSERTCMP(page, !=, NULL);
52914
52915 - fscache_stat(&fscache_n_uncaches);
52916 + fscache_stat_unchecked(&fscache_n_uncaches);
52917
52918 /* cache withdrawal may beat us to it */
52919 if (!PageFsCache(page))
52920 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52921 struct fscache_cookie *cookie = op->op.object->cookie;
52922
52923 #ifdef CONFIG_FSCACHE_STATS
52924 - atomic_inc(&fscache_n_marks);
52925 + atomic_inc_unchecked(&fscache_n_marks);
52926 #endif
52927
52928 _debug("- mark %p{%lx}", page, page->index);
52929 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52930 index 8179e8b..5072cc7 100644
52931 --- a/fs/fscache/stats.c
52932 +++ b/fs/fscache/stats.c
52933 @@ -18,99 +18,99 @@
52934 /*
52935 * operation counters
52936 */
52937 -atomic_t fscache_n_op_pend;
52938 -atomic_t fscache_n_op_run;
52939 -atomic_t fscache_n_op_enqueue;
52940 -atomic_t fscache_n_op_requeue;
52941 -atomic_t fscache_n_op_deferred_release;
52942 -atomic_t fscache_n_op_release;
52943 -atomic_t fscache_n_op_gc;
52944 -atomic_t fscache_n_op_cancelled;
52945 -atomic_t fscache_n_op_rejected;
52946 +atomic_unchecked_t fscache_n_op_pend;
52947 +atomic_unchecked_t fscache_n_op_run;
52948 +atomic_unchecked_t fscache_n_op_enqueue;
52949 +atomic_unchecked_t fscache_n_op_requeue;
52950 +atomic_unchecked_t fscache_n_op_deferred_release;
52951 +atomic_unchecked_t fscache_n_op_release;
52952 +atomic_unchecked_t fscache_n_op_gc;
52953 +atomic_unchecked_t fscache_n_op_cancelled;
52954 +atomic_unchecked_t fscache_n_op_rejected;
52955
52956 -atomic_t fscache_n_attr_changed;
52957 -atomic_t fscache_n_attr_changed_ok;
52958 -atomic_t fscache_n_attr_changed_nobufs;
52959 -atomic_t fscache_n_attr_changed_nomem;
52960 -atomic_t fscache_n_attr_changed_calls;
52961 +atomic_unchecked_t fscache_n_attr_changed;
52962 +atomic_unchecked_t fscache_n_attr_changed_ok;
52963 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52964 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52965 +atomic_unchecked_t fscache_n_attr_changed_calls;
52966
52967 -atomic_t fscache_n_allocs;
52968 -atomic_t fscache_n_allocs_ok;
52969 -atomic_t fscache_n_allocs_wait;
52970 -atomic_t fscache_n_allocs_nobufs;
52971 -atomic_t fscache_n_allocs_intr;
52972 -atomic_t fscache_n_allocs_object_dead;
52973 -atomic_t fscache_n_alloc_ops;
52974 -atomic_t fscache_n_alloc_op_waits;
52975 +atomic_unchecked_t fscache_n_allocs;
52976 +atomic_unchecked_t fscache_n_allocs_ok;
52977 +atomic_unchecked_t fscache_n_allocs_wait;
52978 +atomic_unchecked_t fscache_n_allocs_nobufs;
52979 +atomic_unchecked_t fscache_n_allocs_intr;
52980 +atomic_unchecked_t fscache_n_allocs_object_dead;
52981 +atomic_unchecked_t fscache_n_alloc_ops;
52982 +atomic_unchecked_t fscache_n_alloc_op_waits;
52983
52984 -atomic_t fscache_n_retrievals;
52985 -atomic_t fscache_n_retrievals_ok;
52986 -atomic_t fscache_n_retrievals_wait;
52987 -atomic_t fscache_n_retrievals_nodata;
52988 -atomic_t fscache_n_retrievals_nobufs;
52989 -atomic_t fscache_n_retrievals_intr;
52990 -atomic_t fscache_n_retrievals_nomem;
52991 -atomic_t fscache_n_retrievals_object_dead;
52992 -atomic_t fscache_n_retrieval_ops;
52993 -atomic_t fscache_n_retrieval_op_waits;
52994 +atomic_unchecked_t fscache_n_retrievals;
52995 +atomic_unchecked_t fscache_n_retrievals_ok;
52996 +atomic_unchecked_t fscache_n_retrievals_wait;
52997 +atomic_unchecked_t fscache_n_retrievals_nodata;
52998 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52999 +atomic_unchecked_t fscache_n_retrievals_intr;
53000 +atomic_unchecked_t fscache_n_retrievals_nomem;
53001 +atomic_unchecked_t fscache_n_retrievals_object_dead;
53002 +atomic_unchecked_t fscache_n_retrieval_ops;
53003 +atomic_unchecked_t fscache_n_retrieval_op_waits;
53004
53005 -atomic_t fscache_n_stores;
53006 -atomic_t fscache_n_stores_ok;
53007 -atomic_t fscache_n_stores_again;
53008 -atomic_t fscache_n_stores_nobufs;
53009 -atomic_t fscache_n_stores_oom;
53010 -atomic_t fscache_n_store_ops;
53011 -atomic_t fscache_n_store_calls;
53012 -atomic_t fscache_n_store_pages;
53013 -atomic_t fscache_n_store_radix_deletes;
53014 -atomic_t fscache_n_store_pages_over_limit;
53015 +atomic_unchecked_t fscache_n_stores;
53016 +atomic_unchecked_t fscache_n_stores_ok;
53017 +atomic_unchecked_t fscache_n_stores_again;
53018 +atomic_unchecked_t fscache_n_stores_nobufs;
53019 +atomic_unchecked_t fscache_n_stores_oom;
53020 +atomic_unchecked_t fscache_n_store_ops;
53021 +atomic_unchecked_t fscache_n_store_calls;
53022 +atomic_unchecked_t fscache_n_store_pages;
53023 +atomic_unchecked_t fscache_n_store_radix_deletes;
53024 +atomic_unchecked_t fscache_n_store_pages_over_limit;
53025
53026 -atomic_t fscache_n_store_vmscan_not_storing;
53027 -atomic_t fscache_n_store_vmscan_gone;
53028 -atomic_t fscache_n_store_vmscan_busy;
53029 -atomic_t fscache_n_store_vmscan_cancelled;
53030 -atomic_t fscache_n_store_vmscan_wait;
53031 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
53032 +atomic_unchecked_t fscache_n_store_vmscan_gone;
53033 +atomic_unchecked_t fscache_n_store_vmscan_busy;
53034 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
53035 +atomic_unchecked_t fscache_n_store_vmscan_wait;
53036
53037 -atomic_t fscache_n_marks;
53038 -atomic_t fscache_n_uncaches;
53039 +atomic_unchecked_t fscache_n_marks;
53040 +atomic_unchecked_t fscache_n_uncaches;
53041
53042 -atomic_t fscache_n_acquires;
53043 -atomic_t fscache_n_acquires_null;
53044 -atomic_t fscache_n_acquires_no_cache;
53045 -atomic_t fscache_n_acquires_ok;
53046 -atomic_t fscache_n_acquires_nobufs;
53047 -atomic_t fscache_n_acquires_oom;
53048 +atomic_unchecked_t fscache_n_acquires;
53049 +atomic_unchecked_t fscache_n_acquires_null;
53050 +atomic_unchecked_t fscache_n_acquires_no_cache;
53051 +atomic_unchecked_t fscache_n_acquires_ok;
53052 +atomic_unchecked_t fscache_n_acquires_nobufs;
53053 +atomic_unchecked_t fscache_n_acquires_oom;
53054
53055 -atomic_t fscache_n_invalidates;
53056 -atomic_t fscache_n_invalidates_run;
53057 +atomic_unchecked_t fscache_n_invalidates;
53058 +atomic_unchecked_t fscache_n_invalidates_run;
53059
53060 -atomic_t fscache_n_updates;
53061 -atomic_t fscache_n_updates_null;
53062 -atomic_t fscache_n_updates_run;
53063 +atomic_unchecked_t fscache_n_updates;
53064 +atomic_unchecked_t fscache_n_updates_null;
53065 +atomic_unchecked_t fscache_n_updates_run;
53066
53067 -atomic_t fscache_n_relinquishes;
53068 -atomic_t fscache_n_relinquishes_null;
53069 -atomic_t fscache_n_relinquishes_waitcrt;
53070 -atomic_t fscache_n_relinquishes_retire;
53071 +atomic_unchecked_t fscache_n_relinquishes;
53072 +atomic_unchecked_t fscache_n_relinquishes_null;
53073 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
53074 +atomic_unchecked_t fscache_n_relinquishes_retire;
53075
53076 -atomic_t fscache_n_cookie_index;
53077 -atomic_t fscache_n_cookie_data;
53078 -atomic_t fscache_n_cookie_special;
53079 +atomic_unchecked_t fscache_n_cookie_index;
53080 +atomic_unchecked_t fscache_n_cookie_data;
53081 +atomic_unchecked_t fscache_n_cookie_special;
53082
53083 -atomic_t fscache_n_object_alloc;
53084 -atomic_t fscache_n_object_no_alloc;
53085 -atomic_t fscache_n_object_lookups;
53086 -atomic_t fscache_n_object_lookups_negative;
53087 -atomic_t fscache_n_object_lookups_positive;
53088 -atomic_t fscache_n_object_lookups_timed_out;
53089 -atomic_t fscache_n_object_created;
53090 -atomic_t fscache_n_object_avail;
53091 -atomic_t fscache_n_object_dead;
53092 +atomic_unchecked_t fscache_n_object_alloc;
53093 +atomic_unchecked_t fscache_n_object_no_alloc;
53094 +atomic_unchecked_t fscache_n_object_lookups;
53095 +atomic_unchecked_t fscache_n_object_lookups_negative;
53096 +atomic_unchecked_t fscache_n_object_lookups_positive;
53097 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
53098 +atomic_unchecked_t fscache_n_object_created;
53099 +atomic_unchecked_t fscache_n_object_avail;
53100 +atomic_unchecked_t fscache_n_object_dead;
53101
53102 -atomic_t fscache_n_checkaux_none;
53103 -atomic_t fscache_n_checkaux_okay;
53104 -atomic_t fscache_n_checkaux_update;
53105 -atomic_t fscache_n_checkaux_obsolete;
53106 +atomic_unchecked_t fscache_n_checkaux_none;
53107 +atomic_unchecked_t fscache_n_checkaux_okay;
53108 +atomic_unchecked_t fscache_n_checkaux_update;
53109 +atomic_unchecked_t fscache_n_checkaux_obsolete;
53110
53111 atomic_t fscache_n_cop_alloc_object;
53112 atomic_t fscache_n_cop_lookup_object;
53113 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
53114 seq_puts(m, "FS-Cache statistics\n");
53115
53116 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
53117 - atomic_read(&fscache_n_cookie_index),
53118 - atomic_read(&fscache_n_cookie_data),
53119 - atomic_read(&fscache_n_cookie_special));
53120 + atomic_read_unchecked(&fscache_n_cookie_index),
53121 + atomic_read_unchecked(&fscache_n_cookie_data),
53122 + atomic_read_unchecked(&fscache_n_cookie_special));
53123
53124 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
53125 - atomic_read(&fscache_n_object_alloc),
53126 - atomic_read(&fscache_n_object_no_alloc),
53127 - atomic_read(&fscache_n_object_avail),
53128 - atomic_read(&fscache_n_object_dead));
53129 + atomic_read_unchecked(&fscache_n_object_alloc),
53130 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53131 + atomic_read_unchecked(&fscache_n_object_avail),
53132 + atomic_read_unchecked(&fscache_n_object_dead));
53133 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53134 - atomic_read(&fscache_n_checkaux_none),
53135 - atomic_read(&fscache_n_checkaux_okay),
53136 - atomic_read(&fscache_n_checkaux_update),
53137 - atomic_read(&fscache_n_checkaux_obsolete));
53138 + atomic_read_unchecked(&fscache_n_checkaux_none),
53139 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53140 + atomic_read_unchecked(&fscache_n_checkaux_update),
53141 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53142
53143 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53144 - atomic_read(&fscache_n_marks),
53145 - atomic_read(&fscache_n_uncaches));
53146 + atomic_read_unchecked(&fscache_n_marks),
53147 + atomic_read_unchecked(&fscache_n_uncaches));
53148
53149 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53150 " oom=%u\n",
53151 - atomic_read(&fscache_n_acquires),
53152 - atomic_read(&fscache_n_acquires_null),
53153 - atomic_read(&fscache_n_acquires_no_cache),
53154 - atomic_read(&fscache_n_acquires_ok),
53155 - atomic_read(&fscache_n_acquires_nobufs),
53156 - atomic_read(&fscache_n_acquires_oom));
53157 + atomic_read_unchecked(&fscache_n_acquires),
53158 + atomic_read_unchecked(&fscache_n_acquires_null),
53159 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53160 + atomic_read_unchecked(&fscache_n_acquires_ok),
53161 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53162 + atomic_read_unchecked(&fscache_n_acquires_oom));
53163
53164 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53165 - atomic_read(&fscache_n_object_lookups),
53166 - atomic_read(&fscache_n_object_lookups_negative),
53167 - atomic_read(&fscache_n_object_lookups_positive),
53168 - atomic_read(&fscache_n_object_created),
53169 - atomic_read(&fscache_n_object_lookups_timed_out));
53170 + atomic_read_unchecked(&fscache_n_object_lookups),
53171 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53172 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53173 + atomic_read_unchecked(&fscache_n_object_created),
53174 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53175
53176 seq_printf(m, "Invals : n=%u run=%u\n",
53177 - atomic_read(&fscache_n_invalidates),
53178 - atomic_read(&fscache_n_invalidates_run));
53179 + atomic_read_unchecked(&fscache_n_invalidates),
53180 + atomic_read_unchecked(&fscache_n_invalidates_run));
53181
53182 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53183 - atomic_read(&fscache_n_updates),
53184 - atomic_read(&fscache_n_updates_null),
53185 - atomic_read(&fscache_n_updates_run));
53186 + atomic_read_unchecked(&fscache_n_updates),
53187 + atomic_read_unchecked(&fscache_n_updates_null),
53188 + atomic_read_unchecked(&fscache_n_updates_run));
53189
53190 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53191 - atomic_read(&fscache_n_relinquishes),
53192 - atomic_read(&fscache_n_relinquishes_null),
53193 - atomic_read(&fscache_n_relinquishes_waitcrt),
53194 - atomic_read(&fscache_n_relinquishes_retire));
53195 + atomic_read_unchecked(&fscache_n_relinquishes),
53196 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53197 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53198 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53199
53200 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53201 - atomic_read(&fscache_n_attr_changed),
53202 - atomic_read(&fscache_n_attr_changed_ok),
53203 - atomic_read(&fscache_n_attr_changed_nobufs),
53204 - atomic_read(&fscache_n_attr_changed_nomem),
53205 - atomic_read(&fscache_n_attr_changed_calls));
53206 + atomic_read_unchecked(&fscache_n_attr_changed),
53207 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53208 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53209 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53210 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53211
53212 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53213 - atomic_read(&fscache_n_allocs),
53214 - atomic_read(&fscache_n_allocs_ok),
53215 - atomic_read(&fscache_n_allocs_wait),
53216 - atomic_read(&fscache_n_allocs_nobufs),
53217 - atomic_read(&fscache_n_allocs_intr));
53218 + atomic_read_unchecked(&fscache_n_allocs),
53219 + atomic_read_unchecked(&fscache_n_allocs_ok),
53220 + atomic_read_unchecked(&fscache_n_allocs_wait),
53221 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53222 + atomic_read_unchecked(&fscache_n_allocs_intr));
53223 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53224 - atomic_read(&fscache_n_alloc_ops),
53225 - atomic_read(&fscache_n_alloc_op_waits),
53226 - atomic_read(&fscache_n_allocs_object_dead));
53227 + atomic_read_unchecked(&fscache_n_alloc_ops),
53228 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53229 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53230
53231 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53232 " int=%u oom=%u\n",
53233 - atomic_read(&fscache_n_retrievals),
53234 - atomic_read(&fscache_n_retrievals_ok),
53235 - atomic_read(&fscache_n_retrievals_wait),
53236 - atomic_read(&fscache_n_retrievals_nodata),
53237 - atomic_read(&fscache_n_retrievals_nobufs),
53238 - atomic_read(&fscache_n_retrievals_intr),
53239 - atomic_read(&fscache_n_retrievals_nomem));
53240 + atomic_read_unchecked(&fscache_n_retrievals),
53241 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53242 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53243 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53244 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53245 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53246 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53247 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53248 - atomic_read(&fscache_n_retrieval_ops),
53249 - atomic_read(&fscache_n_retrieval_op_waits),
53250 - atomic_read(&fscache_n_retrievals_object_dead));
53251 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53252 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53253 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53254
53255 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53256 - atomic_read(&fscache_n_stores),
53257 - atomic_read(&fscache_n_stores_ok),
53258 - atomic_read(&fscache_n_stores_again),
53259 - atomic_read(&fscache_n_stores_nobufs),
53260 - atomic_read(&fscache_n_stores_oom));
53261 + atomic_read_unchecked(&fscache_n_stores),
53262 + atomic_read_unchecked(&fscache_n_stores_ok),
53263 + atomic_read_unchecked(&fscache_n_stores_again),
53264 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53265 + atomic_read_unchecked(&fscache_n_stores_oom));
53266 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53267 - atomic_read(&fscache_n_store_ops),
53268 - atomic_read(&fscache_n_store_calls),
53269 - atomic_read(&fscache_n_store_pages),
53270 - atomic_read(&fscache_n_store_radix_deletes),
53271 - atomic_read(&fscache_n_store_pages_over_limit));
53272 + atomic_read_unchecked(&fscache_n_store_ops),
53273 + atomic_read_unchecked(&fscache_n_store_calls),
53274 + atomic_read_unchecked(&fscache_n_store_pages),
53275 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53276 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53277
53278 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53279 - atomic_read(&fscache_n_store_vmscan_not_storing),
53280 - atomic_read(&fscache_n_store_vmscan_gone),
53281 - atomic_read(&fscache_n_store_vmscan_busy),
53282 - atomic_read(&fscache_n_store_vmscan_cancelled),
53283 - atomic_read(&fscache_n_store_vmscan_wait));
53284 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53285 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53286 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53287 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53288 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53289
53290 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53291 - atomic_read(&fscache_n_op_pend),
53292 - atomic_read(&fscache_n_op_run),
53293 - atomic_read(&fscache_n_op_enqueue),
53294 - atomic_read(&fscache_n_op_cancelled),
53295 - atomic_read(&fscache_n_op_rejected));
53296 + atomic_read_unchecked(&fscache_n_op_pend),
53297 + atomic_read_unchecked(&fscache_n_op_run),
53298 + atomic_read_unchecked(&fscache_n_op_enqueue),
53299 + atomic_read_unchecked(&fscache_n_op_cancelled),
53300 + atomic_read_unchecked(&fscache_n_op_rejected));
53301 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53302 - atomic_read(&fscache_n_op_deferred_release),
53303 - atomic_read(&fscache_n_op_release),
53304 - atomic_read(&fscache_n_op_gc));
53305 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53306 + atomic_read_unchecked(&fscache_n_op_release),
53307 + atomic_read_unchecked(&fscache_n_op_gc));
53308
53309 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53310 atomic_read(&fscache_n_cop_alloc_object),
53311 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53312 index e397b67..b0d8709 100644
53313 --- a/fs/fuse/cuse.c
53314 +++ b/fs/fuse/cuse.c
53315 @@ -593,10 +593,12 @@ static int __init cuse_init(void)
53316 INIT_LIST_HEAD(&cuse_conntbl[i]);
53317
53318 /* inherit and extend fuse_dev_operations */
53319 - cuse_channel_fops = fuse_dev_operations;
53320 - cuse_channel_fops.owner = THIS_MODULE;
53321 - cuse_channel_fops.open = cuse_channel_open;
53322 - cuse_channel_fops.release = cuse_channel_release;
53323 + pax_open_kernel();
53324 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53325 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53326 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53327 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53328 + pax_close_kernel();
53329
53330 cuse_class = class_create(THIS_MODULE, "cuse");
53331 if (IS_ERR(cuse_class))
53332 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53333 index e83351a..41e3c9c 100644
53334 --- a/fs/fuse/dev.c
53335 +++ b/fs/fuse/dev.c
53336 @@ -1236,7 +1236,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53337 ret = 0;
53338 pipe_lock(pipe);
53339
53340 - if (!pipe->readers) {
53341 + if (!atomic_read(&pipe->readers)) {
53342 send_sig(SIGPIPE, current, 0);
53343 if (!ret)
53344 ret = -EPIPE;
53345 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53346 index 315e1f8..91f890c 100644
53347 --- a/fs/fuse/dir.c
53348 +++ b/fs/fuse/dir.c
53349 @@ -1233,7 +1233,7 @@ static char *read_link(struct dentry *dentry)
53350 return link;
53351 }
53352
53353 -static void free_link(char *link)
53354 +static void free_link(const char *link)
53355 {
53356 if (!IS_ERR(link))
53357 free_page((unsigned long) link);
53358 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53359 index 2b6f569..fcb4d1f 100644
53360 --- a/fs/gfs2/inode.c
53361 +++ b/fs/gfs2/inode.c
53362 @@ -1499,7 +1499,7 @@ out:
53363
53364 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53365 {
53366 - char *s = nd_get_link(nd);
53367 + const char *s = nd_get_link(nd);
53368 if (!IS_ERR(s))
53369 kfree(s);
53370 }
53371 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53372 index 78bde32..767e906 100644
53373 --- a/fs/hugetlbfs/inode.c
53374 +++ b/fs/hugetlbfs/inode.c
53375 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53376 struct mm_struct *mm = current->mm;
53377 struct vm_area_struct *vma;
53378 struct hstate *h = hstate_file(file);
53379 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53380 struct vm_unmapped_area_info info;
53381
53382 if (len & ~huge_page_mask(h))
53383 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53384 return addr;
53385 }
53386
53387 +#ifdef CONFIG_PAX_RANDMMAP
53388 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53389 +#endif
53390 +
53391 if (addr) {
53392 addr = ALIGN(addr, huge_page_size(h));
53393 vma = find_vma(mm, addr);
53394 - if (TASK_SIZE - len >= addr &&
53395 - (!vma || addr + len <= vma->vm_start))
53396 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53397 return addr;
53398 }
53399
53400 info.flags = 0;
53401 info.length = len;
53402 info.low_limit = TASK_UNMAPPED_BASE;
53403 +
53404 +#ifdef CONFIG_PAX_RANDMMAP
53405 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53406 + info.low_limit += mm->delta_mmap;
53407 +#endif
53408 +
53409 info.high_limit = TASK_SIZE;
53410 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53411 info.align_offset = 0;
53412 @@ -897,7 +907,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53413 .kill_sb = kill_litter_super,
53414 };
53415
53416 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53417 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53418
53419 static int can_do_hugetlb_shm(void)
53420 {
53421 diff --git a/fs/inode.c b/fs/inode.c
53422 index 14084b7..29af1d9 100644
53423 --- a/fs/inode.c
53424 +++ b/fs/inode.c
53425 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
53426
53427 #ifdef CONFIG_SMP
53428 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53429 - static atomic_t shared_last_ino;
53430 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53431 + static atomic_unchecked_t shared_last_ino;
53432 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53433
53434 res = next - LAST_INO_BATCH;
53435 }
53436 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53437 index 4a6cf28..d3a29d3 100644
53438 --- a/fs/jffs2/erase.c
53439 +++ b/fs/jffs2/erase.c
53440 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53441 struct jffs2_unknown_node marker = {
53442 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53443 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53444 - .totlen = cpu_to_je32(c->cleanmarker_size)
53445 + .totlen = cpu_to_je32(c->cleanmarker_size),
53446 + .hdr_crc = cpu_to_je32(0)
53447 };
53448
53449 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53450 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53451 index a6597d6..41b30ec 100644
53452 --- a/fs/jffs2/wbuf.c
53453 +++ b/fs/jffs2/wbuf.c
53454 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53455 {
53456 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53457 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53458 - .totlen = constant_cpu_to_je32(8)
53459 + .totlen = constant_cpu_to_je32(8),
53460 + .hdr_crc = constant_cpu_to_je32(0)
53461 };
53462
53463 /*
53464 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53465 index 1a543be..a4e1363 100644
53466 --- a/fs/jfs/super.c
53467 +++ b/fs/jfs/super.c
53468 @@ -225,7 +225,7 @@ static const match_table_t tokens = {
53469 static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53470 int *flag)
53471 {
53472 - void *nls_map = (void *)-1; /* -1: no change; NULL: none */
53473 + const void *nls_map = (const void *)-1; /* -1: no change; NULL: none */
53474 char *p;
53475 struct jfs_sb_info *sbi = JFS_SBI(sb);
53476
53477 @@ -253,7 +253,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53478 /* Don't do anything ;-) */
53479 break;
53480 case Opt_iocharset:
53481 - if (nls_map && nls_map != (void *) -1)
53482 + if (nls_map && nls_map != (const void *) -1)
53483 unload_nls(nls_map);
53484 if (!strcmp(args[0].from, "none"))
53485 nls_map = NULL;
53486 @@ -855,7 +855,7 @@ static int __init init_jfs_fs(void)
53487
53488 jfs_inode_cachep =
53489 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53490 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53491 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53492 init_once);
53493 if (jfs_inode_cachep == NULL)
53494 return -ENOMEM;
53495 diff --git a/fs/libfs.c b/fs/libfs.c
53496 index 916da8c..1588998 100644
53497 --- a/fs/libfs.c
53498 +++ b/fs/libfs.c
53499 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53500
53501 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53502 struct dentry *next;
53503 + char d_name[sizeof(next->d_iname)];
53504 + const unsigned char *name;
53505 +
53506 next = list_entry(p, struct dentry, d_u.d_child);
53507 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53508 if (!simple_positive(next)) {
53509 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53510
53511 spin_unlock(&next->d_lock);
53512 spin_unlock(&dentry->d_lock);
53513 - if (filldir(dirent, next->d_name.name,
53514 + name = next->d_name.name;
53515 + if (name == next->d_iname) {
53516 + memcpy(d_name, name, next->d_name.len);
53517 + name = d_name;
53518 + }
53519 + if (filldir(dirent, name,
53520 next->d_name.len, filp->f_pos,
53521 next->d_inode->i_ino,
53522 dt_type(next->d_inode)) < 0)
53523 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53524 index 52e5120..808936e 100644
53525 --- a/fs/lockd/clntproc.c
53526 +++ b/fs/lockd/clntproc.c
53527 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53528 /*
53529 * Cookie counter for NLM requests
53530 */
53531 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53532 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53533
53534 void nlmclnt_next_cookie(struct nlm_cookie *c)
53535 {
53536 - u32 cookie = atomic_inc_return(&nlm_cookie);
53537 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53538
53539 memcpy(c->data, &cookie, 4);
53540 c->len=4;
53541 diff --git a/fs/locks.c b/fs/locks.c
53542 index a94e331..060bce3 100644
53543 --- a/fs/locks.c
53544 +++ b/fs/locks.c
53545 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53546 return;
53547
53548 if (filp->f_op && filp->f_op->flock) {
53549 - struct file_lock fl = {
53550 + struct file_lock flock = {
53551 .fl_pid = current->tgid,
53552 .fl_file = filp,
53553 .fl_flags = FL_FLOCK,
53554 .fl_type = F_UNLCK,
53555 .fl_end = OFFSET_MAX,
53556 };
53557 - filp->f_op->flock(filp, F_SETLKW, &fl);
53558 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53559 - fl.fl_ops->fl_release_private(&fl);
53560 + filp->f_op->flock(filp, F_SETLKW, &flock);
53561 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53562 + flock.fl_ops->fl_release_private(&flock);
53563 }
53564
53565 lock_flocks();
53566 diff --git a/fs/namei.c b/fs/namei.c
53567 index ec97aef..e67718d 100644
53568 --- a/fs/namei.c
53569 +++ b/fs/namei.c
53570 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53571 if (ret != -EACCES)
53572 return ret;
53573
53574 +#ifdef CONFIG_GRKERNSEC
53575 + /* we'll block if we have to log due to a denied capability use */
53576 + if (mask & MAY_NOT_BLOCK)
53577 + return -ECHILD;
53578 +#endif
53579 +
53580 if (S_ISDIR(inode->i_mode)) {
53581 /* DACs are overridable for directories */
53582 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53583 - return 0;
53584 if (!(mask & MAY_WRITE))
53585 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53586 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53587 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53588 return 0;
53589 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53590 + return 0;
53591 return -EACCES;
53592 }
53593 /*
53594 + * Searching includes executable on directories, else just read.
53595 + */
53596 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53597 + if (mask == MAY_READ)
53598 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53599 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53600 + return 0;
53601 +
53602 + /*
53603 * Read/write DACs are always overridable.
53604 * Executable DACs are overridable when there is
53605 * at least one exec bit set.
53606 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53607 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53608 return 0;
53609
53610 - /*
53611 - * Searching includes executable on directories, else just read.
53612 - */
53613 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53614 - if (mask == MAY_READ)
53615 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53616 - return 0;
53617 -
53618 return -EACCES;
53619 }
53620
53621 @@ -824,7 +832,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53622 {
53623 struct dentry *dentry = link->dentry;
53624 int error;
53625 - char *s;
53626 + const char *s;
53627
53628 BUG_ON(nd->flags & LOOKUP_RCU);
53629
53630 @@ -845,6 +853,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53631 if (error)
53632 goto out_put_nd_path;
53633
53634 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53635 + dentry->d_inode, dentry, nd->path.mnt)) {
53636 + error = -EACCES;
53637 + goto out_put_nd_path;
53638 + }
53639 +
53640 nd->last_type = LAST_BIND;
53641 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53642 error = PTR_ERR(*p);
53643 @@ -1594,6 +1608,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53644 break;
53645 res = walk_component(nd, path, &nd->last,
53646 nd->last_type, LOOKUP_FOLLOW);
53647 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53648 + res = -EACCES;
53649 put_link(nd, &link, cookie);
53650 } while (res > 0);
53651
53652 @@ -1692,7 +1708,7 @@ EXPORT_SYMBOL(full_name_hash);
53653 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53654 {
53655 unsigned long a, b, adata, bdata, mask, hash, len;
53656 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53657 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53658
53659 hash = a = 0;
53660 len = -sizeof(unsigned long);
53661 @@ -1977,6 +1993,8 @@ static int path_lookupat(int dfd, const char *name,
53662 if (err)
53663 break;
53664 err = lookup_last(nd, &path);
53665 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53666 + err = -EACCES;
53667 put_link(nd, &link, cookie);
53668 }
53669 }
53670 @@ -1984,6 +2002,13 @@ static int path_lookupat(int dfd, const char *name,
53671 if (!err)
53672 err = complete_walk(nd);
53673
53674 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53675 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53676 + path_put(&nd->path);
53677 + err = -ENOENT;
53678 + }
53679 + }
53680 +
53681 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53682 if (!nd->inode->i_op->lookup) {
53683 path_put(&nd->path);
53684 @@ -2011,8 +2036,15 @@ static int filename_lookup(int dfd, struct filename *name,
53685 retval = path_lookupat(dfd, name->name,
53686 flags | LOOKUP_REVAL, nd);
53687
53688 - if (likely(!retval))
53689 + if (likely(!retval)) {
53690 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53691 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53692 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53693 + path_put(&nd->path);
53694 + return -ENOENT;
53695 + }
53696 + }
53697 + }
53698 return retval;
53699 }
53700
53701 @@ -2390,6 +2422,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53702 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53703 return -EPERM;
53704
53705 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53706 + return -EPERM;
53707 + if (gr_handle_rawio(inode))
53708 + return -EPERM;
53709 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53710 + return -EACCES;
53711 +
53712 return 0;
53713 }
53714
53715 @@ -2611,7 +2650,7 @@ looked_up:
53716 * cleared otherwise prior to returning.
53717 */
53718 static int lookup_open(struct nameidata *nd, struct path *path,
53719 - struct file *file,
53720 + struct path *link, struct file *file,
53721 const struct open_flags *op,
53722 bool got_write, int *opened)
53723 {
53724 @@ -2646,6 +2685,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53725 /* Negative dentry, just create the file */
53726 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53727 umode_t mode = op->mode;
53728 +
53729 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53730 + error = -EACCES;
53731 + goto out_dput;
53732 + }
53733 +
53734 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53735 + error = -EACCES;
53736 + goto out_dput;
53737 + }
53738 +
53739 if (!IS_POSIXACL(dir->d_inode))
53740 mode &= ~current_umask();
53741 /*
53742 @@ -2667,6 +2717,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53743 nd->flags & LOOKUP_EXCL);
53744 if (error)
53745 goto out_dput;
53746 + else
53747 + gr_handle_create(dentry, nd->path.mnt);
53748 }
53749 out_no_open:
53750 path->dentry = dentry;
53751 @@ -2681,7 +2733,7 @@ out_dput:
53752 /*
53753 * Handle the last step of open()
53754 */
53755 -static int do_last(struct nameidata *nd, struct path *path,
53756 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53757 struct file *file, const struct open_flags *op,
53758 int *opened, struct filename *name)
53759 {
53760 @@ -2710,16 +2762,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53761 error = complete_walk(nd);
53762 if (error)
53763 return error;
53764 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53765 + error = -ENOENT;
53766 + goto out;
53767 + }
53768 audit_inode(name, nd->path.dentry, 0);
53769 if (open_flag & O_CREAT) {
53770 error = -EISDIR;
53771 goto out;
53772 }
53773 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53774 + error = -EACCES;
53775 + goto out;
53776 + }
53777 goto finish_open;
53778 case LAST_BIND:
53779 error = complete_walk(nd);
53780 if (error)
53781 return error;
53782 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53783 + error = -ENOENT;
53784 + goto out;
53785 + }
53786 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53787 + error = -EACCES;
53788 + goto out;
53789 + }
53790 audit_inode(name, dir, 0);
53791 goto finish_open;
53792 }
53793 @@ -2768,7 +2836,7 @@ retry_lookup:
53794 */
53795 }
53796 mutex_lock(&dir->d_inode->i_mutex);
53797 - error = lookup_open(nd, path, file, op, got_write, opened);
53798 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53799 mutex_unlock(&dir->d_inode->i_mutex);
53800
53801 if (error <= 0) {
53802 @@ -2792,11 +2860,28 @@ retry_lookup:
53803 goto finish_open_created;
53804 }
53805
53806 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53807 + error = -ENOENT;
53808 + goto exit_dput;
53809 + }
53810 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53811 + error = -EACCES;
53812 + goto exit_dput;
53813 + }
53814 +
53815 /*
53816 * create/update audit record if it already exists.
53817 */
53818 - if (path->dentry->d_inode)
53819 + if (path->dentry->d_inode) {
53820 + /* only check if O_CREAT is specified, all other checks need to go
53821 + into may_open */
53822 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53823 + error = -EACCES;
53824 + goto exit_dput;
53825 + }
53826 +
53827 audit_inode(name, path->dentry, 0);
53828 + }
53829
53830 /*
53831 * If atomic_open() acquired write access it is dropped now due to
53832 @@ -2837,6 +2922,11 @@ finish_lookup:
53833 }
53834 }
53835 BUG_ON(inode != path->dentry->d_inode);
53836 + /* if we're resolving a symlink to another symlink */
53837 + if (link && gr_handle_symlink_owner(link, inode)) {
53838 + error = -EACCES;
53839 + goto out;
53840 + }
53841 return 1;
53842 }
53843
53844 @@ -2846,7 +2936,6 @@ finish_lookup:
53845 save_parent.dentry = nd->path.dentry;
53846 save_parent.mnt = mntget(path->mnt);
53847 nd->path.dentry = path->dentry;
53848 -
53849 }
53850 nd->inode = inode;
53851 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53852 @@ -2855,6 +2944,16 @@ finish_lookup:
53853 path_put(&save_parent);
53854 return error;
53855 }
53856 +
53857 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53858 + error = -ENOENT;
53859 + goto out;
53860 + }
53861 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53862 + error = -EACCES;
53863 + goto out;
53864 + }
53865 +
53866 error = -EISDIR;
53867 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53868 goto out;
53869 @@ -2953,7 +3052,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53870 if (unlikely(error))
53871 goto out;
53872
53873 - error = do_last(nd, &path, file, op, &opened, pathname);
53874 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53875 while (unlikely(error > 0)) { /* trailing symlink */
53876 struct path link = path;
53877 void *cookie;
53878 @@ -2971,7 +3070,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53879 error = follow_link(&link, nd, &cookie);
53880 if (unlikely(error))
53881 break;
53882 - error = do_last(nd, &path, file, op, &opened, pathname);
53883 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53884 put_link(nd, &link, cookie);
53885 }
53886 out:
53887 @@ -3071,8 +3170,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53888 goto unlock;
53889
53890 error = -EEXIST;
53891 - if (dentry->d_inode)
53892 + if (dentry->d_inode) {
53893 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53894 + error = -ENOENT;
53895 + }
53896 goto fail;
53897 + }
53898 /*
53899 * Special case - lookup gave negative, but... we had foo/bar/
53900 * From the vfs_mknod() POV we just have a negative dentry -
53901 @@ -3124,6 +3227,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53902 }
53903 EXPORT_SYMBOL(user_path_create);
53904
53905 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53906 +{
53907 + struct filename *tmp = getname(pathname);
53908 + struct dentry *res;
53909 + if (IS_ERR(tmp))
53910 + return ERR_CAST(tmp);
53911 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53912 + if (IS_ERR(res))
53913 + putname(tmp);
53914 + else
53915 + *to = tmp;
53916 + return res;
53917 +}
53918 +
53919 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53920 {
53921 int error = may_create(dir, dentry);
53922 @@ -3186,6 +3303,17 @@ retry:
53923
53924 if (!IS_POSIXACL(path.dentry->d_inode))
53925 mode &= ~current_umask();
53926 +
53927 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53928 + error = -EPERM;
53929 + goto out;
53930 + }
53931 +
53932 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53933 + error = -EACCES;
53934 + goto out;
53935 + }
53936 +
53937 error = security_path_mknod(&path, dentry, mode, dev);
53938 if (error)
53939 goto out;
53940 @@ -3202,6 +3330,8 @@ retry:
53941 break;
53942 }
53943 out:
53944 + if (!error)
53945 + gr_handle_create(dentry, path.mnt);
53946 done_path_create(&path, dentry);
53947 if (retry_estale(error, lookup_flags)) {
53948 lookup_flags |= LOOKUP_REVAL;
53949 @@ -3254,9 +3384,16 @@ retry:
53950
53951 if (!IS_POSIXACL(path.dentry->d_inode))
53952 mode &= ~current_umask();
53953 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53954 + error = -EACCES;
53955 + goto out;
53956 + }
53957 error = security_path_mkdir(&path, dentry, mode);
53958 if (!error)
53959 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53960 + if (!error)
53961 + gr_handle_create(dentry, path.mnt);
53962 +out:
53963 done_path_create(&path, dentry);
53964 if (retry_estale(error, lookup_flags)) {
53965 lookup_flags |= LOOKUP_REVAL;
53966 @@ -3337,6 +3474,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53967 struct filename *name;
53968 struct dentry *dentry;
53969 struct nameidata nd;
53970 + ino_t saved_ino = 0;
53971 + dev_t saved_dev = 0;
53972 unsigned int lookup_flags = 0;
53973 retry:
53974 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53975 @@ -3369,10 +3508,21 @@ retry:
53976 error = -ENOENT;
53977 goto exit3;
53978 }
53979 +
53980 + saved_ino = dentry->d_inode->i_ino;
53981 + saved_dev = gr_get_dev_from_dentry(dentry);
53982 +
53983 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53984 + error = -EACCES;
53985 + goto exit3;
53986 + }
53987 +
53988 error = security_path_rmdir(&nd.path, dentry);
53989 if (error)
53990 goto exit3;
53991 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53992 + if (!error && (saved_dev || saved_ino))
53993 + gr_handle_delete(saved_ino, saved_dev);
53994 exit3:
53995 dput(dentry);
53996 exit2:
53997 @@ -3438,6 +3588,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53998 struct dentry *dentry;
53999 struct nameidata nd;
54000 struct inode *inode = NULL;
54001 + ino_t saved_ino = 0;
54002 + dev_t saved_dev = 0;
54003 unsigned int lookup_flags = 0;
54004 retry:
54005 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54006 @@ -3464,10 +3616,22 @@ retry:
54007 if (!inode)
54008 goto slashes;
54009 ihold(inode);
54010 +
54011 + if (inode->i_nlink <= 1) {
54012 + saved_ino = inode->i_ino;
54013 + saved_dev = gr_get_dev_from_dentry(dentry);
54014 + }
54015 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
54016 + error = -EACCES;
54017 + goto exit2;
54018 + }
54019 +
54020 error = security_path_unlink(&nd.path, dentry);
54021 if (error)
54022 goto exit2;
54023 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
54024 + if (!error && (saved_ino || saved_dev))
54025 + gr_handle_delete(saved_ino, saved_dev);
54026 exit2:
54027 dput(dentry);
54028 }
54029 @@ -3545,9 +3709,17 @@ retry:
54030 if (IS_ERR(dentry))
54031 goto out_putname;
54032
54033 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
54034 + error = -EACCES;
54035 + goto out;
54036 + }
54037 +
54038 error = security_path_symlink(&path, dentry, from->name);
54039 if (!error)
54040 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
54041 + if (!error)
54042 + gr_handle_create(dentry, path.mnt);
54043 +out:
54044 done_path_create(&path, dentry);
54045 if (retry_estale(error, lookup_flags)) {
54046 lookup_flags |= LOOKUP_REVAL;
54047 @@ -3621,6 +3793,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
54048 {
54049 struct dentry *new_dentry;
54050 struct path old_path, new_path;
54051 + struct filename *to = NULL;
54052 int how = 0;
54053 int error;
54054
54055 @@ -3644,7 +3817,7 @@ retry:
54056 if (error)
54057 return error;
54058
54059 - new_dentry = user_path_create(newdfd, newname, &new_path,
54060 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
54061 (how & LOOKUP_REVAL));
54062 error = PTR_ERR(new_dentry);
54063 if (IS_ERR(new_dentry))
54064 @@ -3656,11 +3829,28 @@ retry:
54065 error = may_linkat(&old_path);
54066 if (unlikely(error))
54067 goto out_dput;
54068 +
54069 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
54070 + old_path.dentry->d_inode,
54071 + old_path.dentry->d_inode->i_mode, to)) {
54072 + error = -EACCES;
54073 + goto out_dput;
54074 + }
54075 +
54076 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
54077 + old_path.dentry, old_path.mnt, to)) {
54078 + error = -EACCES;
54079 + goto out_dput;
54080 + }
54081 +
54082 error = security_path_link(old_path.dentry, &new_path, new_dentry);
54083 if (error)
54084 goto out_dput;
54085 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
54086 + if (!error)
54087 + gr_handle_create(new_dentry, new_path.mnt);
54088 out_dput:
54089 + putname(to);
54090 done_path_create(&new_path, new_dentry);
54091 if (retry_estale(error, how)) {
54092 how |= LOOKUP_REVAL;
54093 @@ -3906,12 +4096,21 @@ retry:
54094 if (new_dentry == trap)
54095 goto exit5;
54096
54097 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
54098 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
54099 + to);
54100 + if (error)
54101 + goto exit5;
54102 +
54103 error = security_path_rename(&oldnd.path, old_dentry,
54104 &newnd.path, new_dentry);
54105 if (error)
54106 goto exit5;
54107 error = vfs_rename(old_dir->d_inode, old_dentry,
54108 new_dir->d_inode, new_dentry);
54109 + if (!error)
54110 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
54111 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
54112 exit5:
54113 dput(new_dentry);
54114 exit4:
54115 @@ -3943,6 +4142,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
54116
54117 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
54118 {
54119 + char tmpbuf[64];
54120 + const char *newlink;
54121 int len;
54122
54123 len = PTR_ERR(link);
54124 @@ -3952,7 +4153,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
54125 len = strlen(link);
54126 if (len > (unsigned) buflen)
54127 len = buflen;
54128 - if (copy_to_user(buffer, link, len))
54129 +
54130 + if (len < sizeof(tmpbuf)) {
54131 + memcpy(tmpbuf, link, len);
54132 + newlink = tmpbuf;
54133 + } else
54134 + newlink = link;
54135 +
54136 + if (copy_to_user(buffer, newlink, len))
54137 len = -EFAULT;
54138 out:
54139 return len;
54140 diff --git a/fs/namespace.c b/fs/namespace.c
54141 index 5dd7709..6f64e9c 100644
54142 --- a/fs/namespace.c
54143 +++ b/fs/namespace.c
54144 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
54145 if (!(sb->s_flags & MS_RDONLY))
54146 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54147 up_write(&sb->s_umount);
54148 +
54149 + gr_log_remount(mnt->mnt_devname, retval);
54150 +
54151 return retval;
54152 }
54153
54154 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
54155 br_write_unlock(&vfsmount_lock);
54156 up_write(&namespace_sem);
54157 release_mounts(&umount_list);
54158 +
54159 + gr_log_unmount(mnt->mnt_devname, retval);
54160 +
54161 return retval;
54162 }
54163
54164 @@ -1713,7 +1719,7 @@ static int do_loopback(struct path *path, const char *old_name,
54165
54166 if (IS_ERR(mnt)) {
54167 err = PTR_ERR(mnt);
54168 - goto out;
54169 + goto out2;
54170 }
54171
54172 err = graft_tree(mnt, path);
54173 @@ -2294,6 +2300,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54174 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54175 MS_STRICTATIME);
54176
54177 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54178 + retval = -EPERM;
54179 + goto dput_out;
54180 + }
54181 +
54182 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54183 + retval = -EPERM;
54184 + goto dput_out;
54185 + }
54186 +
54187 if (flags & MS_REMOUNT)
54188 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54189 data_page);
54190 @@ -2308,6 +2324,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54191 dev_name, data_page);
54192 dput_out:
54193 path_put(&path);
54194 +
54195 + gr_log_mount(dev_name, dir_name, retval);
54196 +
54197 return retval;
54198 }
54199
54200 @@ -2594,6 +2613,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54201 if (error)
54202 goto out2;
54203
54204 + if (gr_handle_chroot_pivot()) {
54205 + error = -EPERM;
54206 + goto out2;
54207 + }
54208 +
54209 get_fs_root(current->fs, &root);
54210 error = lock_mount(&old);
54211 if (error)
54212 @@ -2842,7 +2866,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54213 !nsown_capable(CAP_SYS_ADMIN))
54214 return -EPERM;
54215
54216 - if (fs->users != 1)
54217 + if (atomic_read(&fs->users) != 1)
54218 return -EINVAL;
54219
54220 get_mnt_ns(mnt_ns);
54221 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54222 index 59461c9..b17c57e 100644
54223 --- a/fs/nfs/callback_xdr.c
54224 +++ b/fs/nfs/callback_xdr.c
54225 @@ -51,7 +51,7 @@ struct callback_op {
54226 callback_decode_arg_t decode_args;
54227 callback_encode_res_t encode_res;
54228 long res_maxsize;
54229 -};
54230 +} __do_const;
54231
54232 static struct callback_op callback_ops[];
54233
54234 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54235 index ebeb94c..ff35337 100644
54236 --- a/fs/nfs/inode.c
54237 +++ b/fs/nfs/inode.c
54238 @@ -1042,16 +1042,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54239 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54240 }
54241
54242 -static atomic_long_t nfs_attr_generation_counter;
54243 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54244
54245 static unsigned long nfs_read_attr_generation_counter(void)
54246 {
54247 - return atomic_long_read(&nfs_attr_generation_counter);
54248 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54249 }
54250
54251 unsigned long nfs_inc_attr_generation_counter(void)
54252 {
54253 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54254 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54255 }
54256
54257 void nfs_fattr_init(struct nfs_fattr *fattr)
54258 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54259 index 9d1c5db..1e13db8 100644
54260 --- a/fs/nfsd/nfs4proc.c
54261 +++ b/fs/nfsd/nfs4proc.c
54262 @@ -1097,7 +1097,7 @@ struct nfsd4_operation {
54263 nfsd4op_rsize op_rsize_bop;
54264 stateid_getter op_get_currentstateid;
54265 stateid_setter op_set_currentstateid;
54266 -};
54267 +} __do_const;
54268
54269 static struct nfsd4_operation nfsd4_ops[];
54270
54271 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54272 index d1dd710..32ac0e8 100644
54273 --- a/fs/nfsd/nfs4xdr.c
54274 +++ b/fs/nfsd/nfs4xdr.c
54275 @@ -1456,7 +1456,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54276
54277 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54278
54279 -static nfsd4_dec nfsd4_dec_ops[] = {
54280 +static const nfsd4_dec nfsd4_dec_ops[] = {
54281 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54282 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54283 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54284 @@ -1496,7 +1496,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54285 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54286 };
54287
54288 -static nfsd4_dec nfsd41_dec_ops[] = {
54289 +static const nfsd4_dec nfsd41_dec_ops[] = {
54290 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54291 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54292 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54293 @@ -1558,7 +1558,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54294 };
54295
54296 struct nfsd4_minorversion_ops {
54297 - nfsd4_dec *decoders;
54298 + const nfsd4_dec *decoders;
54299 int nops;
54300 };
54301
54302 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54303 index 69c6413..c0408d2 100644
54304 --- a/fs/nfsd/vfs.c
54305 +++ b/fs/nfsd/vfs.c
54306 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54307 } else {
54308 oldfs = get_fs();
54309 set_fs(KERNEL_DS);
54310 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54311 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54312 set_fs(oldfs);
54313 }
54314
54315 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54316
54317 /* Write the data. */
54318 oldfs = get_fs(); set_fs(KERNEL_DS);
54319 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54320 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54321 set_fs(oldfs);
54322 if (host_err < 0)
54323 goto out_nfserr;
54324 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54325 */
54326
54327 oldfs = get_fs(); set_fs(KERNEL_DS);
54328 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54329 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54330 set_fs(oldfs);
54331
54332 if (host_err < 0)
54333 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54334 index fea6bd5..8ee9d81 100644
54335 --- a/fs/nls/nls_base.c
54336 +++ b/fs/nls/nls_base.c
54337 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54338
54339 int register_nls(struct nls_table * nls)
54340 {
54341 - struct nls_table ** tmp = &tables;
54342 + struct nls_table *tmp = tables;
54343
54344 if (nls->next)
54345 return -EBUSY;
54346
54347 spin_lock(&nls_lock);
54348 - while (*tmp) {
54349 - if (nls == *tmp) {
54350 + while (tmp) {
54351 + if (nls == tmp) {
54352 spin_unlock(&nls_lock);
54353 return -EBUSY;
54354 }
54355 - tmp = &(*tmp)->next;
54356 + tmp = tmp->next;
54357 }
54358 - nls->next = tables;
54359 + pax_open_kernel();
54360 + *(struct nls_table **)&nls->next = tables;
54361 + pax_close_kernel();
54362 tables = nls;
54363 spin_unlock(&nls_lock);
54364 return 0;
54365 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54366
54367 int unregister_nls(struct nls_table * nls)
54368 {
54369 - struct nls_table ** tmp = &tables;
54370 + struct nls_table * const * tmp = &tables;
54371
54372 spin_lock(&nls_lock);
54373 while (*tmp) {
54374 if (nls == *tmp) {
54375 - *tmp = nls->next;
54376 + pax_open_kernel();
54377 + *(struct nls_table **)tmp = nls->next;
54378 + pax_close_kernel();
54379 spin_unlock(&nls_lock);
54380 return 0;
54381 }
54382 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54383 index 7424929..35f6be5 100644
54384 --- a/fs/nls/nls_euc-jp.c
54385 +++ b/fs/nls/nls_euc-jp.c
54386 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54387 p_nls = load_nls("cp932");
54388
54389 if (p_nls) {
54390 - table.charset2upper = p_nls->charset2upper;
54391 - table.charset2lower = p_nls->charset2lower;
54392 + pax_open_kernel();
54393 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54394 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54395 + pax_close_kernel();
54396 return register_nls(&table);
54397 }
54398
54399 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54400 index e7bc1d7..06bd4bb 100644
54401 --- a/fs/nls/nls_koi8-ru.c
54402 +++ b/fs/nls/nls_koi8-ru.c
54403 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54404 p_nls = load_nls("koi8-u");
54405
54406 if (p_nls) {
54407 - table.charset2upper = p_nls->charset2upper;
54408 - table.charset2lower = p_nls->charset2lower;
54409 + pax_open_kernel();
54410 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54411 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54412 + pax_close_kernel();
54413 return register_nls(&table);
54414 }
54415
54416 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54417 index 9ff4a5e..deb1f0f 100644
54418 --- a/fs/notify/fanotify/fanotify_user.c
54419 +++ b/fs/notify/fanotify/fanotify_user.c
54420 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54421
54422 fd = fanotify_event_metadata.fd;
54423 ret = -EFAULT;
54424 - if (copy_to_user(buf, &fanotify_event_metadata,
54425 - fanotify_event_metadata.event_len))
54426 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54427 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54428 goto out_close_fd;
54429
54430 ret = prepare_for_access_response(group, event, fd);
54431 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54432 index 7b51b05..5ea5ef6 100644
54433 --- a/fs/notify/notification.c
54434 +++ b/fs/notify/notification.c
54435 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54436 * get set to 0 so it will never get 'freed'
54437 */
54438 static struct fsnotify_event *q_overflow_event;
54439 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54440 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54441
54442 /**
54443 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54444 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54445 */
54446 u32 fsnotify_get_cookie(void)
54447 {
54448 - return atomic_inc_return(&fsnotify_sync_cookie);
54449 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54450 }
54451 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54452
54453 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54454 index 99e3610..02c1068 100644
54455 --- a/fs/ntfs/dir.c
54456 +++ b/fs/ntfs/dir.c
54457 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54458 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54459 ~(s64)(ndir->itype.index.block_size - 1)));
54460 /* Bounds checks. */
54461 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54462 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54463 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54464 "inode 0x%lx or driver bug.", vdir->i_ino);
54465 goto err_out;
54466 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54467 index 5b2d4f0..c6de396 100644
54468 --- a/fs/ntfs/file.c
54469 +++ b/fs/ntfs/file.c
54470 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54471 #endif /* NTFS_RW */
54472 };
54473
54474 -const struct file_operations ntfs_empty_file_ops = {};
54475 +const struct file_operations ntfs_empty_file_ops __read_only;
54476
54477 -const struct inode_operations ntfs_empty_inode_ops = {};
54478 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54479 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54480 index a9f78c7..ed8a381 100644
54481 --- a/fs/ocfs2/localalloc.c
54482 +++ b/fs/ocfs2/localalloc.c
54483 @@ -1279,7 +1279,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54484 goto bail;
54485 }
54486
54487 - atomic_inc(&osb->alloc_stats.moves);
54488 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54489
54490 bail:
54491 if (handle)
54492 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54493 index d355e6e..578d905 100644
54494 --- a/fs/ocfs2/ocfs2.h
54495 +++ b/fs/ocfs2/ocfs2.h
54496 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54497
54498 struct ocfs2_alloc_stats
54499 {
54500 - atomic_t moves;
54501 - atomic_t local_data;
54502 - atomic_t bitmap_data;
54503 - atomic_t bg_allocs;
54504 - atomic_t bg_extends;
54505 + atomic_unchecked_t moves;
54506 + atomic_unchecked_t local_data;
54507 + atomic_unchecked_t bitmap_data;
54508 + atomic_unchecked_t bg_allocs;
54509 + atomic_unchecked_t bg_extends;
54510 };
54511
54512 enum ocfs2_local_alloc_state
54513 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54514 index b7e74b5..19c6536 100644
54515 --- a/fs/ocfs2/suballoc.c
54516 +++ b/fs/ocfs2/suballoc.c
54517 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54518 mlog_errno(status);
54519 goto bail;
54520 }
54521 - atomic_inc(&osb->alloc_stats.bg_extends);
54522 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54523
54524 /* You should never ask for this much metadata */
54525 BUG_ON(bits_wanted >
54526 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54527 mlog_errno(status);
54528 goto bail;
54529 }
54530 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54531 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54532
54533 *suballoc_loc = res.sr_bg_blkno;
54534 *suballoc_bit_start = res.sr_bit_offset;
54535 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54536 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54537 res->sr_bits);
54538
54539 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54540 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54541
54542 BUG_ON(res->sr_bits != 1);
54543
54544 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54545 mlog_errno(status);
54546 goto bail;
54547 }
54548 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54549 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54550
54551 BUG_ON(res.sr_bits != 1);
54552
54553 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54554 cluster_start,
54555 num_clusters);
54556 if (!status)
54557 - atomic_inc(&osb->alloc_stats.local_data);
54558 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54559 } else {
54560 if (min_clusters > (osb->bitmap_cpg - 1)) {
54561 /* The only paths asking for contiguousness
54562 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54563 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54564 res.sr_bg_blkno,
54565 res.sr_bit_offset);
54566 - atomic_inc(&osb->alloc_stats.bitmap_data);
54567 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54568 *num_clusters = res.sr_bits;
54569 }
54570 }
54571 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54572 index 0e91ec2..f4b3fc6 100644
54573 --- a/fs/ocfs2/super.c
54574 +++ b/fs/ocfs2/super.c
54575 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54576 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54577 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54578 "Stats",
54579 - atomic_read(&osb->alloc_stats.bitmap_data),
54580 - atomic_read(&osb->alloc_stats.local_data),
54581 - atomic_read(&osb->alloc_stats.bg_allocs),
54582 - atomic_read(&osb->alloc_stats.moves),
54583 - atomic_read(&osb->alloc_stats.bg_extends));
54584 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54585 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54586 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54587 + atomic_read_unchecked(&osb->alloc_stats.moves),
54588 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54589
54590 out += snprintf(buf + out, len - out,
54591 "%10s => State: %u Descriptor: %llu Size: %u bits "
54592 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54593 spin_lock_init(&osb->osb_xattr_lock);
54594 ocfs2_init_steal_slots(osb);
54595
54596 - atomic_set(&osb->alloc_stats.moves, 0);
54597 - atomic_set(&osb->alloc_stats.local_data, 0);
54598 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54599 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54600 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54601 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54602 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54603 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54604 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54605 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54606
54607 /* Copy the blockcheck stats from the superblock probe */
54608 osb->osb_ecc_stats = *stats;
54609 diff --git a/fs/open.c b/fs/open.c
54610 index 9b33c0c..2ffcca2 100644
54611 --- a/fs/open.c
54612 +++ b/fs/open.c
54613 @@ -31,6 +31,8 @@
54614 #include <linux/ima.h>
54615 #include <linux/dnotify.h>
54616
54617 +#define CREATE_TRACE_POINTS
54618 +#include <trace/events/fs.h>
54619 #include "internal.h"
54620
54621 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54622 @@ -101,6 +103,8 @@ long vfs_truncate(struct path *path, loff_t length)
54623 error = locks_verify_truncate(inode, NULL, length);
54624 if (!error)
54625 error = security_path_truncate(path);
54626 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54627 + error = -EACCES;
54628 if (!error)
54629 error = do_truncate(path->dentry, length, 0, NULL);
54630
54631 @@ -178,6 +182,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54632 error = locks_verify_truncate(inode, f.file, length);
54633 if (!error)
54634 error = security_path_truncate(&f.file->f_path);
54635 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54636 + error = -EACCES;
54637 if (!error)
54638 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54639 sb_end_write(inode->i_sb);
54640 @@ -373,6 +379,9 @@ retry:
54641 if (__mnt_is_readonly(path.mnt))
54642 res = -EROFS;
54643
54644 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54645 + res = -EACCES;
54646 +
54647 out_path_release:
54648 path_put(&path);
54649 if (retry_estale(res, lookup_flags)) {
54650 @@ -404,6 +413,8 @@ retry:
54651 if (error)
54652 goto dput_and_out;
54653
54654 + gr_log_chdir(path.dentry, path.mnt);
54655 +
54656 set_fs_pwd(current->fs, &path);
54657
54658 dput_and_out:
54659 @@ -433,6 +444,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54660 goto out_putf;
54661
54662 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54663 +
54664 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54665 + error = -EPERM;
54666 +
54667 + if (!error)
54668 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54669 +
54670 if (!error)
54671 set_fs_pwd(current->fs, &f.file->f_path);
54672 out_putf:
54673 @@ -462,7 +480,13 @@ retry:
54674 if (error)
54675 goto dput_and_out;
54676
54677 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54678 + goto dput_and_out;
54679 +
54680 set_fs_root(current->fs, &path);
54681 +
54682 + gr_handle_chroot_chdir(&path);
54683 +
54684 error = 0;
54685 dput_and_out:
54686 path_put(&path);
54687 @@ -484,6 +508,16 @@ static int chmod_common(struct path *path, umode_t mode)
54688 if (error)
54689 return error;
54690 mutex_lock(&inode->i_mutex);
54691 +
54692 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54693 + error = -EACCES;
54694 + goto out_unlock;
54695 + }
54696 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54697 + error = -EACCES;
54698 + goto out_unlock;
54699 + }
54700 +
54701 error = security_path_chmod(path, mode);
54702 if (error)
54703 goto out_unlock;
54704 @@ -544,6 +578,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54705 uid = make_kuid(current_user_ns(), user);
54706 gid = make_kgid(current_user_ns(), group);
54707
54708 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54709 + return -EACCES;
54710 +
54711 newattrs.ia_valid = ATTR_CTIME;
54712 if (user != (uid_t) -1) {
54713 if (!uid_valid(uid))
54714 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54715 } else {
54716 fsnotify_open(f);
54717 fd_install(fd, f);
54718 + trace_do_sys_open(tmp->name, flags, mode);
54719 }
54720 }
54721 putname(tmp);
54722 diff --git a/fs/pipe.c b/fs/pipe.c
54723 index 8e2e73f..1ef1048 100644
54724 --- a/fs/pipe.c
54725 +++ b/fs/pipe.c
54726 @@ -438,9 +438,9 @@ redo:
54727 }
54728 if (bufs) /* More to do? */
54729 continue;
54730 - if (!pipe->writers)
54731 + if (!atomic_read(&pipe->writers))
54732 break;
54733 - if (!pipe->waiting_writers) {
54734 + if (!atomic_read(&pipe->waiting_writers)) {
54735 /* syscall merging: Usually we must not sleep
54736 * if O_NONBLOCK is set, or if we got some data.
54737 * But if a writer sleeps in kernel space, then
54738 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54739 mutex_lock(&inode->i_mutex);
54740 pipe = inode->i_pipe;
54741
54742 - if (!pipe->readers) {
54743 + if (!atomic_read(&pipe->readers)) {
54744 send_sig(SIGPIPE, current, 0);
54745 ret = -EPIPE;
54746 goto out;
54747 @@ -553,7 +553,7 @@ redo1:
54748 for (;;) {
54749 int bufs;
54750
54751 - if (!pipe->readers) {
54752 + if (!atomic_read(&pipe->readers)) {
54753 send_sig(SIGPIPE, current, 0);
54754 if (!ret)
54755 ret = -EPIPE;
54756 @@ -644,9 +644,9 @@ redo2:
54757 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54758 do_wakeup = 0;
54759 }
54760 - pipe->waiting_writers++;
54761 + atomic_inc(&pipe->waiting_writers);
54762 pipe_wait(pipe);
54763 - pipe->waiting_writers--;
54764 + atomic_dec(&pipe->waiting_writers);
54765 }
54766 out:
54767 mutex_unlock(&inode->i_mutex);
54768 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54769 mask = 0;
54770 if (filp->f_mode & FMODE_READ) {
54771 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54772 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54773 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54774 mask |= POLLHUP;
54775 }
54776
54777 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54778 * Most Unices do not set POLLERR for FIFOs but on Linux they
54779 * behave exactly like pipes for poll().
54780 */
54781 - if (!pipe->readers)
54782 + if (!atomic_read(&pipe->readers))
54783 mask |= POLLERR;
54784 }
54785
54786 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54787
54788 mutex_lock(&inode->i_mutex);
54789 pipe = inode->i_pipe;
54790 - pipe->readers -= decr;
54791 - pipe->writers -= decw;
54792 + atomic_sub(decr, &pipe->readers);
54793 + atomic_sub(decw, &pipe->writers);
54794
54795 - if (!pipe->readers && !pipe->writers) {
54796 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54797 free_pipe_info(inode);
54798 } else {
54799 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54800 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54801
54802 if (inode->i_pipe) {
54803 ret = 0;
54804 - inode->i_pipe->readers++;
54805 + atomic_inc(&inode->i_pipe->readers);
54806 }
54807
54808 mutex_unlock(&inode->i_mutex);
54809 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54810
54811 if (inode->i_pipe) {
54812 ret = 0;
54813 - inode->i_pipe->writers++;
54814 + atomic_inc(&inode->i_pipe->writers);
54815 }
54816
54817 mutex_unlock(&inode->i_mutex);
54818 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54819 if (inode->i_pipe) {
54820 ret = 0;
54821 if (filp->f_mode & FMODE_READ)
54822 - inode->i_pipe->readers++;
54823 + atomic_inc(&inode->i_pipe->readers);
54824 if (filp->f_mode & FMODE_WRITE)
54825 - inode->i_pipe->writers++;
54826 + atomic_inc(&inode->i_pipe->writers);
54827 }
54828
54829 mutex_unlock(&inode->i_mutex);
54830 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54831 inode->i_pipe = NULL;
54832 }
54833
54834 -static struct vfsmount *pipe_mnt __read_mostly;
54835 +struct vfsmount *pipe_mnt __read_mostly;
54836
54837 /*
54838 * pipefs_dname() is called from d_path().
54839 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54840 goto fail_iput;
54841 inode->i_pipe = pipe;
54842
54843 - pipe->readers = pipe->writers = 1;
54844 + atomic_set(&pipe->readers, 1);
54845 + atomic_set(&pipe->writers, 1);
54846 inode->i_fop = &rdwr_pipefifo_fops;
54847
54848 /*
54849 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54850 index 15af622..0e9f4467 100644
54851 --- a/fs/proc/Kconfig
54852 +++ b/fs/proc/Kconfig
54853 @@ -30,12 +30,12 @@ config PROC_FS
54854
54855 config PROC_KCORE
54856 bool "/proc/kcore support" if !ARM
54857 - depends on PROC_FS && MMU
54858 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54859
54860 config PROC_VMCORE
54861 bool "/proc/vmcore support"
54862 - depends on PROC_FS && CRASH_DUMP
54863 - default y
54864 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54865 + default n
54866 help
54867 Exports the dump image of crashed kernel in ELF format.
54868
54869 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54870 limited in memory.
54871
54872 config PROC_PAGE_MONITOR
54873 - default y
54874 - depends on PROC_FS && MMU
54875 + default n
54876 + depends on PROC_FS && MMU && !GRKERNSEC
54877 bool "Enable /proc page monitoring" if EXPERT
54878 help
54879 Various /proc files exist to monitor process memory utilization:
54880 diff --git a/fs/proc/array.c b/fs/proc/array.c
54881 index 6a91e6f..e54dbc14 100644
54882 --- a/fs/proc/array.c
54883 +++ b/fs/proc/array.c
54884 @@ -60,6 +60,7 @@
54885 #include <linux/tty.h>
54886 #include <linux/string.h>
54887 #include <linux/mman.h>
54888 +#include <linux/grsecurity.h>
54889 #include <linux/proc_fs.h>
54890 #include <linux/ioport.h>
54891 #include <linux/uaccess.h>
54892 @@ -362,6 +363,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54893 seq_putc(m, '\n');
54894 }
54895
54896 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54897 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54898 +{
54899 + if (p->mm)
54900 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54901 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54902 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54903 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54904 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54905 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54906 + else
54907 + seq_printf(m, "PaX:\t-----\n");
54908 +}
54909 +#endif
54910 +
54911 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54912 struct pid *pid, struct task_struct *task)
54913 {
54914 @@ -380,9 +396,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54915 task_cpus_allowed(m, task);
54916 cpuset_task_status_allowed(m, task);
54917 task_context_switch_counts(m, task);
54918 +
54919 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54920 + task_pax(m, task);
54921 +#endif
54922 +
54923 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54924 + task_grsec_rbac(m, task);
54925 +#endif
54926 +
54927 return 0;
54928 }
54929
54930 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54931 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54932 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54933 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54934 +#endif
54935 +
54936 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54937 struct pid *pid, struct task_struct *task, int whole)
54938 {
54939 @@ -404,6 +435,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54940 char tcomm[sizeof(task->comm)];
54941 unsigned long flags;
54942
54943 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54944 + if (current->exec_id != m->exec_id) {
54945 + gr_log_badprocpid("stat");
54946 + return 0;
54947 + }
54948 +#endif
54949 +
54950 state = *get_task_state(task);
54951 vsize = eip = esp = 0;
54952 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54953 @@ -475,6 +513,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54954 gtime = task->gtime;
54955 }
54956
54957 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54958 + if (PAX_RAND_FLAGS(mm)) {
54959 + eip = 0;
54960 + esp = 0;
54961 + wchan = 0;
54962 + }
54963 +#endif
54964 +#ifdef CONFIG_GRKERNSEC_HIDESYM
54965 + wchan = 0;
54966 + eip =0;
54967 + esp =0;
54968 +#endif
54969 +
54970 /* scale priority and nice values from timeslices to -20..20 */
54971 /* to make it look like a "normal" Unix priority/nice value */
54972 priority = task_prio(task);
54973 @@ -511,9 +562,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54974 seq_put_decimal_ull(m, ' ', vsize);
54975 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
54976 seq_put_decimal_ull(m, ' ', rsslim);
54977 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54978 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
54979 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
54980 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
54981 +#else
54982 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
54983 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
54984 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
54985 +#endif
54986 seq_put_decimal_ull(m, ' ', esp);
54987 seq_put_decimal_ull(m, ' ', eip);
54988 /* The signal information here is obsolete.
54989 @@ -535,7 +592,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54990 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
54991 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
54992
54993 - if (mm && permitted) {
54994 + if (mm && permitted
54995 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54996 + && !PAX_RAND_FLAGS(mm)
54997 +#endif
54998 + ) {
54999 seq_put_decimal_ull(m, ' ', mm->start_data);
55000 seq_put_decimal_ull(m, ' ', mm->end_data);
55001 seq_put_decimal_ull(m, ' ', mm->start_brk);
55002 @@ -573,8 +634,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55003 struct pid *pid, struct task_struct *task)
55004 {
55005 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
55006 - struct mm_struct *mm = get_task_mm(task);
55007 + struct mm_struct *mm;
55008
55009 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55010 + if (current->exec_id != m->exec_id) {
55011 + gr_log_badprocpid("statm");
55012 + return 0;
55013 + }
55014 +#endif
55015 + mm = get_task_mm(task);
55016 if (mm) {
55017 size = task_statm(mm, &shared, &text, &data, &resident);
55018 mmput(mm);
55019 @@ -597,6 +665,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55020 return 0;
55021 }
55022
55023 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55024 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55025 +{
55026 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55027 +}
55028 +#endif
55029 +
55030 #ifdef CONFIG_CHECKPOINT_RESTORE
55031 static struct pid *
55032 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55033 diff --git a/fs/proc/base.c b/fs/proc/base.c
55034 index 9b43ff77..0fa9564 100644
55035 --- a/fs/proc/base.c
55036 +++ b/fs/proc/base.c
55037 @@ -111,6 +111,14 @@ struct pid_entry {
55038 union proc_op op;
55039 };
55040
55041 +struct getdents_callback {
55042 + struct linux_dirent __user * current_dir;
55043 + struct linux_dirent __user * previous;
55044 + struct file * file;
55045 + int count;
55046 + int error;
55047 +};
55048 +
55049 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55050 .name = (NAME), \
55051 .len = sizeof(NAME) - 1, \
55052 @@ -208,6 +216,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55053 if (!mm->arg_end)
55054 goto out_mm; /* Shh! No looking before we're done */
55055
55056 + if (gr_acl_handle_procpidmem(task))
55057 + goto out_mm;
55058 +
55059 len = mm->arg_end - mm->arg_start;
55060
55061 if (len > PAGE_SIZE)
55062 @@ -235,12 +246,28 @@ out:
55063 return res;
55064 }
55065
55066 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55067 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55068 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55069 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55070 +#endif
55071 +
55072 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55073 {
55074 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55075 int res = PTR_ERR(mm);
55076 if (mm && !IS_ERR(mm)) {
55077 unsigned int nwords = 0;
55078 +
55079 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55080 + /* allow if we're currently ptracing this task */
55081 + if (PAX_RAND_FLAGS(mm) &&
55082 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55083 + mmput(mm);
55084 + return 0;
55085 + }
55086 +#endif
55087 +
55088 do {
55089 nwords += 2;
55090 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55091 @@ -254,7 +281,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55092 }
55093
55094
55095 -#ifdef CONFIG_KALLSYMS
55096 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55097 /*
55098 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55099 * Returns the resolved symbol. If that fails, simply return the address.
55100 @@ -293,7 +320,7 @@ static void unlock_trace(struct task_struct *task)
55101 mutex_unlock(&task->signal->cred_guard_mutex);
55102 }
55103
55104 -#ifdef CONFIG_STACKTRACE
55105 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55106
55107 #define MAX_STACK_TRACE_DEPTH 64
55108
55109 @@ -485,7 +512,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55110 return count;
55111 }
55112
55113 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55114 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55115 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55116 {
55117 long nr;
55118 @@ -514,7 +541,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55119 /************************************************************************/
55120
55121 /* permission checks */
55122 -static int proc_fd_access_allowed(struct inode *inode)
55123 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55124 {
55125 struct task_struct *task;
55126 int allowed = 0;
55127 @@ -524,7 +551,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55128 */
55129 task = get_proc_task(inode);
55130 if (task) {
55131 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55132 + if (log)
55133 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55134 + else
55135 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55136 put_task_struct(task);
55137 }
55138 return allowed;
55139 @@ -555,10 +585,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55140 struct task_struct *task,
55141 int hide_pid_min)
55142 {
55143 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55144 + return false;
55145 +
55146 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55147 + rcu_read_lock();
55148 + {
55149 + const struct cred *tmpcred = current_cred();
55150 + const struct cred *cred = __task_cred(task);
55151 +
55152 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55153 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55154 + || in_group_p(grsec_proc_gid)
55155 +#endif
55156 + ) {
55157 + rcu_read_unlock();
55158 + return true;
55159 + }
55160 + }
55161 + rcu_read_unlock();
55162 +
55163 + if (!pid->hide_pid)
55164 + return false;
55165 +#endif
55166 +
55167 if (pid->hide_pid < hide_pid_min)
55168 return true;
55169 if (in_group_p(pid->pid_gid))
55170 return true;
55171 +
55172 return ptrace_may_access(task, PTRACE_MODE_READ);
55173 }
55174
55175 @@ -576,7 +631,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55176 put_task_struct(task);
55177
55178 if (!has_perms) {
55179 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55180 + {
55181 +#else
55182 if (pid->hide_pid == 2) {
55183 +#endif
55184 /*
55185 * Let's make getdents(), stat(), and open()
55186 * consistent with each other. If a process
55187 @@ -674,6 +733,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55188 if (!task)
55189 return -ESRCH;
55190
55191 + if (gr_acl_handle_procpidmem(task)) {
55192 + put_task_struct(task);
55193 + return -EPERM;
55194 + }
55195 +
55196 mm = mm_access(task, mode);
55197 put_task_struct(task);
55198
55199 @@ -689,6 +753,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55200
55201 file->private_data = mm;
55202
55203 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55204 + file->f_version = current->exec_id;
55205 +#endif
55206 +
55207 return 0;
55208 }
55209
55210 @@ -710,6 +778,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55211 ssize_t copied;
55212 char *page;
55213
55214 +#ifdef CONFIG_GRKERNSEC
55215 + if (write)
55216 + return -EPERM;
55217 +#endif
55218 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55219 + if (file->f_version != current->exec_id) {
55220 + gr_log_badprocpid("mem");
55221 + return 0;
55222 + }
55223 +#endif
55224 +
55225 if (!mm)
55226 return 0;
55227
55228 @@ -722,7 +801,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55229 goto free;
55230
55231 while (count > 0) {
55232 - int this_len = min_t(int, count, PAGE_SIZE);
55233 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55234
55235 if (write && copy_from_user(page, buf, this_len)) {
55236 copied = -EFAULT;
55237 @@ -814,6 +893,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55238 if (!mm)
55239 return 0;
55240
55241 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55242 + if (file->f_version != current->exec_id) {
55243 + gr_log_badprocpid("environ");
55244 + return 0;
55245 + }
55246 +#endif
55247 +
55248 page = (char *)__get_free_page(GFP_TEMPORARY);
55249 if (!page)
55250 return -ENOMEM;
55251 @@ -823,7 +909,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55252 goto free;
55253 while (count > 0) {
55254 size_t this_len, max_len;
55255 - int retval;
55256 + ssize_t retval;
55257
55258 if (src >= (mm->env_end - mm->env_start))
55259 break;
55260 @@ -1429,7 +1515,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55261 int error = -EACCES;
55262
55263 /* Are we allowed to snoop on the tasks file descriptors? */
55264 - if (!proc_fd_access_allowed(inode))
55265 + if (!proc_fd_access_allowed(inode, 0))
55266 goto out;
55267
55268 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55269 @@ -1473,8 +1559,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55270 struct path path;
55271
55272 /* Are we allowed to snoop on the tasks file descriptors? */
55273 - if (!proc_fd_access_allowed(inode))
55274 - goto out;
55275 + /* logging this is needed for learning on chromium to work properly,
55276 + but we don't want to flood the logs from 'ps' which does a readlink
55277 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55278 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55279 + */
55280 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55281 + if (!proc_fd_access_allowed(inode,0))
55282 + goto out;
55283 + } else {
55284 + if (!proc_fd_access_allowed(inode,1))
55285 + goto out;
55286 + }
55287
55288 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55289 if (error)
55290 @@ -1524,7 +1620,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55291 rcu_read_lock();
55292 cred = __task_cred(task);
55293 inode->i_uid = cred->euid;
55294 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55295 + inode->i_gid = grsec_proc_gid;
55296 +#else
55297 inode->i_gid = cred->egid;
55298 +#endif
55299 rcu_read_unlock();
55300 }
55301 security_task_to_inode(task, inode);
55302 @@ -1560,10 +1660,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55303 return -ENOENT;
55304 }
55305 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55306 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55307 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55308 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55309 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55310 +#endif
55311 task_dumpable(task)) {
55312 cred = __task_cred(task);
55313 stat->uid = cred->euid;
55314 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55315 + stat->gid = grsec_proc_gid;
55316 +#else
55317 stat->gid = cred->egid;
55318 +#endif
55319 }
55320 }
55321 rcu_read_unlock();
55322 @@ -1601,11 +1710,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55323
55324 if (task) {
55325 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55326 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55327 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55328 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55329 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55330 +#endif
55331 task_dumpable(task)) {
55332 rcu_read_lock();
55333 cred = __task_cred(task);
55334 inode->i_uid = cred->euid;
55335 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55336 + inode->i_gid = grsec_proc_gid;
55337 +#else
55338 inode->i_gid = cred->egid;
55339 +#endif
55340 rcu_read_unlock();
55341 } else {
55342 inode->i_uid = GLOBAL_ROOT_UID;
55343 @@ -2058,6 +2176,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55344 if (!task)
55345 goto out_no_task;
55346
55347 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55348 + goto out;
55349 +
55350 /*
55351 * Yes, it does not scale. And it should not. Don't add
55352 * new entries into /proc/<tgid>/ without very good reasons.
55353 @@ -2102,6 +2223,9 @@ static int proc_pident_readdir(struct file *filp,
55354 if (!task)
55355 goto out_no_task;
55356
55357 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55358 + goto out;
55359 +
55360 ret = 0;
55361 i = filp->f_pos;
55362 switch (i) {
55363 @@ -2515,7 +2639,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55364 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55365 #endif
55366 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55367 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55368 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55369 INF("syscall", S_IRUGO, proc_pid_syscall),
55370 #endif
55371 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55372 @@ -2540,10 +2664,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55373 #ifdef CONFIG_SECURITY
55374 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55375 #endif
55376 -#ifdef CONFIG_KALLSYMS
55377 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55378 INF("wchan", S_IRUGO, proc_pid_wchan),
55379 #endif
55380 -#ifdef CONFIG_STACKTRACE
55381 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55382 ONE("stack", S_IRUGO, proc_pid_stack),
55383 #endif
55384 #ifdef CONFIG_SCHEDSTATS
55385 @@ -2577,6 +2701,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55386 #ifdef CONFIG_HARDWALL
55387 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55388 #endif
55389 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55390 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55391 +#endif
55392 #ifdef CONFIG_USER_NS
55393 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55394 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55395 @@ -2705,7 +2832,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55396 if (!inode)
55397 goto out;
55398
55399 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55400 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55401 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55402 + inode->i_gid = grsec_proc_gid;
55403 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55404 +#else
55405 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55406 +#endif
55407 inode->i_op = &proc_tgid_base_inode_operations;
55408 inode->i_fop = &proc_tgid_base_operations;
55409 inode->i_flags|=S_IMMUTABLE;
55410 @@ -2743,7 +2877,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55411 if (!task)
55412 goto out;
55413
55414 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55415 + goto out_put_task;
55416 +
55417 result = proc_pid_instantiate(dir, dentry, task, NULL);
55418 +out_put_task:
55419 put_task_struct(task);
55420 out:
55421 return result;
55422 @@ -2806,6 +2944,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55423 static int fake_filldir(void *buf, const char *name, int namelen,
55424 loff_t offset, u64 ino, unsigned d_type)
55425 {
55426 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55427 + __buf->error = -EINVAL;
55428 return 0;
55429 }
55430
55431 @@ -2857,7 +2997,7 @@ static const struct pid_entry tid_base_stuff[] = {
55432 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55433 #endif
55434 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55435 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55436 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55437 INF("syscall", S_IRUGO, proc_pid_syscall),
55438 #endif
55439 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55440 @@ -2884,10 +3024,10 @@ static const struct pid_entry tid_base_stuff[] = {
55441 #ifdef CONFIG_SECURITY
55442 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55443 #endif
55444 -#ifdef CONFIG_KALLSYMS
55445 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55446 INF("wchan", S_IRUGO, proc_pid_wchan),
55447 #endif
55448 -#ifdef CONFIG_STACKTRACE
55449 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55450 ONE("stack", S_IRUGO, proc_pid_stack),
55451 #endif
55452 #ifdef CONFIG_SCHEDSTATS
55453 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55454 index 82676e3..5f8518a 100644
55455 --- a/fs/proc/cmdline.c
55456 +++ b/fs/proc/cmdline.c
55457 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55458
55459 static int __init proc_cmdline_init(void)
55460 {
55461 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55462 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55463 +#else
55464 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55465 +#endif
55466 return 0;
55467 }
55468 module_init(proc_cmdline_init);
55469 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55470 index b143471..bb105e5 100644
55471 --- a/fs/proc/devices.c
55472 +++ b/fs/proc/devices.c
55473 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55474
55475 static int __init proc_devices_init(void)
55476 {
55477 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55478 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55479 +#else
55480 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55481 +#endif
55482 return 0;
55483 }
55484 module_init(proc_devices_init);
55485 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55486 index d7a4a28..0201742 100644
55487 --- a/fs/proc/fd.c
55488 +++ b/fs/proc/fd.c
55489 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55490 if (!task)
55491 return -ENOENT;
55492
55493 - files = get_files_struct(task);
55494 + if (!gr_acl_handle_procpidmem(task))
55495 + files = get_files_struct(task);
55496 put_task_struct(task);
55497
55498 if (files) {
55499 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55500 */
55501 int proc_fd_permission(struct inode *inode, int mask)
55502 {
55503 + struct task_struct *task;
55504 int rv = generic_permission(inode, mask);
55505 - if (rv == 0)
55506 - return 0;
55507 +
55508 if (task_pid(current) == proc_pid(inode))
55509 rv = 0;
55510 +
55511 + task = get_proc_task(inode);
55512 + if (task == NULL)
55513 + return rv;
55514 +
55515 + if (gr_acl_handle_procpidmem(task))
55516 + rv = -EACCES;
55517 +
55518 + put_task_struct(task);
55519 +
55520 return rv;
55521 }
55522
55523 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55524 index 0ac1e1b..0497e58 100644
55525 --- a/fs/proc/inode.c
55526 +++ b/fs/proc/inode.c
55527 @@ -21,11 +21,17 @@
55528 #include <linux/seq_file.h>
55529 #include <linux/slab.h>
55530 #include <linux/mount.h>
55531 +#include <linux/grsecurity.h>
55532
55533 #include <asm/uaccess.h>
55534
55535 #include "internal.h"
55536
55537 +#ifdef CONFIG_PROC_SYSCTL
55538 +extern const struct inode_operations proc_sys_inode_operations;
55539 +extern const struct inode_operations proc_sys_dir_operations;
55540 +#endif
55541 +
55542 static void proc_evict_inode(struct inode *inode)
55543 {
55544 struct proc_dir_entry *de;
55545 @@ -53,6 +59,13 @@ static void proc_evict_inode(struct inode *inode)
55546 ns = PROC_I(inode)->ns;
55547 if (ns_ops && ns)
55548 ns_ops->put(ns);
55549 +
55550 +#ifdef CONFIG_PROC_SYSCTL
55551 + if (inode->i_op == &proc_sys_inode_operations ||
55552 + inode->i_op == &proc_sys_dir_operations)
55553 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55554 +#endif
55555 +
55556 }
55557
55558 static struct kmem_cache * proc_inode_cachep;
55559 @@ -455,7 +468,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55560 if (de->mode) {
55561 inode->i_mode = de->mode;
55562 inode->i_uid = de->uid;
55563 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55564 + inode->i_gid = grsec_proc_gid;
55565 +#else
55566 inode->i_gid = de->gid;
55567 +#endif
55568 }
55569 if (de->size)
55570 inode->i_size = de->size;
55571 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55572 index 252544c..04395b9 100644
55573 --- a/fs/proc/internal.h
55574 +++ b/fs/proc/internal.h
55575 @@ -55,6 +55,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55576 struct pid *pid, struct task_struct *task);
55577 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55578 struct pid *pid, struct task_struct *task);
55579 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55580 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55581 +#endif
55582 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55583
55584 extern const struct file_operations proc_tid_children_operations;
55585 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55586 index e96d4f1..8b116ed 100644
55587 --- a/fs/proc/kcore.c
55588 +++ b/fs/proc/kcore.c
55589 @@ -480,9 +480,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55590 * the addresses in the elf_phdr on our list.
55591 */
55592 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55593 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55594 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55595 + if (tsz > buflen)
55596 tsz = buflen;
55597 -
55598 +
55599 while (buflen) {
55600 struct kcore_list *m;
55601
55602 @@ -511,20 +512,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55603 kfree(elf_buf);
55604 } else {
55605 if (kern_addr_valid(start)) {
55606 - unsigned long n;
55607 + char *elf_buf;
55608 + mm_segment_t oldfs;
55609
55610 - n = copy_to_user(buffer, (char *)start, tsz);
55611 - /*
55612 - * We cannot distinguish between fault on source
55613 - * and fault on destination. When this happens
55614 - * we clear too and hope it will trigger the
55615 - * EFAULT again.
55616 - */
55617 - if (n) {
55618 - if (clear_user(buffer + tsz - n,
55619 - n))
55620 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55621 + if (!elf_buf)
55622 + return -ENOMEM;
55623 + oldfs = get_fs();
55624 + set_fs(KERNEL_DS);
55625 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55626 + set_fs(oldfs);
55627 + if (copy_to_user(buffer, elf_buf, tsz)) {
55628 + kfree(elf_buf);
55629 return -EFAULT;
55630 + }
55631 }
55632 + set_fs(oldfs);
55633 + kfree(elf_buf);
55634 } else {
55635 if (clear_user(buffer, tsz))
55636 return -EFAULT;
55637 @@ -544,6 +548,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55638
55639 static int open_kcore(struct inode *inode, struct file *filp)
55640 {
55641 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55642 + return -EPERM;
55643 +#endif
55644 if (!capable(CAP_SYS_RAWIO))
55645 return -EPERM;
55646 if (kcore_need_update)
55647 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55648 index 80e4645..53e5fcf 100644
55649 --- a/fs/proc/meminfo.c
55650 +++ b/fs/proc/meminfo.c
55651 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55652 vmi.used >> 10,
55653 vmi.largest_chunk >> 10
55654 #ifdef CONFIG_MEMORY_FAILURE
55655 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
55656 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
55657 #endif
55658 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55659 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55660 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55661 index b1822dd..df622cb 100644
55662 --- a/fs/proc/nommu.c
55663 +++ b/fs/proc/nommu.c
55664 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55665 if (len < 1)
55666 len = 1;
55667 seq_printf(m, "%*c", len, ' ');
55668 - seq_path(m, &file->f_path, "");
55669 + seq_path(m, &file->f_path, "\n\\");
55670 }
55671
55672 seq_putc(m, '\n');
55673 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55674 index fe72cd0..21b52ff 100644
55675 --- a/fs/proc/proc_net.c
55676 +++ b/fs/proc/proc_net.c
55677 @@ -23,6 +23,7 @@
55678 #include <linux/nsproxy.h>
55679 #include <net/net_namespace.h>
55680 #include <linux/seq_file.h>
55681 +#include <linux/grsecurity.h>
55682
55683 #include "internal.h"
55684
55685 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55686 struct task_struct *task;
55687 struct nsproxy *ns;
55688 struct net *net = NULL;
55689 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55690 + const struct cred *cred = current_cred();
55691 +#endif
55692 +
55693 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55694 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55695 + return net;
55696 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55697 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55698 + return net;
55699 +#endif
55700
55701 rcu_read_lock();
55702 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55703 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55704 index 1827d88..43b0279 100644
55705 --- a/fs/proc/proc_sysctl.c
55706 +++ b/fs/proc/proc_sysctl.c
55707 @@ -12,11 +12,15 @@
55708 #include <linux/module.h>
55709 #include "internal.h"
55710
55711 +extern int gr_handle_chroot_sysctl(const int op);
55712 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55713 + const int op);
55714 +
55715 static const struct dentry_operations proc_sys_dentry_operations;
55716 static const struct file_operations proc_sys_file_operations;
55717 -static const struct inode_operations proc_sys_inode_operations;
55718 +const struct inode_operations proc_sys_inode_operations;
55719 static const struct file_operations proc_sys_dir_file_operations;
55720 -static const struct inode_operations proc_sys_dir_operations;
55721 +const struct inode_operations proc_sys_dir_operations;
55722
55723 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55724 {
55725 @@ -466,6 +470,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55726
55727 err = NULL;
55728 d_set_d_op(dentry, &proc_sys_dentry_operations);
55729 +
55730 + gr_handle_proc_create(dentry, inode);
55731 +
55732 d_add(dentry, inode);
55733
55734 out:
55735 @@ -481,6 +488,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55736 struct inode *inode = filp->f_path.dentry->d_inode;
55737 struct ctl_table_header *head = grab_header(inode);
55738 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55739 + int op = write ? MAY_WRITE : MAY_READ;
55740 ssize_t error;
55741 size_t res;
55742
55743 @@ -492,7 +500,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55744 * and won't be until we finish.
55745 */
55746 error = -EPERM;
55747 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55748 + if (sysctl_perm(head, table, op))
55749 goto out;
55750
55751 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55752 @@ -500,6 +508,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55753 if (!table->proc_handler)
55754 goto out;
55755
55756 +#ifdef CONFIG_GRKERNSEC
55757 + error = -EPERM;
55758 + if (gr_handle_chroot_sysctl(op))
55759 + goto out;
55760 + dget(filp->f_path.dentry);
55761 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55762 + dput(filp->f_path.dentry);
55763 + goto out;
55764 + }
55765 + dput(filp->f_path.dentry);
55766 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55767 + goto out;
55768 + if (write && !capable(CAP_SYS_ADMIN))
55769 + goto out;
55770 +#endif
55771 +
55772 /* careful: calling conventions are nasty here */
55773 res = count;
55774 error = table->proc_handler(table, write, buf, &res, ppos);
55775 @@ -597,6 +621,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55776 return -ENOMEM;
55777 } else {
55778 d_set_d_op(child, &proc_sys_dentry_operations);
55779 +
55780 + gr_handle_proc_create(child, inode);
55781 +
55782 d_add(child, inode);
55783 }
55784 } else {
55785 @@ -640,6 +667,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55786 if ((*pos)++ < file->f_pos)
55787 return 0;
55788
55789 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55790 + return 0;
55791 +
55792 if (unlikely(S_ISLNK(table->mode)))
55793 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55794 else
55795 @@ -750,6 +780,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55796 if (IS_ERR(head))
55797 return PTR_ERR(head);
55798
55799 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55800 + return -ENOENT;
55801 +
55802 generic_fillattr(inode, stat);
55803 if (table)
55804 stat->mode = (stat->mode & S_IFMT) | table->mode;
55805 @@ -772,13 +805,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55806 .llseek = generic_file_llseek,
55807 };
55808
55809 -static const struct inode_operations proc_sys_inode_operations = {
55810 +const struct inode_operations proc_sys_inode_operations = {
55811 .permission = proc_sys_permission,
55812 .setattr = proc_sys_setattr,
55813 .getattr = proc_sys_getattr,
55814 };
55815
55816 -static const struct inode_operations proc_sys_dir_operations = {
55817 +const struct inode_operations proc_sys_dir_operations = {
55818 .lookup = proc_sys_lookup,
55819 .permission = proc_sys_permission,
55820 .setattr = proc_sys_setattr,
55821 @@ -854,7 +887,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55822 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55823 const char *name, int namelen)
55824 {
55825 - struct ctl_table *table;
55826 + ctl_table_no_const *table;
55827 struct ctl_dir *new;
55828 struct ctl_node *node;
55829 char *new_name;
55830 @@ -866,7 +899,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55831 return NULL;
55832
55833 node = (struct ctl_node *)(new + 1);
55834 - table = (struct ctl_table *)(node + 1);
55835 + table = (ctl_table_no_const *)(node + 1);
55836 new_name = (char *)(table + 2);
55837 memcpy(new_name, name, namelen);
55838 new_name[namelen] = '\0';
55839 @@ -1035,7 +1068,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55840 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55841 struct ctl_table_root *link_root)
55842 {
55843 - struct ctl_table *link_table, *entry, *link;
55844 + ctl_table_no_const *link_table, *link;
55845 + struct ctl_table *entry;
55846 struct ctl_table_header *links;
55847 struct ctl_node *node;
55848 char *link_name;
55849 @@ -1058,7 +1092,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55850 return NULL;
55851
55852 node = (struct ctl_node *)(links + 1);
55853 - link_table = (struct ctl_table *)(node + nr_entries);
55854 + link_table = (ctl_table_no_const *)(node + nr_entries);
55855 link_name = (char *)&link_table[nr_entries + 1];
55856
55857 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55858 @@ -1306,8 +1340,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55859 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55860 struct ctl_table *table)
55861 {
55862 - struct ctl_table *ctl_table_arg = NULL;
55863 - struct ctl_table *entry, *files;
55864 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55865 + struct ctl_table *entry;
55866 int nr_files = 0;
55867 int nr_dirs = 0;
55868 int err = -ENOMEM;
55869 @@ -1319,10 +1353,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55870 nr_files++;
55871 }
55872
55873 - files = table;
55874 /* If there are mixed files and directories we need a new table */
55875 if (nr_dirs && nr_files) {
55876 - struct ctl_table *new;
55877 + ctl_table_no_const *new;
55878 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55879 GFP_KERNEL);
55880 if (!files)
55881 @@ -1340,7 +1373,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55882 /* Register everything except a directory full of subdirectories */
55883 if (nr_files || !nr_dirs) {
55884 struct ctl_table_header *header;
55885 - header = __register_sysctl_table(set, path, files);
55886 + header = __register_sysctl_table(set, path, files ? files : table);
55887 if (!header) {
55888 kfree(ctl_table_arg);
55889 goto out;
55890 diff --git a/fs/proc/root.c b/fs/proc/root.c
55891 index 9c7fab1..ed1c8e0 100644
55892 --- a/fs/proc/root.c
55893 +++ b/fs/proc/root.c
55894 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
55895 #ifdef CONFIG_PROC_DEVICETREE
55896 proc_device_tree_init();
55897 #endif
55898 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55899 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55900 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55901 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55902 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55903 +#endif
55904 +#else
55905 proc_mkdir("bus", NULL);
55906 +#endif
55907 proc_sys_init();
55908 }
55909
55910 diff --git a/fs/proc/self.c b/fs/proc/self.c
55911 index aa5cc3b..c91a5d0 100644
55912 --- a/fs/proc/self.c
55913 +++ b/fs/proc/self.c
55914 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55915 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55916 void *cookie)
55917 {
55918 - char *s = nd_get_link(nd);
55919 + const char *s = nd_get_link(nd);
55920 if (!IS_ERR(s))
55921 kfree(s);
55922 }
55923 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55924 index ca5ce7f..02c1cf0 100644
55925 --- a/fs/proc/task_mmu.c
55926 +++ b/fs/proc/task_mmu.c
55927 @@ -11,12 +11,19 @@
55928 #include <linux/rmap.h>
55929 #include <linux/swap.h>
55930 #include <linux/swapops.h>
55931 +#include <linux/grsecurity.h>
55932
55933 #include <asm/elf.h>
55934 #include <asm/uaccess.h>
55935 #include <asm/tlbflush.h>
55936 #include "internal.h"
55937
55938 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55939 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55940 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55941 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55942 +#endif
55943 +
55944 void task_mem(struct seq_file *m, struct mm_struct *mm)
55945 {
55946 unsigned long data, text, lib, swap;
55947 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55948 "VmExe:\t%8lu kB\n"
55949 "VmLib:\t%8lu kB\n"
55950 "VmPTE:\t%8lu kB\n"
55951 - "VmSwap:\t%8lu kB\n",
55952 - hiwater_vm << (PAGE_SHIFT-10),
55953 + "VmSwap:\t%8lu kB\n"
55954 +
55955 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55956 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
55957 +#endif
55958 +
55959 + ,hiwater_vm << (PAGE_SHIFT-10),
55960 total_vm << (PAGE_SHIFT-10),
55961 mm->locked_vm << (PAGE_SHIFT-10),
55962 mm->pinned_vm << (PAGE_SHIFT-10),
55963 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55964 data << (PAGE_SHIFT-10),
55965 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
55966 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
55967 - swap << (PAGE_SHIFT-10));
55968 + swap << (PAGE_SHIFT-10)
55969 +
55970 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
55971 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55972 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
55973 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
55974 +#else
55975 + , mm->context.user_cs_base
55976 + , mm->context.user_cs_limit
55977 +#endif
55978 +#endif
55979 +
55980 + );
55981 }
55982
55983 unsigned long task_vsize(struct mm_struct *mm)
55984 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
55985 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
55986 }
55987
55988 - /* We don't show the stack guard page in /proc/maps */
55989 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55990 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
55991 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
55992 +#else
55993 start = vma->vm_start;
55994 - if (stack_guard_page_start(vma, start))
55995 - start += PAGE_SIZE;
55996 end = vma->vm_end;
55997 - if (stack_guard_page_end(vma, end))
55998 - end -= PAGE_SIZE;
55999 +#endif
56000
56001 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
56002 start,
56003 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56004 flags & VM_WRITE ? 'w' : '-',
56005 flags & VM_EXEC ? 'x' : '-',
56006 flags & VM_MAYSHARE ? 's' : 'p',
56007 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56008 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
56009 +#else
56010 pgoff,
56011 +#endif
56012 MAJOR(dev), MINOR(dev), ino, &len);
56013
56014 /*
56015 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56016 */
56017 if (file) {
56018 pad_len_spaces(m, len);
56019 - seq_path(m, &file->f_path, "\n");
56020 + seq_path(m, &file->f_path, "\n\\");
56021 goto done;
56022 }
56023
56024 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56025 * Thread stack in /proc/PID/task/TID/maps or
56026 * the main process stack.
56027 */
56028 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56029 - vma->vm_end >= mm->start_stack)) {
56030 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56031 + (vma->vm_start <= mm->start_stack &&
56032 + vma->vm_end >= mm->start_stack)) {
56033 name = "[stack]";
56034 } else {
56035 /* Thread stack in /proc/PID/maps */
56036 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56037 struct proc_maps_private *priv = m->private;
56038 struct task_struct *task = priv->task;
56039
56040 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56041 + if (current->exec_id != m->exec_id) {
56042 + gr_log_badprocpid("maps");
56043 + return 0;
56044 + }
56045 +#endif
56046 +
56047 show_map_vma(m, vma, is_pid);
56048
56049 if (m->count < m->size) /* vma is copied successfully */
56050 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56051 .private = &mss,
56052 };
56053
56054 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56055 + if (current->exec_id != m->exec_id) {
56056 + gr_log_badprocpid("smaps");
56057 + return 0;
56058 + }
56059 +#endif
56060 memset(&mss, 0, sizeof mss);
56061 - mss.vma = vma;
56062 - /* mmap_sem is held in m_start */
56063 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56064 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56065 -
56066 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56067 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56068 +#endif
56069 + mss.vma = vma;
56070 + /* mmap_sem is held in m_start */
56071 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56072 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56073 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56074 + }
56075 +#endif
56076 show_map_vma(m, vma, is_pid);
56077
56078 seq_printf(m,
56079 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56080 "KernelPageSize: %8lu kB\n"
56081 "MMUPageSize: %8lu kB\n"
56082 "Locked: %8lu kB\n",
56083 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56084 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56085 +#else
56086 (vma->vm_end - vma->vm_start) >> 10,
56087 +#endif
56088 mss.resident >> 10,
56089 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56090 mss.shared_clean >> 10,
56091 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56092 int n;
56093 char buffer[50];
56094
56095 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56096 + if (current->exec_id != m->exec_id) {
56097 + gr_log_badprocpid("numa_maps");
56098 + return 0;
56099 + }
56100 +#endif
56101 +
56102 if (!mm)
56103 return 0;
56104
56105 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56106 mpol_to_str(buffer, sizeof(buffer), pol);
56107 mpol_cond_put(pol);
56108
56109 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56110 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56111 +#else
56112 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56113 +#endif
56114
56115 if (file) {
56116 seq_printf(m, " file=");
56117 - seq_path(m, &file->f_path, "\n\t= ");
56118 + seq_path(m, &file->f_path, "\n\t\\= ");
56119 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56120 seq_printf(m, " heap");
56121 } else {
56122 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56123 index 1ccfa53..0848f95 100644
56124 --- a/fs/proc/task_nommu.c
56125 +++ b/fs/proc/task_nommu.c
56126 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56127 else
56128 bytes += kobjsize(mm);
56129
56130 - if (current->fs && current->fs->users > 1)
56131 + if (current->fs && atomic_read(&current->fs->users) > 1)
56132 sbytes += kobjsize(current->fs);
56133 else
56134 bytes += kobjsize(current->fs);
56135 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56136
56137 if (file) {
56138 pad_len_spaces(m, len);
56139 - seq_path(m, &file->f_path, "");
56140 + seq_path(m, &file->f_path, "\n\\");
56141 } else if (mm) {
56142 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56143
56144 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56145 index b00fcc9..e0c6381 100644
56146 --- a/fs/qnx6/qnx6.h
56147 +++ b/fs/qnx6/qnx6.h
56148 @@ -74,7 +74,7 @@ enum {
56149 BYTESEX_BE,
56150 };
56151
56152 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56153 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56154 {
56155 if (sbi->s_bytesex == BYTESEX_LE)
56156 return le64_to_cpu((__force __le64)n);
56157 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56158 return (__force __fs64)cpu_to_be64(n);
56159 }
56160
56161 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56162 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56163 {
56164 if (sbi->s_bytesex == BYTESEX_LE)
56165 return le32_to_cpu((__force __le32)n);
56166 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56167 index 16e8abb..2dcf914 100644
56168 --- a/fs/quota/netlink.c
56169 +++ b/fs/quota/netlink.c
56170 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56171 void quota_send_warning(struct kqid qid, dev_t dev,
56172 const char warntype)
56173 {
56174 - static atomic_t seq;
56175 + static atomic_unchecked_t seq;
56176 struct sk_buff *skb;
56177 void *msg_head;
56178 int ret;
56179 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56180 "VFS: Not enough memory to send quota warning.\n");
56181 return;
56182 }
56183 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56184 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56185 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56186 if (!msg_head) {
56187 printk(KERN_ERR
56188 diff --git a/fs/readdir.c b/fs/readdir.c
56189 index 5e69ef5..e5d9099 100644
56190 --- a/fs/readdir.c
56191 +++ b/fs/readdir.c
56192 @@ -17,6 +17,7 @@
56193 #include <linux/security.h>
56194 #include <linux/syscalls.h>
56195 #include <linux/unistd.h>
56196 +#include <linux/namei.h>
56197
56198 #include <asm/uaccess.h>
56199
56200 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56201
56202 struct readdir_callback {
56203 struct old_linux_dirent __user * dirent;
56204 + struct file * file;
56205 int result;
56206 };
56207
56208 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56209 buf->result = -EOVERFLOW;
56210 return -EOVERFLOW;
56211 }
56212 +
56213 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56214 + return 0;
56215 +
56216 buf->result++;
56217 dirent = buf->dirent;
56218 if (!access_ok(VERIFY_WRITE, dirent,
56219 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56220
56221 buf.result = 0;
56222 buf.dirent = dirent;
56223 + buf.file = f.file;
56224
56225 error = vfs_readdir(f.file, fillonedir, &buf);
56226 if (buf.result)
56227 @@ -139,6 +146,7 @@ struct linux_dirent {
56228 struct getdents_callback {
56229 struct linux_dirent __user * current_dir;
56230 struct linux_dirent __user * previous;
56231 + struct file * file;
56232 int count;
56233 int error;
56234 };
56235 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56236 buf->error = -EOVERFLOW;
56237 return -EOVERFLOW;
56238 }
56239 +
56240 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56241 + return 0;
56242 +
56243 dirent = buf->previous;
56244 if (dirent) {
56245 if (__put_user(offset, &dirent->d_off))
56246 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56247 buf.previous = NULL;
56248 buf.count = count;
56249 buf.error = 0;
56250 + buf.file = f.file;
56251
56252 error = vfs_readdir(f.file, filldir, &buf);
56253 if (error >= 0)
56254 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56255 struct getdents_callback64 {
56256 struct linux_dirent64 __user * current_dir;
56257 struct linux_dirent64 __user * previous;
56258 + struct file *file;
56259 int count;
56260 int error;
56261 };
56262 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56263 buf->error = -EINVAL; /* only used if we fail.. */
56264 if (reclen > buf->count)
56265 return -EINVAL;
56266 +
56267 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56268 + return 0;
56269 +
56270 dirent = buf->previous;
56271 if (dirent) {
56272 if (__put_user(offset, &dirent->d_off))
56273 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56274
56275 buf.current_dir = dirent;
56276 buf.previous = NULL;
56277 + buf.file = f.file;
56278 buf.count = count;
56279 buf.error = 0;
56280
56281 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56282 error = buf.error;
56283 lastdirent = buf.previous;
56284 if (lastdirent) {
56285 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56286 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56287 if (__put_user(d_off, &lastdirent->d_off))
56288 error = -EFAULT;
56289 else
56290 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56291 index 2b7882b..1c5ef48 100644
56292 --- a/fs/reiserfs/do_balan.c
56293 +++ b/fs/reiserfs/do_balan.c
56294 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56295 return;
56296 }
56297
56298 - atomic_inc(&(fs_generation(tb->tb_sb)));
56299 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56300 do_balance_starts(tb);
56301
56302 /* balance leaf returns 0 except if combining L R and S into
56303 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56304 index e60e870..f40ac16 100644
56305 --- a/fs/reiserfs/procfs.c
56306 +++ b/fs/reiserfs/procfs.c
56307 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56308 "SMALL_TAILS " : "NO_TAILS ",
56309 replay_only(sb) ? "REPLAY_ONLY " : "",
56310 convert_reiserfs(sb) ? "CONV " : "",
56311 - atomic_read(&r->s_generation_counter),
56312 + atomic_read_unchecked(&r->s_generation_counter),
56313 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56314 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56315 SF(s_good_search_by_key_reada), SF(s_bmaps),
56316 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56317 index 157e474..65a6114 100644
56318 --- a/fs/reiserfs/reiserfs.h
56319 +++ b/fs/reiserfs/reiserfs.h
56320 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56321 /* Comment? -Hans */
56322 wait_queue_head_t s_wait;
56323 /* To be obsoleted soon by per buffer seals.. -Hans */
56324 - atomic_t s_generation_counter; // increased by one every time the
56325 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56326 // tree gets re-balanced
56327 unsigned long s_properties; /* File system properties. Currently holds
56328 on-disk FS format */
56329 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56330 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56331
56332 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56333 -#define get_generation(s) atomic_read (&fs_generation(s))
56334 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56335 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56336 #define __fs_changed(gen,s) (gen != get_generation (s))
56337 #define fs_changed(gen,s) \
56338 diff --git a/fs/select.c b/fs/select.c
56339 index 2ef72d9..f213b17 100644
56340 --- a/fs/select.c
56341 +++ b/fs/select.c
56342 @@ -20,6 +20,7 @@
56343 #include <linux/export.h>
56344 #include <linux/slab.h>
56345 #include <linux/poll.h>
56346 +#include <linux/security.h>
56347 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56348 #include <linux/file.h>
56349 #include <linux/fdtable.h>
56350 @@ -826,6 +827,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56351 struct poll_list *walk = head;
56352 unsigned long todo = nfds;
56353
56354 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56355 if (nfds > rlimit(RLIMIT_NOFILE))
56356 return -EINVAL;
56357
56358 diff --git a/fs/seq_file.c b/fs/seq_file.c
56359 index f2bc3df..239d4f6 100644
56360 --- a/fs/seq_file.c
56361 +++ b/fs/seq_file.c
56362 @@ -10,6 +10,7 @@
56363 #include <linux/seq_file.h>
56364 #include <linux/slab.h>
56365 #include <linux/cred.h>
56366 +#include <linux/sched.h>
56367
56368 #include <asm/uaccess.h>
56369 #include <asm/page.h>
56370 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56371 #ifdef CONFIG_USER_NS
56372 p->user_ns = file->f_cred->user_ns;
56373 #endif
56374 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56375 + p->exec_id = current->exec_id;
56376 +#endif
56377
56378 /*
56379 * Wrappers around seq_open(e.g. swaps_open) need to be
56380 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56381 return 0;
56382 }
56383 if (!m->buf) {
56384 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56385 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56386 if (!m->buf)
56387 return -ENOMEM;
56388 }
56389 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56390 Eoverflow:
56391 m->op->stop(m, p);
56392 kfree(m->buf);
56393 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56394 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56395 return !m->buf ? -ENOMEM : -EAGAIN;
56396 }
56397
56398 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56399
56400 /* grab buffer if we didn't have one */
56401 if (!m->buf) {
56402 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56403 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56404 if (!m->buf)
56405 goto Enomem;
56406 }
56407 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56408 goto Fill;
56409 m->op->stop(m, p);
56410 kfree(m->buf);
56411 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56412 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56413 if (!m->buf)
56414 goto Enomem;
56415 m->count = 0;
56416 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56417 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56418 void *data)
56419 {
56420 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56421 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56422 int res = -ENOMEM;
56423
56424 if (op) {
56425 diff --git a/fs/splice.c b/fs/splice.c
56426 index 6909d89..5b2e8f9 100644
56427 --- a/fs/splice.c
56428 +++ b/fs/splice.c
56429 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56430 pipe_lock(pipe);
56431
56432 for (;;) {
56433 - if (!pipe->readers) {
56434 + if (!atomic_read(&pipe->readers)) {
56435 send_sig(SIGPIPE, current, 0);
56436 if (!ret)
56437 ret = -EPIPE;
56438 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56439 do_wakeup = 0;
56440 }
56441
56442 - pipe->waiting_writers++;
56443 + atomic_inc(&pipe->waiting_writers);
56444 pipe_wait(pipe);
56445 - pipe->waiting_writers--;
56446 + atomic_dec(&pipe->waiting_writers);
56447 }
56448
56449 pipe_unlock(pipe);
56450 @@ -563,7 +563,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56451 old_fs = get_fs();
56452 set_fs(get_ds());
56453 /* The cast to a user pointer is valid due to the set_fs() */
56454 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56455 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56456 set_fs(old_fs);
56457
56458 return res;
56459 @@ -578,7 +578,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56460 old_fs = get_fs();
56461 set_fs(get_ds());
56462 /* The cast to a user pointer is valid due to the set_fs() */
56463 - res = vfs_write(file, (const char __user *)buf, count, &pos);
56464 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56465 set_fs(old_fs);
56466
56467 return res;
56468 @@ -630,7 +630,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56469 goto err;
56470
56471 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56472 - vec[i].iov_base = (void __user *) page_address(page);
56473 + vec[i].iov_base = (void __force_user *) page_address(page);
56474 vec[i].iov_len = this_len;
56475 spd.pages[i] = page;
56476 spd.nr_pages++;
56477 @@ -851,10 +851,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56478 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56479 {
56480 while (!pipe->nrbufs) {
56481 - if (!pipe->writers)
56482 + if (!atomic_read(&pipe->writers))
56483 return 0;
56484
56485 - if (!pipe->waiting_writers && sd->num_spliced)
56486 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56487 return 0;
56488
56489 if (sd->flags & SPLICE_F_NONBLOCK)
56490 @@ -1189,7 +1189,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56491 * out of the pipe right after the splice_to_pipe(). So set
56492 * PIPE_READERS appropriately.
56493 */
56494 - pipe->readers = 1;
56495 + atomic_set(&pipe->readers, 1);
56496
56497 current->splice_pipe = pipe;
56498 }
56499 @@ -1738,9 +1738,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56500 ret = -ERESTARTSYS;
56501 break;
56502 }
56503 - if (!pipe->writers)
56504 + if (!atomic_read(&pipe->writers))
56505 break;
56506 - if (!pipe->waiting_writers) {
56507 + if (!atomic_read(&pipe->waiting_writers)) {
56508 if (flags & SPLICE_F_NONBLOCK) {
56509 ret = -EAGAIN;
56510 break;
56511 @@ -1772,7 +1772,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56512 pipe_lock(pipe);
56513
56514 while (pipe->nrbufs >= pipe->buffers) {
56515 - if (!pipe->readers) {
56516 + if (!atomic_read(&pipe->readers)) {
56517 send_sig(SIGPIPE, current, 0);
56518 ret = -EPIPE;
56519 break;
56520 @@ -1785,9 +1785,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56521 ret = -ERESTARTSYS;
56522 break;
56523 }
56524 - pipe->waiting_writers++;
56525 + atomic_inc(&pipe->waiting_writers);
56526 pipe_wait(pipe);
56527 - pipe->waiting_writers--;
56528 + atomic_dec(&pipe->waiting_writers);
56529 }
56530
56531 pipe_unlock(pipe);
56532 @@ -1823,14 +1823,14 @@ retry:
56533 pipe_double_lock(ipipe, opipe);
56534
56535 do {
56536 - if (!opipe->readers) {
56537 + if (!atomic_read(&opipe->readers)) {
56538 send_sig(SIGPIPE, current, 0);
56539 if (!ret)
56540 ret = -EPIPE;
56541 break;
56542 }
56543
56544 - if (!ipipe->nrbufs && !ipipe->writers)
56545 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56546 break;
56547
56548 /*
56549 @@ -1927,7 +1927,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56550 pipe_double_lock(ipipe, opipe);
56551
56552 do {
56553 - if (!opipe->readers) {
56554 + if (!atomic_read(&opipe->readers)) {
56555 send_sig(SIGPIPE, current, 0);
56556 if (!ret)
56557 ret = -EPIPE;
56558 @@ -1972,7 +1972,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56559 * return EAGAIN if we have the potential of some data in the
56560 * future, otherwise just return 0
56561 */
56562 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56563 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56564 ret = -EAGAIN;
56565
56566 pipe_unlock(ipipe);
56567 diff --git a/fs/stat.c b/fs/stat.c
56568 index 14f4545..9b7f55b 100644
56569 --- a/fs/stat.c
56570 +++ b/fs/stat.c
56571 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56572 stat->gid = inode->i_gid;
56573 stat->rdev = inode->i_rdev;
56574 stat->size = i_size_read(inode);
56575 - stat->atime = inode->i_atime;
56576 - stat->mtime = inode->i_mtime;
56577 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56578 + stat->atime = inode->i_ctime;
56579 + stat->mtime = inode->i_ctime;
56580 + } else {
56581 + stat->atime = inode->i_atime;
56582 + stat->mtime = inode->i_mtime;
56583 + }
56584 stat->ctime = inode->i_ctime;
56585 stat->blksize = (1 << inode->i_blkbits);
56586 stat->blocks = inode->i_blocks;
56587 @@ -46,8 +51,14 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
56588 if (retval)
56589 return retval;
56590
56591 - if (inode->i_op->getattr)
56592 - return inode->i_op->getattr(mnt, dentry, stat);
56593 + if (inode->i_op->getattr) {
56594 + retval = inode->i_op->getattr(mnt, dentry, stat);
56595 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56596 + stat->atime = stat->ctime;
56597 + stat->mtime = stat->ctime;
56598 + }
56599 + return retval;
56600 + }
56601
56602 generic_fillattr(inode, stat);
56603 return 0;
56604 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56605 index 614b2b5..4d321e6 100644
56606 --- a/fs/sysfs/bin.c
56607 +++ b/fs/sysfs/bin.c
56608 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56609 return ret;
56610 }
56611
56612 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56613 - void *buf, int len, int write)
56614 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56615 + void *buf, size_t len, int write)
56616 {
56617 struct file *file = vma->vm_file;
56618 struct bin_buffer *bb = file->private_data;
56619 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56620 - int ret;
56621 + ssize_t ret;
56622
56623 if (!bb->vm_ops)
56624 return -EINVAL;
56625 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56626 index 1f8c823..ed57cfe 100644
56627 --- a/fs/sysfs/dir.c
56628 +++ b/fs/sysfs/dir.c
56629 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56630 *
56631 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56632 */
56633 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56634 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56635 {
56636 unsigned long hash = init_name_hash();
56637 unsigned int len = strlen(name);
56638 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56639 struct sysfs_dirent *sd;
56640 int rc;
56641
56642 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56643 + const char *parent_name = parent_sd->s_name;
56644 +
56645 + mode = S_IFDIR | S_IRWXU;
56646 +
56647 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56648 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56649 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56650 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56651 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56652 +#endif
56653 +
56654 /* allocate */
56655 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56656 if (!sd)
56657 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56658 index 602f56d..6853db8 100644
56659 --- a/fs/sysfs/file.c
56660 +++ b/fs/sysfs/file.c
56661 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56662
56663 struct sysfs_open_dirent {
56664 atomic_t refcnt;
56665 - atomic_t event;
56666 + atomic_unchecked_t event;
56667 wait_queue_head_t poll;
56668 struct list_head buffers; /* goes through sysfs_buffer.list */
56669 };
56670 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56671 if (!sysfs_get_active(attr_sd))
56672 return -ENODEV;
56673
56674 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56675 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56676 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56677
56678 sysfs_put_active(attr_sd);
56679 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56680 return -ENOMEM;
56681
56682 atomic_set(&new_od->refcnt, 0);
56683 - atomic_set(&new_od->event, 1);
56684 + atomic_set_unchecked(&new_od->event, 1);
56685 init_waitqueue_head(&new_od->poll);
56686 INIT_LIST_HEAD(&new_od->buffers);
56687 goto retry;
56688 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56689
56690 sysfs_put_active(attr_sd);
56691
56692 - if (buffer->event != atomic_read(&od->event))
56693 + if (buffer->event != atomic_read_unchecked(&od->event))
56694 goto trigger;
56695
56696 return DEFAULT_POLLMASK;
56697 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56698
56699 od = sd->s_attr.open;
56700 if (od) {
56701 - atomic_inc(&od->event);
56702 + atomic_inc_unchecked(&od->event);
56703 wake_up_interruptible(&od->poll);
56704 }
56705
56706 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56707 index 3c9eb56..9dea5be 100644
56708 --- a/fs/sysfs/symlink.c
56709 +++ b/fs/sysfs/symlink.c
56710 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56711
56712 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56713 {
56714 - char *page = nd_get_link(nd);
56715 + const char *page = nd_get_link(nd);
56716 if (!IS_ERR(page))
56717 free_page((unsigned long)page);
56718 }
56719 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56720 index 69d4889..a810bd4 100644
56721 --- a/fs/sysv/sysv.h
56722 +++ b/fs/sysv/sysv.h
56723 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56724 #endif
56725 }
56726
56727 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56728 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56729 {
56730 if (sbi->s_bytesex == BYTESEX_PDP)
56731 return PDP_swab((__force __u32)n);
56732 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56733 index e18b988..f1d4ad0f 100644
56734 --- a/fs/ubifs/io.c
56735 +++ b/fs/ubifs/io.c
56736 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56737 return err;
56738 }
56739
56740 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56741 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56742 {
56743 int err;
56744
56745 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56746 index c175b4d..8f36a16 100644
56747 --- a/fs/udf/misc.c
56748 +++ b/fs/udf/misc.c
56749 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56750
56751 u8 udf_tag_checksum(const struct tag *t)
56752 {
56753 - u8 *data = (u8 *)t;
56754 + const u8 *data = (const u8 *)t;
56755 u8 checksum = 0;
56756 int i;
56757 for (i = 0; i < sizeof(struct tag); ++i)
56758 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56759 index 8d974c4..b82f6ec 100644
56760 --- a/fs/ufs/swab.h
56761 +++ b/fs/ufs/swab.h
56762 @@ -22,7 +22,7 @@ enum {
56763 BYTESEX_BE
56764 };
56765
56766 -static inline u64
56767 +static inline u64 __intentional_overflow(-1)
56768 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56769 {
56770 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56771 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56772 return (__force __fs64)cpu_to_be64(n);
56773 }
56774
56775 -static inline u32
56776 +static inline u32 __intentional_overflow(-1)
56777 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56778 {
56779 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56780 diff --git a/fs/utimes.c b/fs/utimes.c
56781 index f4fb7ec..3fe03c0 100644
56782 --- a/fs/utimes.c
56783 +++ b/fs/utimes.c
56784 @@ -1,6 +1,7 @@
56785 #include <linux/compiler.h>
56786 #include <linux/file.h>
56787 #include <linux/fs.h>
56788 +#include <linux/security.h>
56789 #include <linux/linkage.h>
56790 #include <linux/mount.h>
56791 #include <linux/namei.h>
56792 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56793 goto mnt_drop_write_and_out;
56794 }
56795 }
56796 +
56797 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56798 + error = -EACCES;
56799 + goto mnt_drop_write_and_out;
56800 + }
56801 +
56802 mutex_lock(&inode->i_mutex);
56803 error = notify_change(path->dentry, &newattrs);
56804 mutex_unlock(&inode->i_mutex);
56805 diff --git a/fs/xattr.c b/fs/xattr.c
56806 index 3377dff..4feded6 100644
56807 --- a/fs/xattr.c
56808 +++ b/fs/xattr.c
56809 @@ -319,7 +319,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56810 * Extended attribute SET operations
56811 */
56812 static long
56813 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56814 +setxattr(struct path *path, const char __user *name, const void __user *value,
56815 size_t size, int flags)
56816 {
56817 int error;
56818 @@ -355,7 +355,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56819 posix_acl_fix_xattr_from_user(kvalue, size);
56820 }
56821
56822 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56823 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56824 + error = -EACCES;
56825 + goto out;
56826 + }
56827 +
56828 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56829 out:
56830 if (vvalue)
56831 vfree(vvalue);
56832 @@ -377,7 +382,7 @@ retry:
56833 return error;
56834 error = mnt_want_write(path.mnt);
56835 if (!error) {
56836 - error = setxattr(path.dentry, name, value, size, flags);
56837 + error = setxattr(&path, name, value, size, flags);
56838 mnt_drop_write(path.mnt);
56839 }
56840 path_put(&path);
56841 @@ -401,7 +406,7 @@ retry:
56842 return error;
56843 error = mnt_want_write(path.mnt);
56844 if (!error) {
56845 - error = setxattr(path.dentry, name, value, size, flags);
56846 + error = setxattr(&path, name, value, size, flags);
56847 mnt_drop_write(path.mnt);
56848 }
56849 path_put(&path);
56850 @@ -416,16 +421,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56851 const void __user *,value, size_t, size, int, flags)
56852 {
56853 struct fd f = fdget(fd);
56854 - struct dentry *dentry;
56855 int error = -EBADF;
56856
56857 if (!f.file)
56858 return error;
56859 - dentry = f.file->f_path.dentry;
56860 - audit_inode(NULL, dentry, 0);
56861 + audit_inode(NULL, f.file->f_path.dentry, 0);
56862 error = mnt_want_write_file(f.file);
56863 if (!error) {
56864 - error = setxattr(dentry, name, value, size, flags);
56865 + error = setxattr(&f.file->f_path, name, value, size, flags);
56866 mnt_drop_write_file(f.file);
56867 }
56868 fdput(f);
56869 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56870 index 9fbea87..6b19972 100644
56871 --- a/fs/xattr_acl.c
56872 +++ b/fs/xattr_acl.c
56873 @@ -76,8 +76,8 @@ struct posix_acl *
56874 posix_acl_from_xattr(struct user_namespace *user_ns,
56875 const void *value, size_t size)
56876 {
56877 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56878 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56879 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56880 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56881 int count;
56882 struct posix_acl *acl;
56883 struct posix_acl_entry *acl_e;
56884 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56885 index 572a858..12a9b0d 100644
56886 --- a/fs/xfs/xfs_bmap.c
56887 +++ b/fs/xfs/xfs_bmap.c
56888 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56889 int nmap,
56890 int ret_nmap);
56891 #else
56892 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56893 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56894 #endif /* DEBUG */
56895
56896 STATIC int
56897 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56898 index 1b9fc3e..e1bdde0 100644
56899 --- a/fs/xfs/xfs_dir2_sf.c
56900 +++ b/fs/xfs/xfs_dir2_sf.c
56901 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56902 }
56903
56904 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56905 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56906 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56907 + char name[sfep->namelen];
56908 + memcpy(name, sfep->name, sfep->namelen);
56909 + if (filldir(dirent, name, sfep->namelen,
56910 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56911 + *offset = off & 0x7fffffff;
56912 + return 0;
56913 + }
56914 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56915 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56916 *offset = off & 0x7fffffff;
56917 return 0;
56918 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56919 index c1c3ef8..0952438 100644
56920 --- a/fs/xfs/xfs_ioctl.c
56921 +++ b/fs/xfs/xfs_ioctl.c
56922 @@ -127,7 +127,7 @@ xfs_find_handle(
56923 }
56924
56925 error = -EFAULT;
56926 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56927 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56928 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56929 goto out_put;
56930
56931 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56932 index d82efaa..0904a8e 100644
56933 --- a/fs/xfs/xfs_iops.c
56934 +++ b/fs/xfs/xfs_iops.c
56935 @@ -395,7 +395,7 @@ xfs_vn_put_link(
56936 struct nameidata *nd,
56937 void *p)
56938 {
56939 - char *s = nd_get_link(nd);
56940 + const char *s = nd_get_link(nd);
56941
56942 if (!IS_ERR(s))
56943 kfree(s);
56944 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
56945 new file mode 100644
56946 index 0000000..92247e4
56947 --- /dev/null
56948 +++ b/grsecurity/Kconfig
56949 @@ -0,0 +1,1021 @@
56950 +#
56951 +# grecurity configuration
56952 +#
56953 +menu "Memory Protections"
56954 +depends on GRKERNSEC
56955 +
56956 +config GRKERNSEC_KMEM
56957 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
56958 + default y if GRKERNSEC_CONFIG_AUTO
56959 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
56960 + help
56961 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
56962 + be written to or read from to modify or leak the contents of the running
56963 + kernel. /dev/port will also not be allowed to be opened and support
56964 + for /dev/cpu/*/msr will be removed. If you have module
56965 + support disabled, enabling this will close up five ways that are
56966 + currently used to insert malicious code into the running kernel.
56967 +
56968 + Even with all these features enabled, we still highly recommend that
56969 + you use the RBAC system, as it is still possible for an attacker to
56970 + modify the running kernel through privileged I/O granted by ioperm/iopl.
56971 +
56972 + If you are not using XFree86, you may be able to stop this additional
56973 + case by enabling the 'Disable privileged I/O' option. Though nothing
56974 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
56975 + but only to video memory, which is the only writing we allow in this
56976 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
56977 + not be allowed to mprotect it with PROT_WRITE later.
56978 + Enabling this feature will prevent the "cpupower" and "powertop" tools
56979 + from working.
56980 +
56981 + It is highly recommended that you say Y here if you meet all the
56982 + conditions above.
56983 +
56984 +config GRKERNSEC_VM86
56985 + bool "Restrict VM86 mode"
56986 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
56987 + depends on X86_32
56988 +
56989 + help
56990 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
56991 + make use of a special execution mode on 32bit x86 processors called
56992 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
56993 + video cards and will still work with this option enabled. The purpose
56994 + of the option is to prevent exploitation of emulation errors in
56995 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
56996 + Nearly all users should be able to enable this option.
56997 +
56998 +config GRKERNSEC_IO
56999 + bool "Disable privileged I/O"
57000 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57001 + depends on X86
57002 + select RTC_CLASS
57003 + select RTC_INTF_DEV
57004 + select RTC_DRV_CMOS
57005 +
57006 + help
57007 + If you say Y here, all ioperm and iopl calls will return an error.
57008 + Ioperm and iopl can be used to modify the running kernel.
57009 + Unfortunately, some programs need this access to operate properly,
57010 + the most notable of which are XFree86 and hwclock. hwclock can be
57011 + remedied by having RTC support in the kernel, so real-time
57012 + clock support is enabled if this option is enabled, to ensure
57013 + that hwclock operates correctly. XFree86 still will not
57014 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57015 + IF YOU USE XFree86. If you use XFree86 and you still want to
57016 + protect your kernel against modification, use the RBAC system.
57017 +
57018 +config GRKERNSEC_JIT_HARDEN
57019 + bool "Harden BPF JIT against spray attacks"
57020 + default y if GRKERNSEC_CONFIG_AUTO
57021 + depends on BPF_JIT
57022 + help
57023 + If you say Y here, the native code generated by the kernel's Berkeley
57024 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57025 + attacks that attempt to fit attacker-beneficial instructions in
57026 + 32bit immediate fields of JIT-generated native instructions. The
57027 + attacker will generally aim to cause an unintended instruction sequence
57028 + of JIT-generated native code to execute by jumping into the middle of
57029 + a generated instruction. This feature effectively randomizes the 32bit
57030 + immediate constants present in the generated code to thwart such attacks.
57031 +
57032 + If you're using KERNEXEC, it's recommended that you enable this option
57033 + to supplement the hardening of the kernel.
57034 +
57035 +config GRKERNSEC_RAND_THREADSTACK
57036 + bool "Insert random gaps between thread stacks"
57037 + default y if GRKERNSEC_CONFIG_AUTO
57038 + depends on PAX_RANDMMAP && !PPC
57039 + help
57040 + If you say Y here, a random-sized gap will be enforced between allocated
57041 + thread stacks. Glibc's NPTL and other threading libraries that
57042 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57043 + The implementation currently provides 8 bits of entropy for the gap.
57044 +
57045 + Many distributions do not compile threaded remote services with the
57046 + -fstack-check argument to GCC, causing the variable-sized stack-based
57047 + allocator, alloca(), to not probe the stack on allocation. This
57048 + permits an unbounded alloca() to skip over any guard page and potentially
57049 + modify another thread's stack reliably. An enforced random gap
57050 + reduces the reliability of such an attack and increases the chance
57051 + that such a read/write to another thread's stack instead lands in
57052 + an unmapped area, causing a crash and triggering grsecurity's
57053 + anti-bruteforcing logic.
57054 +
57055 +config GRKERNSEC_PROC_MEMMAP
57056 + bool "Harden ASLR against information leaks and entropy reduction"
57057 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57058 + depends on PAX_NOEXEC || PAX_ASLR
57059 + help
57060 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57061 + give no information about the addresses of its mappings if
57062 + PaX features that rely on random addresses are enabled on the task.
57063 + In addition to sanitizing this information and disabling other
57064 + dangerous sources of information, this option causes reads of sensitive
57065 + /proc/<pid> entries where the file descriptor was opened in a different
57066 + task than the one performing the read. Such attempts are logged.
57067 + This option also limits argv/env strings for suid/sgid binaries
57068 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57069 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57070 + binaries to prevent alternative mmap layouts from being abused.
57071 +
57072 + If you use PaX it is essential that you say Y here as it closes up
57073 + several holes that make full ASLR useless locally.
57074 +
57075 +config GRKERNSEC_BRUTE
57076 + bool "Deter exploit bruteforcing"
57077 + default y if GRKERNSEC_CONFIG_AUTO
57078 + help
57079 + If you say Y here, attempts to bruteforce exploits against forking
57080 + daemons such as apache or sshd, as well as against suid/sgid binaries
57081 + will be deterred. When a child of a forking daemon is killed by PaX
57082 + or crashes due to an illegal instruction or other suspicious signal,
57083 + the parent process will be delayed 30 seconds upon every subsequent
57084 + fork until the administrator is able to assess the situation and
57085 + restart the daemon.
57086 + In the suid/sgid case, the attempt is logged, the user has all their
57087 + processes terminated, and they are prevented from executing any further
57088 + processes for 15 minutes.
57089 + It is recommended that you also enable signal logging in the auditing
57090 + section so that logs are generated when a process triggers a suspicious
57091 + signal.
57092 + If the sysctl option is enabled, a sysctl option with name
57093 + "deter_bruteforce" is created.
57094 +
57095 +
57096 +config GRKERNSEC_MODHARDEN
57097 + bool "Harden module auto-loading"
57098 + default y if GRKERNSEC_CONFIG_AUTO
57099 + depends on MODULES
57100 + help
57101 + If you say Y here, module auto-loading in response to use of some
57102 + feature implemented by an unloaded module will be restricted to
57103 + root users. Enabling this option helps defend against attacks
57104 + by unprivileged users who abuse the auto-loading behavior to
57105 + cause a vulnerable module to load that is then exploited.
57106 +
57107 + If this option prevents a legitimate use of auto-loading for a
57108 + non-root user, the administrator can execute modprobe manually
57109 + with the exact name of the module mentioned in the alert log.
57110 + Alternatively, the administrator can add the module to the list
57111 + of modules loaded at boot by modifying init scripts.
57112 +
57113 + Modification of init scripts will most likely be needed on
57114 + Ubuntu servers with encrypted home directory support enabled,
57115 + as the first non-root user logging in will cause the ecb(aes),
57116 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57117 +
57118 +config GRKERNSEC_HIDESYM
57119 + bool "Hide kernel symbols"
57120 + default y if GRKERNSEC_CONFIG_AUTO
57121 + select PAX_USERCOPY_SLABS
57122 + help
57123 + If you say Y here, getting information on loaded modules, and
57124 + displaying all kernel symbols through a syscall will be restricted
57125 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57126 + /proc/kallsyms will be restricted to the root user. The RBAC
57127 + system can hide that entry even from root.
57128 +
57129 + This option also prevents leaking of kernel addresses through
57130 + several /proc entries.
57131 +
57132 + Note that this option is only effective provided the following
57133 + conditions are met:
57134 + 1) The kernel using grsecurity is not precompiled by some distribution
57135 + 2) You have also enabled GRKERNSEC_DMESG
57136 + 3) You are using the RBAC system and hiding other files such as your
57137 + kernel image and System.map. Alternatively, enabling this option
57138 + causes the permissions on /boot, /lib/modules, and the kernel
57139 + source directory to change at compile time to prevent
57140 + reading by non-root users.
57141 + If the above conditions are met, this option will aid in providing a
57142 + useful protection against local kernel exploitation of overflows
57143 + and arbitrary read/write vulnerabilities.
57144 +
57145 +config GRKERNSEC_KERN_LOCKOUT
57146 + bool "Active kernel exploit response"
57147 + default y if GRKERNSEC_CONFIG_AUTO
57148 + depends on X86 || ARM || PPC || SPARC
57149 + help
57150 + If you say Y here, when a PaX alert is triggered due to suspicious
57151 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57152 + or an OOPS occurs due to bad memory accesses, instead of just
57153 + terminating the offending process (and potentially allowing
57154 + a subsequent exploit from the same user), we will take one of two
57155 + actions:
57156 + If the user was root, we will panic the system
57157 + If the user was non-root, we will log the attempt, terminate
57158 + all processes owned by the user, then prevent them from creating
57159 + any new processes until the system is restarted
57160 + This deters repeated kernel exploitation/bruteforcing attempts
57161 + and is useful for later forensics.
57162 +
57163 +endmenu
57164 +menu "Role Based Access Control Options"
57165 +depends on GRKERNSEC
57166 +
57167 +config GRKERNSEC_RBAC_DEBUG
57168 + bool
57169 +
57170 +config GRKERNSEC_NO_RBAC
57171 + bool "Disable RBAC system"
57172 + help
57173 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57174 + preventing the RBAC system from being enabled. You should only say Y
57175 + here if you have no intention of using the RBAC system, so as to prevent
57176 + an attacker with root access from misusing the RBAC system to hide files
57177 + and processes when loadable module support and /dev/[k]mem have been
57178 + locked down.
57179 +
57180 +config GRKERNSEC_ACL_HIDEKERN
57181 + bool "Hide kernel processes"
57182 + help
57183 + If you say Y here, all kernel threads will be hidden to all
57184 + processes but those whose subject has the "view hidden processes"
57185 + flag.
57186 +
57187 +config GRKERNSEC_ACL_MAXTRIES
57188 + int "Maximum tries before password lockout"
57189 + default 3
57190 + help
57191 + This option enforces the maximum number of times a user can attempt
57192 + to authorize themselves with the grsecurity RBAC system before being
57193 + denied the ability to attempt authorization again for a specified time.
57194 + The lower the number, the harder it will be to brute-force a password.
57195 +
57196 +config GRKERNSEC_ACL_TIMEOUT
57197 + int "Time to wait after max password tries, in seconds"
57198 + default 30
57199 + help
57200 + This option specifies the time the user must wait after attempting to
57201 + authorize to the RBAC system with the maximum number of invalid
57202 + passwords. The higher the number, the harder it will be to brute-force
57203 + a password.
57204 +
57205 +endmenu
57206 +menu "Filesystem Protections"
57207 +depends on GRKERNSEC
57208 +
57209 +config GRKERNSEC_PROC
57210 + bool "Proc restrictions"
57211 + default y if GRKERNSEC_CONFIG_AUTO
57212 + help
57213 + If you say Y here, the permissions of the /proc filesystem
57214 + will be altered to enhance system security and privacy. You MUST
57215 + choose either a user only restriction or a user and group restriction.
57216 + Depending upon the option you choose, you can either restrict users to
57217 + see only the processes they themselves run, or choose a group that can
57218 + view all processes and files normally restricted to root if you choose
57219 + the "restrict to user only" option. NOTE: If you're running identd or
57220 + ntpd as a non-root user, you will have to run it as the group you
57221 + specify here.
57222 +
57223 +config GRKERNSEC_PROC_USER
57224 + bool "Restrict /proc to user only"
57225 + depends on GRKERNSEC_PROC
57226 + help
57227 + If you say Y here, non-root users will only be able to view their own
57228 + processes, and restricts them from viewing network-related information,
57229 + and viewing kernel symbol and module information.
57230 +
57231 +config GRKERNSEC_PROC_USERGROUP
57232 + bool "Allow special group"
57233 + default y if GRKERNSEC_CONFIG_AUTO
57234 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57235 + help
57236 + If you say Y here, you will be able to select a group that will be
57237 + able to view all processes and network-related information. If you've
57238 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57239 + remain hidden. This option is useful if you want to run identd as
57240 + a non-root user. The group you select may also be chosen at boot time
57241 + via "grsec_proc_gid=" on the kernel commandline.
57242 +
57243 +config GRKERNSEC_PROC_GID
57244 + int "GID for special group"
57245 + depends on GRKERNSEC_PROC_USERGROUP
57246 + default 1001
57247 +
57248 +config GRKERNSEC_PROC_ADD
57249 + bool "Additional restrictions"
57250 + default y if GRKERNSEC_CONFIG_AUTO
57251 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57252 + help
57253 + If you say Y here, additional restrictions will be placed on
57254 + /proc that keep normal users from viewing device information and
57255 + slabinfo information that could be useful for exploits.
57256 +
57257 +config GRKERNSEC_LINK
57258 + bool "Linking restrictions"
57259 + default y if GRKERNSEC_CONFIG_AUTO
57260 + help
57261 + If you say Y here, /tmp race exploits will be prevented, since users
57262 + will no longer be able to follow symlinks owned by other users in
57263 + world-writable +t directories (e.g. /tmp), unless the owner of the
57264 + symlink is the owner of the directory. users will also not be
57265 + able to hardlink to files they do not own. If the sysctl option is
57266 + enabled, a sysctl option with name "linking_restrictions" is created.
57267 +
57268 +config GRKERNSEC_SYMLINKOWN
57269 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57270 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57271 + help
57272 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57273 + that prevents it from being used as a security feature. As Apache
57274 + verifies the symlink by performing a stat() against the target of
57275 + the symlink before it is followed, an attacker can setup a symlink
57276 + to point to a same-owned file, then replace the symlink with one
57277 + that targets another user's file just after Apache "validates" the
57278 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57279 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57280 + will be in place for the group you specify. If the sysctl option
57281 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57282 + created.
57283 +
57284 +config GRKERNSEC_SYMLINKOWN_GID
57285 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57286 + depends on GRKERNSEC_SYMLINKOWN
57287 + default 1006
57288 + help
57289 + Setting this GID determines what group kernel-enforced
57290 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57291 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57292 +
57293 +config GRKERNSEC_FIFO
57294 + bool "FIFO restrictions"
57295 + default y if GRKERNSEC_CONFIG_AUTO
57296 + help
57297 + If you say Y here, users will not be able to write to FIFOs they don't
57298 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57299 + the FIFO is the same owner of the directory it's held in. If the sysctl
57300 + option is enabled, a sysctl option with name "fifo_restrictions" is
57301 + created.
57302 +
57303 +config GRKERNSEC_SYSFS_RESTRICT
57304 + bool "Sysfs/debugfs restriction"
57305 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57306 + depends on SYSFS
57307 + help
57308 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57309 + any filesystem normally mounted under it (e.g. debugfs) will be
57310 + mostly accessible only by root. These filesystems generally provide access
57311 + to hardware and debug information that isn't appropriate for unprivileged
57312 + users of the system. Sysfs and debugfs have also become a large source
57313 + of new vulnerabilities, ranging from infoleaks to local compromise.
57314 + There has been very little oversight with an eye toward security involved
57315 + in adding new exporters of information to these filesystems, so their
57316 + use is discouraged.
57317 + For reasons of compatibility, a few directories have been whitelisted
57318 + for access by non-root users:
57319 + /sys/fs/selinux
57320 + /sys/fs/fuse
57321 + /sys/devices/system/cpu
57322 +
57323 +config GRKERNSEC_ROFS
57324 + bool "Runtime read-only mount protection"
57325 + help
57326 + If you say Y here, a sysctl option with name "romount_protect" will
57327 + be created. By setting this option to 1 at runtime, filesystems
57328 + will be protected in the following ways:
57329 + * No new writable mounts will be allowed
57330 + * Existing read-only mounts won't be able to be remounted read/write
57331 + * Write operations will be denied on all block devices
57332 + This option acts independently of grsec_lock: once it is set to 1,
57333 + it cannot be turned off. Therefore, please be mindful of the resulting
57334 + behavior if this option is enabled in an init script on a read-only
57335 + filesystem. This feature is mainly intended for secure embedded systems.
57336 +
57337 +config GRKERNSEC_DEVICE_SIDECHANNEL
57338 + bool "Eliminate stat/notify-based device sidechannels"
57339 + default y if GRKERNSEC_CONFIG_AUTO
57340 + help
57341 + If you say Y here, timing analyses on block or character
57342 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57343 + will be thwarted for unprivileged users. If a process without
57344 + CAP_MKNOD stats such a device, the last access and last modify times
57345 + will match the device's create time. No access or modify events
57346 + will be triggered through inotify/dnotify/fanotify for such devices.
57347 + This feature will prevent attacks that may at a minimum
57348 + allow an attacker to determine the administrator's password length.
57349 +
57350 +config GRKERNSEC_CHROOT
57351 + bool "Chroot jail restrictions"
57352 + default y if GRKERNSEC_CONFIG_AUTO
57353 + help
57354 + If you say Y here, you will be able to choose several options that will
57355 + make breaking out of a chrooted jail much more difficult. If you
57356 + encounter no software incompatibilities with the following options, it
57357 + is recommended that you enable each one.
57358 +
57359 +config GRKERNSEC_CHROOT_MOUNT
57360 + bool "Deny mounts"
57361 + default y if GRKERNSEC_CONFIG_AUTO
57362 + depends on GRKERNSEC_CHROOT
57363 + help
57364 + If you say Y here, processes inside a chroot will not be able to
57365 + mount or remount filesystems. If the sysctl option is enabled, a
57366 + sysctl option with name "chroot_deny_mount" is created.
57367 +
57368 +config GRKERNSEC_CHROOT_DOUBLE
57369 + bool "Deny double-chroots"
57370 + default y if GRKERNSEC_CONFIG_AUTO
57371 + depends on GRKERNSEC_CHROOT
57372 + help
57373 + If you say Y here, processes inside a chroot will not be able to chroot
57374 + again outside the chroot. This is a widely used method of breaking
57375 + out of a chroot jail and should not be allowed. If the sysctl
57376 + option is enabled, a sysctl option with name
57377 + "chroot_deny_chroot" is created.
57378 +
57379 +config GRKERNSEC_CHROOT_PIVOT
57380 + bool "Deny pivot_root in chroot"
57381 + default y if GRKERNSEC_CONFIG_AUTO
57382 + depends on GRKERNSEC_CHROOT
57383 + help
57384 + If you say Y here, processes inside a chroot will not be able to use
57385 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57386 + works similar to chroot in that it changes the root filesystem. This
57387 + function could be misused in a chrooted process to attempt to break out
57388 + of the chroot, and therefore should not be allowed. If the sysctl
57389 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57390 + created.
57391 +
57392 +config GRKERNSEC_CHROOT_CHDIR
57393 + bool "Enforce chdir(\"/\") on all chroots"
57394 + default y if GRKERNSEC_CONFIG_AUTO
57395 + depends on GRKERNSEC_CHROOT
57396 + help
57397 + If you say Y here, the current working directory of all newly-chrooted
57398 + applications will be set to the the root directory of the chroot.
57399 + The man page on chroot(2) states:
57400 + Note that this call does not change the current working
57401 + directory, so that `.' can be outside the tree rooted at
57402 + `/'. In particular, the super-user can escape from a
57403 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57404 +
57405 + It is recommended that you say Y here, since it's not known to break
57406 + any software. If the sysctl option is enabled, a sysctl option with
57407 + name "chroot_enforce_chdir" is created.
57408 +
57409 +config GRKERNSEC_CHROOT_CHMOD
57410 + bool "Deny (f)chmod +s"
57411 + default y if GRKERNSEC_CONFIG_AUTO
57412 + depends on GRKERNSEC_CHROOT
57413 + help
57414 + If you say Y here, processes inside a chroot will not be able to chmod
57415 + or fchmod files to make them have suid or sgid bits. This protects
57416 + against another published method of breaking a chroot. If the sysctl
57417 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57418 + created.
57419 +
57420 +config GRKERNSEC_CHROOT_FCHDIR
57421 + bool "Deny fchdir out of chroot"
57422 + default y if GRKERNSEC_CONFIG_AUTO
57423 + depends on GRKERNSEC_CHROOT
57424 + help
57425 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57426 + to a file descriptor of the chrooting process that points to a directory
57427 + outside the filesystem will be stopped. If the sysctl option
57428 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57429 +
57430 +config GRKERNSEC_CHROOT_MKNOD
57431 + bool "Deny mknod"
57432 + default y if GRKERNSEC_CONFIG_AUTO
57433 + depends on GRKERNSEC_CHROOT
57434 + help
57435 + If you say Y here, processes inside a chroot will not be allowed to
57436 + mknod. The problem with using mknod inside a chroot is that it
57437 + would allow an attacker to create a device entry that is the same
57438 + as one on the physical root of your system, which could range from
57439 + anything from the console device to a device for your harddrive (which
57440 + they could then use to wipe the drive or steal data). It is recommended
57441 + that you say Y here, unless you run into software incompatibilities.
57442 + If the sysctl option is enabled, a sysctl option with name
57443 + "chroot_deny_mknod" is created.
57444 +
57445 +config GRKERNSEC_CHROOT_SHMAT
57446 + bool "Deny shmat() out of chroot"
57447 + default y if GRKERNSEC_CONFIG_AUTO
57448 + depends on GRKERNSEC_CHROOT
57449 + help
57450 + If you say Y here, processes inside a chroot will not be able to attach
57451 + to shared memory segments that were created outside of the chroot jail.
57452 + It is recommended that you say Y here. If the sysctl option is enabled,
57453 + a sysctl option with name "chroot_deny_shmat" is created.
57454 +
57455 +config GRKERNSEC_CHROOT_UNIX
57456 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57457 + default y if GRKERNSEC_CONFIG_AUTO
57458 + depends on GRKERNSEC_CHROOT
57459 + help
57460 + If you say Y here, processes inside a chroot will not be able to
57461 + connect to abstract (meaning not belonging to a filesystem) Unix
57462 + domain sockets that were bound outside of a chroot. It is recommended
57463 + that you say Y here. If the sysctl option is enabled, a sysctl option
57464 + with name "chroot_deny_unix" is created.
57465 +
57466 +config GRKERNSEC_CHROOT_FINDTASK
57467 + bool "Protect outside processes"
57468 + default y if GRKERNSEC_CONFIG_AUTO
57469 + depends on GRKERNSEC_CHROOT
57470 + help
57471 + If you say Y here, processes inside a chroot will not be able to
57472 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57473 + getsid, or view any process outside of the chroot. If the sysctl
57474 + option is enabled, a sysctl option with name "chroot_findtask" is
57475 + created.
57476 +
57477 +config GRKERNSEC_CHROOT_NICE
57478 + bool "Restrict priority changes"
57479 + default y if GRKERNSEC_CONFIG_AUTO
57480 + depends on GRKERNSEC_CHROOT
57481 + help
57482 + If you say Y here, processes inside a chroot will not be able to raise
57483 + the priority of processes in the chroot, or alter the priority of
57484 + processes outside the chroot. This provides more security than simply
57485 + removing CAP_SYS_NICE from the process' capability set. If the
57486 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57487 + is created.
57488 +
57489 +config GRKERNSEC_CHROOT_SYSCTL
57490 + bool "Deny sysctl writes"
57491 + default y if GRKERNSEC_CONFIG_AUTO
57492 + depends on GRKERNSEC_CHROOT
57493 + help
57494 + If you say Y here, an attacker in a chroot will not be able to
57495 + write to sysctl entries, either by sysctl(2) or through a /proc
57496 + interface. It is strongly recommended that you say Y here. If the
57497 + sysctl option is enabled, a sysctl option with name
57498 + "chroot_deny_sysctl" is created.
57499 +
57500 +config GRKERNSEC_CHROOT_CAPS
57501 + bool "Capability restrictions"
57502 + default y if GRKERNSEC_CONFIG_AUTO
57503 + depends on GRKERNSEC_CHROOT
57504 + help
57505 + If you say Y here, the capabilities on all processes within a
57506 + chroot jail will be lowered to stop module insertion, raw i/o,
57507 + system and net admin tasks, rebooting the system, modifying immutable
57508 + files, modifying IPC owned by another, and changing the system time.
57509 + This is left an option because it can break some apps. Disable this
57510 + if your chrooted apps are having problems performing those kinds of
57511 + tasks. If the sysctl option is enabled, a sysctl option with
57512 + name "chroot_caps" is created.
57513 +
57514 +endmenu
57515 +menu "Kernel Auditing"
57516 +depends on GRKERNSEC
57517 +
57518 +config GRKERNSEC_AUDIT_GROUP
57519 + bool "Single group for auditing"
57520 + help
57521 + If you say Y here, the exec and chdir logging features will only operate
57522 + on a group you specify. This option is recommended if you only want to
57523 + watch certain users instead of having a large amount of logs from the
57524 + entire system. If the sysctl option is enabled, a sysctl option with
57525 + name "audit_group" is created.
57526 +
57527 +config GRKERNSEC_AUDIT_GID
57528 + int "GID for auditing"
57529 + depends on GRKERNSEC_AUDIT_GROUP
57530 + default 1007
57531 +
57532 +config GRKERNSEC_EXECLOG
57533 + bool "Exec logging"
57534 + help
57535 + If you say Y here, all execve() calls will be logged (since the
57536 + other exec*() calls are frontends to execve(), all execution
57537 + will be logged). Useful for shell-servers that like to keep track
57538 + of their users. If the sysctl option is enabled, a sysctl option with
57539 + name "exec_logging" is created.
57540 + WARNING: This option when enabled will produce a LOT of logs, especially
57541 + on an active system.
57542 +
57543 +config GRKERNSEC_RESLOG
57544 + bool "Resource logging"
57545 + default y if GRKERNSEC_CONFIG_AUTO
57546 + help
57547 + If you say Y here, all attempts to overstep resource limits will
57548 + be logged with the resource name, the requested size, and the current
57549 + limit. It is highly recommended that you say Y here. If the sysctl
57550 + option is enabled, a sysctl option with name "resource_logging" is
57551 + created. If the RBAC system is enabled, the sysctl value is ignored.
57552 +
57553 +config GRKERNSEC_CHROOT_EXECLOG
57554 + bool "Log execs within chroot"
57555 + help
57556 + If you say Y here, all executions inside a chroot jail will be logged
57557 + to syslog. This can cause a large amount of logs if certain
57558 + applications (eg. djb's daemontools) are installed on the system, and
57559 + is therefore left as an option. If the sysctl option is enabled, a
57560 + sysctl option with name "chroot_execlog" is created.
57561 +
57562 +config GRKERNSEC_AUDIT_PTRACE
57563 + bool "Ptrace logging"
57564 + help
57565 + If you say Y here, all attempts to attach to a process via ptrace
57566 + will be logged. If the sysctl option is enabled, a sysctl option
57567 + with name "audit_ptrace" is created.
57568 +
57569 +config GRKERNSEC_AUDIT_CHDIR
57570 + bool "Chdir logging"
57571 + help
57572 + If you say Y here, all chdir() calls will be logged. If the sysctl
57573 + option is enabled, a sysctl option with name "audit_chdir" is created.
57574 +
57575 +config GRKERNSEC_AUDIT_MOUNT
57576 + bool "(Un)Mount logging"
57577 + help
57578 + If you say Y here, all mounts and unmounts will be logged. If the
57579 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57580 + created.
57581 +
57582 +config GRKERNSEC_SIGNAL
57583 + bool "Signal logging"
57584 + default y if GRKERNSEC_CONFIG_AUTO
57585 + help
57586 + If you say Y here, certain important signals will be logged, such as
57587 + SIGSEGV, which will as a result inform you of when a error in a program
57588 + occurred, which in some cases could mean a possible exploit attempt.
57589 + If the sysctl option is enabled, a sysctl option with name
57590 + "signal_logging" is created.
57591 +
57592 +config GRKERNSEC_FORKFAIL
57593 + bool "Fork failure logging"
57594 + help
57595 + If you say Y here, all failed fork() attempts will be logged.
57596 + This could suggest a fork bomb, or someone attempting to overstep
57597 + their process limit. If the sysctl option is enabled, a sysctl option
57598 + with name "forkfail_logging" is created.
57599 +
57600 +config GRKERNSEC_TIME
57601 + bool "Time change logging"
57602 + default y if GRKERNSEC_CONFIG_AUTO
57603 + help
57604 + If you say Y here, any changes of the system clock will be logged.
57605 + If the sysctl option is enabled, a sysctl option with name
57606 + "timechange_logging" is created.
57607 +
57608 +config GRKERNSEC_PROC_IPADDR
57609 + bool "/proc/<pid>/ipaddr support"
57610 + default y if GRKERNSEC_CONFIG_AUTO
57611 + help
57612 + If you say Y here, a new entry will be added to each /proc/<pid>
57613 + directory that contains the IP address of the person using the task.
57614 + The IP is carried across local TCP and AF_UNIX stream sockets.
57615 + This information can be useful for IDS/IPSes to perform remote response
57616 + to a local attack. The entry is readable by only the owner of the
57617 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57618 + the RBAC system), and thus does not create privacy concerns.
57619 +
57620 +config GRKERNSEC_RWXMAP_LOG
57621 + bool 'Denied RWX mmap/mprotect logging'
57622 + default y if GRKERNSEC_CONFIG_AUTO
57623 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57624 + help
57625 + If you say Y here, calls to mmap() and mprotect() with explicit
57626 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57627 + denied by the PAX_MPROTECT feature. If the sysctl option is
57628 + enabled, a sysctl option with name "rwxmap_logging" is created.
57629 +
57630 +config GRKERNSEC_AUDIT_TEXTREL
57631 + bool 'ELF text relocations logging (READ HELP)'
57632 + depends on PAX_MPROTECT
57633 + help
57634 + If you say Y here, text relocations will be logged with the filename
57635 + of the offending library or binary. The purpose of the feature is
57636 + to help Linux distribution developers get rid of libraries and
57637 + binaries that need text relocations which hinder the future progress
57638 + of PaX. Only Linux distribution developers should say Y here, and
57639 + never on a production machine, as this option creates an information
57640 + leak that could aid an attacker in defeating the randomization of
57641 + a single memory region. If the sysctl option is enabled, a sysctl
57642 + option with name "audit_textrel" is created.
57643 +
57644 +endmenu
57645 +
57646 +menu "Executable Protections"
57647 +depends on GRKERNSEC
57648 +
57649 +config GRKERNSEC_DMESG
57650 + bool "Dmesg(8) restriction"
57651 + default y if GRKERNSEC_CONFIG_AUTO
57652 + help
57653 + If you say Y here, non-root users will not be able to use dmesg(8)
57654 + to view the contents of the kernel's circular log buffer.
57655 + The kernel's log buffer often contains kernel addresses and other
57656 + identifying information useful to an attacker in fingerprinting a
57657 + system for a targeted exploit.
57658 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57659 + created.
57660 +
57661 +config GRKERNSEC_HARDEN_PTRACE
57662 + bool "Deter ptrace-based process snooping"
57663 + default y if GRKERNSEC_CONFIG_AUTO
57664 + help
57665 + If you say Y here, TTY sniffers and other malicious monitoring
57666 + programs implemented through ptrace will be defeated. If you
57667 + have been using the RBAC system, this option has already been
57668 + enabled for several years for all users, with the ability to make
57669 + fine-grained exceptions.
57670 +
57671 + This option only affects the ability of non-root users to ptrace
57672 + processes that are not a descendent of the ptracing process.
57673 + This means that strace ./binary and gdb ./binary will still work,
57674 + but attaching to arbitrary processes will not. If the sysctl
57675 + option is enabled, a sysctl option with name "harden_ptrace" is
57676 + created.
57677 +
57678 +config GRKERNSEC_PTRACE_READEXEC
57679 + bool "Require read access to ptrace sensitive binaries"
57680 + default y if GRKERNSEC_CONFIG_AUTO
57681 + help
57682 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57683 + binaries. This option is useful in environments that
57684 + remove the read bits (e.g. file mode 4711) from suid binaries to
57685 + prevent infoleaking of their contents. This option adds
57686 + consistency to the use of that file mode, as the binary could normally
57687 + be read out when run without privileges while ptracing.
57688 +
57689 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57690 + is created.
57691 +
57692 +config GRKERNSEC_SETXID
57693 + bool "Enforce consistent multithreaded privileges"
57694 + default y if GRKERNSEC_CONFIG_AUTO
57695 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57696 + help
57697 + If you say Y here, a change from a root uid to a non-root uid
57698 + in a multithreaded application will cause the resulting uids,
57699 + gids, supplementary groups, and capabilities in that thread
57700 + to be propagated to the other threads of the process. In most
57701 + cases this is unnecessary, as glibc will emulate this behavior
57702 + on behalf of the application. Other libcs do not act in the
57703 + same way, allowing the other threads of the process to continue
57704 + running with root privileges. If the sysctl option is enabled,
57705 + a sysctl option with name "consistent_setxid" is created.
57706 +
57707 +config GRKERNSEC_TPE
57708 + bool "Trusted Path Execution (TPE)"
57709 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57710 + help
57711 + If you say Y here, you will be able to choose a gid to add to the
57712 + supplementary groups of users you want to mark as "untrusted."
57713 + These users will not be able to execute any files that are not in
57714 + root-owned directories writable only by root. If the sysctl option
57715 + is enabled, a sysctl option with name "tpe" is created.
57716 +
57717 +config GRKERNSEC_TPE_ALL
57718 + bool "Partially restrict all non-root users"
57719 + depends on GRKERNSEC_TPE
57720 + help
57721 + If you say Y here, all non-root users will be covered under
57722 + a weaker TPE restriction. This is separate from, and in addition to,
57723 + the main TPE options that you have selected elsewhere. Thus, if a
57724 + "trusted" GID is chosen, this restriction applies to even that GID.
57725 + Under this restriction, all non-root users will only be allowed to
57726 + execute files in directories they own that are not group or
57727 + world-writable, or in directories owned by root and writable only by
57728 + root. If the sysctl option is enabled, a sysctl option with name
57729 + "tpe_restrict_all" is created.
57730 +
57731 +config GRKERNSEC_TPE_INVERT
57732 + bool "Invert GID option"
57733 + depends on GRKERNSEC_TPE
57734 + help
57735 + If you say Y here, the group you specify in the TPE configuration will
57736 + decide what group TPE restrictions will be *disabled* for. This
57737 + option is useful if you want TPE restrictions to be applied to most
57738 + users on the system. If the sysctl option is enabled, a sysctl option
57739 + with name "tpe_invert" is created. Unlike other sysctl options, this
57740 + entry will default to on for backward-compatibility.
57741 +
57742 +config GRKERNSEC_TPE_GID
57743 + int
57744 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57745 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57746 +
57747 +config GRKERNSEC_TPE_UNTRUSTED_GID
57748 + int "GID for TPE-untrusted users"
57749 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57750 + default 1005
57751 + help
57752 + Setting this GID determines what group TPE restrictions will be
57753 + *enabled* for. If the sysctl option is enabled, a sysctl option
57754 + with name "tpe_gid" is created.
57755 +
57756 +config GRKERNSEC_TPE_TRUSTED_GID
57757 + int "GID for TPE-trusted users"
57758 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57759 + default 1005
57760 + help
57761 + Setting this GID determines what group TPE restrictions will be
57762 + *disabled* for. If the sysctl option is enabled, a sysctl option
57763 + with name "tpe_gid" is created.
57764 +
57765 +endmenu
57766 +menu "Network Protections"
57767 +depends on GRKERNSEC
57768 +
57769 +config GRKERNSEC_RANDNET
57770 + bool "Larger entropy pools"
57771 + default y if GRKERNSEC_CONFIG_AUTO
57772 + help
57773 + If you say Y here, the entropy pools used for many features of Linux
57774 + and grsecurity will be doubled in size. Since several grsecurity
57775 + features use additional randomness, it is recommended that you say Y
57776 + here. Saying Y here has a similar effect as modifying
57777 + /proc/sys/kernel/random/poolsize.
57778 +
57779 +config GRKERNSEC_BLACKHOLE
57780 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57781 + default y if GRKERNSEC_CONFIG_AUTO
57782 + depends on NET
57783 + help
57784 + If you say Y here, neither TCP resets nor ICMP
57785 + destination-unreachable packets will be sent in response to packets
57786 + sent to ports for which no associated listening process exists.
57787 + This feature supports both IPV4 and IPV6 and exempts the
57788 + loopback interface from blackholing. Enabling this feature
57789 + makes a host more resilient to DoS attacks and reduces network
57790 + visibility against scanners.
57791 +
57792 + The blackhole feature as-implemented is equivalent to the FreeBSD
57793 + blackhole feature, as it prevents RST responses to all packets, not
57794 + just SYNs. Under most application behavior this causes no
57795 + problems, but applications (like haproxy) may not close certain
57796 + connections in a way that cleanly terminates them on the remote
57797 + end, leaving the remote host in LAST_ACK state. Because of this
57798 + side-effect and to prevent intentional LAST_ACK DoSes, this
57799 + feature also adds automatic mitigation against such attacks.
57800 + The mitigation drastically reduces the amount of time a socket
57801 + can spend in LAST_ACK state. If you're using haproxy and not
57802 + all servers it connects to have this option enabled, consider
57803 + disabling this feature on the haproxy host.
57804 +
57805 + If the sysctl option is enabled, two sysctl options with names
57806 + "ip_blackhole" and "lastack_retries" will be created.
57807 + While "ip_blackhole" takes the standard zero/non-zero on/off
57808 + toggle, "lastack_retries" uses the same kinds of values as
57809 + "tcp_retries1" and "tcp_retries2". The default value of 4
57810 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57811 + state.
57812 +
57813 +config GRKERNSEC_NO_SIMULT_CONNECT
57814 + bool "Disable TCP Simultaneous Connect"
57815 + default y if GRKERNSEC_CONFIG_AUTO
57816 + depends on NET
57817 + help
57818 + If you say Y here, a feature by Willy Tarreau will be enabled that
57819 + removes a weakness in Linux's strict implementation of TCP that
57820 + allows two clients to connect to each other without either entering
57821 + a listening state. The weakness allows an attacker to easily prevent
57822 + a client from connecting to a known server provided the source port
57823 + for the connection is guessed correctly.
57824 +
57825 + As the weakness could be used to prevent an antivirus or IPS from
57826 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57827 + it should be eliminated by enabling this option. Though Linux is
57828 + one of few operating systems supporting simultaneous connect, it
57829 + has no legitimate use in practice and is rarely supported by firewalls.
57830 +
57831 +config GRKERNSEC_SOCKET
57832 + bool "Socket restrictions"
57833 + depends on NET
57834 + help
57835 + If you say Y here, you will be able to choose from several options.
57836 + If you assign a GID on your system and add it to the supplementary
57837 + groups of users you want to restrict socket access to, this patch
57838 + will perform up to three things, based on the option(s) you choose.
57839 +
57840 +config GRKERNSEC_SOCKET_ALL
57841 + bool "Deny any sockets to group"
57842 + depends on GRKERNSEC_SOCKET
57843 + help
57844 + If you say Y here, you will be able to choose a GID of whose users will
57845 + be unable to connect to other hosts from your machine or run server
57846 + applications from your machine. If the sysctl option is enabled, a
57847 + sysctl option with name "socket_all" is created.
57848 +
57849 +config GRKERNSEC_SOCKET_ALL_GID
57850 + int "GID to deny all sockets for"
57851 + depends on GRKERNSEC_SOCKET_ALL
57852 + default 1004
57853 + help
57854 + Here you can choose the GID to disable socket access for. Remember to
57855 + add the users you want socket access disabled for to the GID
57856 + specified here. If the sysctl option is enabled, a sysctl option
57857 + with name "socket_all_gid" is created.
57858 +
57859 +config GRKERNSEC_SOCKET_CLIENT
57860 + bool "Deny client sockets to group"
57861 + depends on GRKERNSEC_SOCKET
57862 + help
57863 + If you say Y here, you will be able to choose a GID of whose users will
57864 + be unable to connect to other hosts from your machine, but will be
57865 + able to run servers. If this option is enabled, all users in the group
57866 + you specify will have to use passive mode when initiating ftp transfers
57867 + from the shell on your machine. If the sysctl option is enabled, a
57868 + sysctl option with name "socket_client" is created.
57869 +
57870 +config GRKERNSEC_SOCKET_CLIENT_GID
57871 + int "GID to deny client sockets for"
57872 + depends on GRKERNSEC_SOCKET_CLIENT
57873 + default 1003
57874 + help
57875 + Here you can choose the GID to disable client socket access for.
57876 + Remember to add the users you want client socket access disabled for to
57877 + the GID specified here. If the sysctl option is enabled, a sysctl
57878 + option with name "socket_client_gid" is created.
57879 +
57880 +config GRKERNSEC_SOCKET_SERVER
57881 + bool "Deny server sockets to group"
57882 + depends on GRKERNSEC_SOCKET
57883 + help
57884 + If you say Y here, you will be able to choose a GID of whose users will
57885 + be unable to run server applications from your machine. If the sysctl
57886 + option is enabled, a sysctl option with name "socket_server" is created.
57887 +
57888 +config GRKERNSEC_SOCKET_SERVER_GID
57889 + int "GID to deny server sockets for"
57890 + depends on GRKERNSEC_SOCKET_SERVER
57891 + default 1002
57892 + help
57893 + Here you can choose the GID to disable server socket access for.
57894 + Remember to add the users you want server socket access disabled for to
57895 + the GID specified here. If the sysctl option is enabled, a sysctl
57896 + option with name "socket_server_gid" is created.
57897 +
57898 +endmenu
57899 +menu "Sysctl Support"
57900 +depends on GRKERNSEC && SYSCTL
57901 +
57902 +config GRKERNSEC_SYSCTL
57903 + bool "Sysctl support"
57904 + default y if GRKERNSEC_CONFIG_AUTO
57905 + help
57906 + If you say Y here, you will be able to change the options that
57907 + grsecurity runs with at bootup, without having to recompile your
57908 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57909 + to enable (1) or disable (0) various features. All the sysctl entries
57910 + are mutable until the "grsec_lock" entry is set to a non-zero value.
57911 + All features enabled in the kernel configuration are disabled at boot
57912 + if you do not say Y to the "Turn on features by default" option.
57913 + All options should be set at startup, and the grsec_lock entry should
57914 + be set to a non-zero value after all the options are set.
57915 + *THIS IS EXTREMELY IMPORTANT*
57916 +
57917 +config GRKERNSEC_SYSCTL_DISTRO
57918 + bool "Extra sysctl support for distro makers (READ HELP)"
57919 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
57920 + help
57921 + If you say Y here, additional sysctl options will be created
57922 + for features that affect processes running as root. Therefore,
57923 + it is critical when using this option that the grsec_lock entry be
57924 + enabled after boot. Only distros with prebuilt kernel packages
57925 + with this option enabled that can ensure grsec_lock is enabled
57926 + after boot should use this option.
57927 + *Failure to set grsec_lock after boot makes all grsec features
57928 + this option covers useless*
57929 +
57930 + Currently this option creates the following sysctl entries:
57931 + "Disable Privileged I/O": "disable_priv_io"
57932 +
57933 +config GRKERNSEC_SYSCTL_ON
57934 + bool "Turn on features by default"
57935 + default y if GRKERNSEC_CONFIG_AUTO
57936 + depends on GRKERNSEC_SYSCTL
57937 + help
57938 + If you say Y here, instead of having all features enabled in the
57939 + kernel configuration disabled at boot time, the features will be
57940 + enabled at boot time. It is recommended you say Y here unless
57941 + there is some reason you would want all sysctl-tunable features to
57942 + be disabled by default. As mentioned elsewhere, it is important
57943 + to enable the grsec_lock entry once you have finished modifying
57944 + the sysctl entries.
57945 +
57946 +endmenu
57947 +menu "Logging Options"
57948 +depends on GRKERNSEC
57949 +
57950 +config GRKERNSEC_FLOODTIME
57951 + int "Seconds in between log messages (minimum)"
57952 + default 10
57953 + help
57954 + This option allows you to enforce the number of seconds between
57955 + grsecurity log messages. The default should be suitable for most
57956 + people, however, if you choose to change it, choose a value small enough
57957 + to allow informative logs to be produced, but large enough to
57958 + prevent flooding.
57959 +
57960 +config GRKERNSEC_FLOODBURST
57961 + int "Number of messages in a burst (maximum)"
57962 + default 6
57963 + help
57964 + This option allows you to choose the maximum number of messages allowed
57965 + within the flood time interval you chose in a separate option. The
57966 + default should be suitable for most people, however if you find that
57967 + many of your logs are being interpreted as flooding, you may want to
57968 + raise this value.
57969 +
57970 +endmenu
57971 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
57972 new file mode 100644
57973 index 0000000..1b9afa9
57974 --- /dev/null
57975 +++ b/grsecurity/Makefile
57976 @@ -0,0 +1,38 @@
57977 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
57978 +# during 2001-2009 it has been completely redesigned by Brad Spengler
57979 +# into an RBAC system
57980 +#
57981 +# All code in this directory and various hooks inserted throughout the kernel
57982 +# are copyright Brad Spengler - Open Source Security, Inc., and released
57983 +# under the GPL v2 or higher
57984 +
57985 +KBUILD_CFLAGS += -Werror
57986 +
57987 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
57988 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
57989 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
57990 +
57991 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
57992 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
57993 + gracl_learn.o grsec_log.o
57994 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
57995 +
57996 +ifdef CONFIG_NET
57997 +obj-y += grsec_sock.o
57998 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
57999 +endif
58000 +
58001 +ifndef CONFIG_GRKERNSEC
58002 +obj-y += grsec_disabled.o
58003 +endif
58004 +
58005 +ifdef CONFIG_GRKERNSEC_HIDESYM
58006 +extra-y := grsec_hidesym.o
58007 +$(obj)/grsec_hidesym.o:
58008 + @-chmod -f 500 /boot
58009 + @-chmod -f 500 /lib/modules
58010 + @-chmod -f 500 /lib64/modules
58011 + @-chmod -f 500 /lib32/modules
58012 + @-chmod -f 700 .
58013 + @echo ' grsec: protected kernel image paths'
58014 +endif
58015 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58016 new file mode 100644
58017 index 0000000..b306b36
58018 --- /dev/null
58019 +++ b/grsecurity/gracl.c
58020 @@ -0,0 +1,4071 @@
58021 +#include <linux/kernel.h>
58022 +#include <linux/module.h>
58023 +#include <linux/sched.h>
58024 +#include <linux/mm.h>
58025 +#include <linux/file.h>
58026 +#include <linux/fs.h>
58027 +#include <linux/namei.h>
58028 +#include <linux/mount.h>
58029 +#include <linux/tty.h>
58030 +#include <linux/proc_fs.h>
58031 +#include <linux/lglock.h>
58032 +#include <linux/slab.h>
58033 +#include <linux/vmalloc.h>
58034 +#include <linux/types.h>
58035 +#include <linux/sysctl.h>
58036 +#include <linux/netdevice.h>
58037 +#include <linux/ptrace.h>
58038 +#include <linux/gracl.h>
58039 +#include <linux/gralloc.h>
58040 +#include <linux/security.h>
58041 +#include <linux/grinternal.h>
58042 +#include <linux/pid_namespace.h>
58043 +#include <linux/stop_machine.h>
58044 +#include <linux/fdtable.h>
58045 +#include <linux/percpu.h>
58046 +#include <linux/lglock.h>
58047 +#include <linux/hugetlb.h>
58048 +#include <linux/posix-timers.h>
58049 +#include "../fs/mount.h"
58050 +
58051 +#include <asm/uaccess.h>
58052 +#include <asm/errno.h>
58053 +#include <asm/mman.h>
58054 +
58055 +extern struct lglock vfsmount_lock;
58056 +
58057 +static struct acl_role_db acl_role_set;
58058 +static struct name_db name_set;
58059 +static struct inodev_db inodev_set;
58060 +
58061 +/* for keeping track of userspace pointers used for subjects, so we
58062 + can share references in the kernel as well
58063 +*/
58064 +
58065 +static struct path real_root;
58066 +
58067 +static struct acl_subj_map_db subj_map_set;
58068 +
58069 +static struct acl_role_label *default_role;
58070 +
58071 +static struct acl_role_label *role_list;
58072 +
58073 +static u16 acl_sp_role_value;
58074 +
58075 +extern char *gr_shared_page[4];
58076 +static DEFINE_MUTEX(gr_dev_mutex);
58077 +DEFINE_RWLOCK(gr_inode_lock);
58078 +
58079 +struct gr_arg *gr_usermode;
58080 +
58081 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58082 +
58083 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58084 +extern void gr_clear_learn_entries(void);
58085 +
58086 +unsigned char *gr_system_salt;
58087 +unsigned char *gr_system_sum;
58088 +
58089 +static struct sprole_pw **acl_special_roles = NULL;
58090 +static __u16 num_sprole_pws = 0;
58091 +
58092 +static struct acl_role_label *kernel_role = NULL;
58093 +
58094 +static unsigned int gr_auth_attempts = 0;
58095 +static unsigned long gr_auth_expires = 0UL;
58096 +
58097 +#ifdef CONFIG_NET
58098 +extern struct vfsmount *sock_mnt;
58099 +#endif
58100 +
58101 +extern struct vfsmount *pipe_mnt;
58102 +extern struct vfsmount *shm_mnt;
58103 +
58104 +#ifdef CONFIG_HUGETLBFS
58105 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58106 +#endif
58107 +
58108 +static struct acl_object_label *fakefs_obj_rw;
58109 +static struct acl_object_label *fakefs_obj_rwx;
58110 +
58111 +extern int gr_init_uidset(void);
58112 +extern void gr_free_uidset(void);
58113 +extern void gr_remove_uid(uid_t uid);
58114 +extern int gr_find_uid(uid_t uid);
58115 +
58116 +__inline__ int
58117 +gr_acl_is_enabled(void)
58118 +{
58119 + return (gr_status & GR_READY);
58120 +}
58121 +
58122 +#ifdef CONFIG_BTRFS_FS
58123 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
58124 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
58125 +#endif
58126 +
58127 +static inline dev_t __get_dev(const struct dentry *dentry)
58128 +{
58129 +#ifdef CONFIG_BTRFS_FS
58130 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
58131 + return get_btrfs_dev_from_inode(dentry->d_inode);
58132 + else
58133 +#endif
58134 + return dentry->d_inode->i_sb->s_dev;
58135 +}
58136 +
58137 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58138 +{
58139 + return __get_dev(dentry);
58140 +}
58141 +
58142 +static char gr_task_roletype_to_char(struct task_struct *task)
58143 +{
58144 + switch (task->role->roletype &
58145 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58146 + GR_ROLE_SPECIAL)) {
58147 + case GR_ROLE_DEFAULT:
58148 + return 'D';
58149 + case GR_ROLE_USER:
58150 + return 'U';
58151 + case GR_ROLE_GROUP:
58152 + return 'G';
58153 + case GR_ROLE_SPECIAL:
58154 + return 'S';
58155 + }
58156 +
58157 + return 'X';
58158 +}
58159 +
58160 +char gr_roletype_to_char(void)
58161 +{
58162 + return gr_task_roletype_to_char(current);
58163 +}
58164 +
58165 +__inline__ int
58166 +gr_acl_tpe_check(void)
58167 +{
58168 + if (unlikely(!(gr_status & GR_READY)))
58169 + return 0;
58170 + if (current->role->roletype & GR_ROLE_TPE)
58171 + return 1;
58172 + else
58173 + return 0;
58174 +}
58175 +
58176 +int
58177 +gr_handle_rawio(const struct inode *inode)
58178 +{
58179 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58180 + if (inode && S_ISBLK(inode->i_mode) &&
58181 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58182 + !capable(CAP_SYS_RAWIO))
58183 + return 1;
58184 +#endif
58185 + return 0;
58186 +}
58187 +
58188 +static int
58189 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58190 +{
58191 + if (likely(lena != lenb))
58192 + return 0;
58193 +
58194 + return !memcmp(a, b, lena);
58195 +}
58196 +
58197 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58198 +{
58199 + *buflen -= namelen;
58200 + if (*buflen < 0)
58201 + return -ENAMETOOLONG;
58202 + *buffer -= namelen;
58203 + memcpy(*buffer, str, namelen);
58204 + return 0;
58205 +}
58206 +
58207 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58208 +{
58209 + return prepend(buffer, buflen, name->name, name->len);
58210 +}
58211 +
58212 +static int prepend_path(const struct path *path, struct path *root,
58213 + char **buffer, int *buflen)
58214 +{
58215 + struct dentry *dentry = path->dentry;
58216 + struct vfsmount *vfsmnt = path->mnt;
58217 + struct mount *mnt = real_mount(vfsmnt);
58218 + bool slash = false;
58219 + int error = 0;
58220 +
58221 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58222 + struct dentry * parent;
58223 +
58224 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58225 + /* Global root? */
58226 + if (!mnt_has_parent(mnt)) {
58227 + goto out;
58228 + }
58229 + dentry = mnt->mnt_mountpoint;
58230 + mnt = mnt->mnt_parent;
58231 + vfsmnt = &mnt->mnt;
58232 + continue;
58233 + }
58234 + parent = dentry->d_parent;
58235 + prefetch(parent);
58236 + spin_lock(&dentry->d_lock);
58237 + error = prepend_name(buffer, buflen, &dentry->d_name);
58238 + spin_unlock(&dentry->d_lock);
58239 + if (!error)
58240 + error = prepend(buffer, buflen, "/", 1);
58241 + if (error)
58242 + break;
58243 +
58244 + slash = true;
58245 + dentry = parent;
58246 + }
58247 +
58248 +out:
58249 + if (!error && !slash)
58250 + error = prepend(buffer, buflen, "/", 1);
58251 +
58252 + return error;
58253 +}
58254 +
58255 +/* this must be called with vfsmount_lock and rename_lock held */
58256 +
58257 +static char *__our_d_path(const struct path *path, struct path *root,
58258 + char *buf, int buflen)
58259 +{
58260 + char *res = buf + buflen;
58261 + int error;
58262 +
58263 + prepend(&res, &buflen, "\0", 1);
58264 + error = prepend_path(path, root, &res, &buflen);
58265 + if (error)
58266 + return ERR_PTR(error);
58267 +
58268 + return res;
58269 +}
58270 +
58271 +static char *
58272 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58273 +{
58274 + char *retval;
58275 +
58276 + retval = __our_d_path(path, root, buf, buflen);
58277 + if (unlikely(IS_ERR(retval)))
58278 + retval = strcpy(buf, "<path too long>");
58279 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58280 + retval[1] = '\0';
58281 +
58282 + return retval;
58283 +}
58284 +
58285 +static char *
58286 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58287 + char *buf, int buflen)
58288 +{
58289 + struct path path;
58290 + char *res;
58291 +
58292 + path.dentry = (struct dentry *)dentry;
58293 + path.mnt = (struct vfsmount *)vfsmnt;
58294 +
58295 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58296 + by the RBAC system */
58297 + res = gen_full_path(&path, &real_root, buf, buflen);
58298 +
58299 + return res;
58300 +}
58301 +
58302 +static char *
58303 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58304 + char *buf, int buflen)
58305 +{
58306 + char *res;
58307 + struct path path;
58308 + struct path root;
58309 + struct task_struct *reaper = init_pid_ns.child_reaper;
58310 +
58311 + path.dentry = (struct dentry *)dentry;
58312 + path.mnt = (struct vfsmount *)vfsmnt;
58313 +
58314 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58315 + get_fs_root(reaper->fs, &root);
58316 +
58317 + br_read_lock(&vfsmount_lock);
58318 + write_seqlock(&rename_lock);
58319 + res = gen_full_path(&path, &root, buf, buflen);
58320 + write_sequnlock(&rename_lock);
58321 + br_read_unlock(&vfsmount_lock);
58322 +
58323 + path_put(&root);
58324 + return res;
58325 +}
58326 +
58327 +static char *
58328 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58329 +{
58330 + char *ret;
58331 + br_read_lock(&vfsmount_lock);
58332 + write_seqlock(&rename_lock);
58333 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58334 + PAGE_SIZE);
58335 + write_sequnlock(&rename_lock);
58336 + br_read_unlock(&vfsmount_lock);
58337 + return ret;
58338 +}
58339 +
58340 +static char *
58341 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58342 +{
58343 + char *ret;
58344 + char *buf;
58345 + int buflen;
58346 +
58347 + br_read_lock(&vfsmount_lock);
58348 + write_seqlock(&rename_lock);
58349 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58350 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58351 + buflen = (int)(ret - buf);
58352 + if (buflen >= 5)
58353 + prepend(&ret, &buflen, "/proc", 5);
58354 + else
58355 + ret = strcpy(buf, "<path too long>");
58356 + write_sequnlock(&rename_lock);
58357 + br_read_unlock(&vfsmount_lock);
58358 + return ret;
58359 +}
58360 +
58361 +char *
58362 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58363 +{
58364 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58365 + PAGE_SIZE);
58366 +}
58367 +
58368 +char *
58369 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58370 +{
58371 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58372 + PAGE_SIZE);
58373 +}
58374 +
58375 +char *
58376 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58377 +{
58378 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58379 + PAGE_SIZE);
58380 +}
58381 +
58382 +char *
58383 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58384 +{
58385 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58386 + PAGE_SIZE);
58387 +}
58388 +
58389 +char *
58390 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58391 +{
58392 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58393 + PAGE_SIZE);
58394 +}
58395 +
58396 +__inline__ __u32
58397 +to_gr_audit(const __u32 reqmode)
58398 +{
58399 + /* masks off auditable permission flags, then shifts them to create
58400 + auditing flags, and adds the special case of append auditing if
58401 + we're requesting write */
58402 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58403 +}
58404 +
58405 +struct acl_subject_label *
58406 +lookup_subject_map(const struct acl_subject_label *userp)
58407 +{
58408 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58409 + struct subject_map *match;
58410 +
58411 + match = subj_map_set.s_hash[index];
58412 +
58413 + while (match && match->user != userp)
58414 + match = match->next;
58415 +
58416 + if (match != NULL)
58417 + return match->kernel;
58418 + else
58419 + return NULL;
58420 +}
58421 +
58422 +static void
58423 +insert_subj_map_entry(struct subject_map *subjmap)
58424 +{
58425 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58426 + struct subject_map **curr;
58427 +
58428 + subjmap->prev = NULL;
58429 +
58430 + curr = &subj_map_set.s_hash[index];
58431 + if (*curr != NULL)
58432 + (*curr)->prev = subjmap;
58433 +
58434 + subjmap->next = *curr;
58435 + *curr = subjmap;
58436 +
58437 + return;
58438 +}
58439 +
58440 +static struct acl_role_label *
58441 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58442 + const gid_t gid)
58443 +{
58444 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58445 + struct acl_role_label *match;
58446 + struct role_allowed_ip *ipp;
58447 + unsigned int x;
58448 + u32 curr_ip = task->signal->curr_ip;
58449 +
58450 + task->signal->saved_ip = curr_ip;
58451 +
58452 + match = acl_role_set.r_hash[index];
58453 +
58454 + while (match) {
58455 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58456 + for (x = 0; x < match->domain_child_num; x++) {
58457 + if (match->domain_children[x] == uid)
58458 + goto found;
58459 + }
58460 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58461 + break;
58462 + match = match->next;
58463 + }
58464 +found:
58465 + if (match == NULL) {
58466 + try_group:
58467 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58468 + match = acl_role_set.r_hash[index];
58469 +
58470 + while (match) {
58471 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58472 + for (x = 0; x < match->domain_child_num; x++) {
58473 + if (match->domain_children[x] == gid)
58474 + goto found2;
58475 + }
58476 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58477 + break;
58478 + match = match->next;
58479 + }
58480 +found2:
58481 + if (match == NULL)
58482 + match = default_role;
58483 + if (match->allowed_ips == NULL)
58484 + return match;
58485 + else {
58486 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58487 + if (likely
58488 + ((ntohl(curr_ip) & ipp->netmask) ==
58489 + (ntohl(ipp->addr) & ipp->netmask)))
58490 + return match;
58491 + }
58492 + match = default_role;
58493 + }
58494 + } else if (match->allowed_ips == NULL) {
58495 + return match;
58496 + } else {
58497 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58498 + if (likely
58499 + ((ntohl(curr_ip) & ipp->netmask) ==
58500 + (ntohl(ipp->addr) & ipp->netmask)))
58501 + return match;
58502 + }
58503 + goto try_group;
58504 + }
58505 +
58506 + return match;
58507 +}
58508 +
58509 +struct acl_subject_label *
58510 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58511 + const struct acl_role_label *role)
58512 +{
58513 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58514 + struct acl_subject_label *match;
58515 +
58516 + match = role->subj_hash[index];
58517 +
58518 + while (match && (match->inode != ino || match->device != dev ||
58519 + (match->mode & GR_DELETED))) {
58520 + match = match->next;
58521 + }
58522 +
58523 + if (match && !(match->mode & GR_DELETED))
58524 + return match;
58525 + else
58526 + return NULL;
58527 +}
58528 +
58529 +struct acl_subject_label *
58530 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58531 + const struct acl_role_label *role)
58532 +{
58533 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58534 + struct acl_subject_label *match;
58535 +
58536 + match = role->subj_hash[index];
58537 +
58538 + while (match && (match->inode != ino || match->device != dev ||
58539 + !(match->mode & GR_DELETED))) {
58540 + match = match->next;
58541 + }
58542 +
58543 + if (match && (match->mode & GR_DELETED))
58544 + return match;
58545 + else
58546 + return NULL;
58547 +}
58548 +
58549 +static struct acl_object_label *
58550 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58551 + const struct acl_subject_label *subj)
58552 +{
58553 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58554 + struct acl_object_label *match;
58555 +
58556 + match = subj->obj_hash[index];
58557 +
58558 + while (match && (match->inode != ino || match->device != dev ||
58559 + (match->mode & GR_DELETED))) {
58560 + match = match->next;
58561 + }
58562 +
58563 + if (match && !(match->mode & GR_DELETED))
58564 + return match;
58565 + else
58566 + return NULL;
58567 +}
58568 +
58569 +static struct acl_object_label *
58570 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58571 + const struct acl_subject_label *subj)
58572 +{
58573 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58574 + struct acl_object_label *match;
58575 +
58576 + match = subj->obj_hash[index];
58577 +
58578 + while (match && (match->inode != ino || match->device != dev ||
58579 + !(match->mode & GR_DELETED))) {
58580 + match = match->next;
58581 + }
58582 +
58583 + if (match && (match->mode & GR_DELETED))
58584 + return match;
58585 +
58586 + match = subj->obj_hash[index];
58587 +
58588 + while (match && (match->inode != ino || match->device != dev ||
58589 + (match->mode & GR_DELETED))) {
58590 + match = match->next;
58591 + }
58592 +
58593 + if (match && !(match->mode & GR_DELETED))
58594 + return match;
58595 + else
58596 + return NULL;
58597 +}
58598 +
58599 +static struct name_entry *
58600 +lookup_name_entry(const char *name)
58601 +{
58602 + unsigned int len = strlen(name);
58603 + unsigned int key = full_name_hash(name, len);
58604 + unsigned int index = key % name_set.n_size;
58605 + struct name_entry *match;
58606 +
58607 + match = name_set.n_hash[index];
58608 +
58609 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58610 + match = match->next;
58611 +
58612 + return match;
58613 +}
58614 +
58615 +static struct name_entry *
58616 +lookup_name_entry_create(const char *name)
58617 +{
58618 + unsigned int len = strlen(name);
58619 + unsigned int key = full_name_hash(name, len);
58620 + unsigned int index = key % name_set.n_size;
58621 + struct name_entry *match;
58622 +
58623 + match = name_set.n_hash[index];
58624 +
58625 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58626 + !match->deleted))
58627 + match = match->next;
58628 +
58629 + if (match && match->deleted)
58630 + return match;
58631 +
58632 + match = name_set.n_hash[index];
58633 +
58634 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58635 + match->deleted))
58636 + match = match->next;
58637 +
58638 + if (match && !match->deleted)
58639 + return match;
58640 + else
58641 + return NULL;
58642 +}
58643 +
58644 +static struct inodev_entry *
58645 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58646 +{
58647 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58648 + struct inodev_entry *match;
58649 +
58650 + match = inodev_set.i_hash[index];
58651 +
58652 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58653 + match = match->next;
58654 +
58655 + return match;
58656 +}
58657 +
58658 +static void
58659 +insert_inodev_entry(struct inodev_entry *entry)
58660 +{
58661 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58662 + inodev_set.i_size);
58663 + struct inodev_entry **curr;
58664 +
58665 + entry->prev = NULL;
58666 +
58667 + curr = &inodev_set.i_hash[index];
58668 + if (*curr != NULL)
58669 + (*curr)->prev = entry;
58670 +
58671 + entry->next = *curr;
58672 + *curr = entry;
58673 +
58674 + return;
58675 +}
58676 +
58677 +static void
58678 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58679 +{
58680 + unsigned int index =
58681 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58682 + struct acl_role_label **curr;
58683 + struct acl_role_label *tmp, *tmp2;
58684 +
58685 + curr = &acl_role_set.r_hash[index];
58686 +
58687 + /* simple case, slot is empty, just set it to our role */
58688 + if (*curr == NULL) {
58689 + *curr = role;
58690 + } else {
58691 + /* example:
58692 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58693 + 2 -> 3
58694 + */
58695 + /* first check to see if we can already be reached via this slot */
58696 + tmp = *curr;
58697 + while (tmp && tmp != role)
58698 + tmp = tmp->next;
58699 + if (tmp == role) {
58700 + /* we don't need to add ourselves to this slot's chain */
58701 + return;
58702 + }
58703 + /* we need to add ourselves to this chain, two cases */
58704 + if (role->next == NULL) {
58705 + /* simple case, append the current chain to our role */
58706 + role->next = *curr;
58707 + *curr = role;
58708 + } else {
58709 + /* 1 -> 2 -> 3 -> 4
58710 + 2 -> 3 -> 4
58711 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58712 + */
58713 + /* trickier case: walk our role's chain until we find
58714 + the role for the start of the current slot's chain */
58715 + tmp = role;
58716 + tmp2 = *curr;
58717 + while (tmp->next && tmp->next != tmp2)
58718 + tmp = tmp->next;
58719 + if (tmp->next == tmp2) {
58720 + /* from example above, we found 3, so just
58721 + replace this slot's chain with ours */
58722 + *curr = role;
58723 + } else {
58724 + /* we didn't find a subset of our role's chain
58725 + in the current slot's chain, so append their
58726 + chain to ours, and set us as the first role in
58727 + the slot's chain
58728 +
58729 + we could fold this case with the case above,
58730 + but making it explicit for clarity
58731 + */
58732 + tmp->next = tmp2;
58733 + *curr = role;
58734 + }
58735 + }
58736 + }
58737 +
58738 + return;
58739 +}
58740 +
58741 +static void
58742 +insert_acl_role_label(struct acl_role_label *role)
58743 +{
58744 + int i;
58745 +
58746 + if (role_list == NULL) {
58747 + role_list = role;
58748 + role->prev = NULL;
58749 + } else {
58750 + role->prev = role_list;
58751 + role_list = role;
58752 + }
58753 +
58754 + /* used for hash chains */
58755 + role->next = NULL;
58756 +
58757 + if (role->roletype & GR_ROLE_DOMAIN) {
58758 + for (i = 0; i < role->domain_child_num; i++)
58759 + __insert_acl_role_label(role, role->domain_children[i]);
58760 + } else
58761 + __insert_acl_role_label(role, role->uidgid);
58762 +}
58763 +
58764 +static int
58765 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58766 +{
58767 + struct name_entry **curr, *nentry;
58768 + struct inodev_entry *ientry;
58769 + unsigned int len = strlen(name);
58770 + unsigned int key = full_name_hash(name, len);
58771 + unsigned int index = key % name_set.n_size;
58772 +
58773 + curr = &name_set.n_hash[index];
58774 +
58775 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58776 + curr = &((*curr)->next);
58777 +
58778 + if (*curr != NULL)
58779 + return 1;
58780 +
58781 + nentry = acl_alloc(sizeof (struct name_entry));
58782 + if (nentry == NULL)
58783 + return 0;
58784 + ientry = acl_alloc(sizeof (struct inodev_entry));
58785 + if (ientry == NULL)
58786 + return 0;
58787 + ientry->nentry = nentry;
58788 +
58789 + nentry->key = key;
58790 + nentry->name = name;
58791 + nentry->inode = inode;
58792 + nentry->device = device;
58793 + nentry->len = len;
58794 + nentry->deleted = deleted;
58795 +
58796 + nentry->prev = NULL;
58797 + curr = &name_set.n_hash[index];
58798 + if (*curr != NULL)
58799 + (*curr)->prev = nentry;
58800 + nentry->next = *curr;
58801 + *curr = nentry;
58802 +
58803 + /* insert us into the table searchable by inode/dev */
58804 + insert_inodev_entry(ientry);
58805 +
58806 + return 1;
58807 +}
58808 +
58809 +static void
58810 +insert_acl_obj_label(struct acl_object_label *obj,
58811 + struct acl_subject_label *subj)
58812 +{
58813 + unsigned int index =
58814 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58815 + struct acl_object_label **curr;
58816 +
58817 +
58818 + obj->prev = NULL;
58819 +
58820 + curr = &subj->obj_hash[index];
58821 + if (*curr != NULL)
58822 + (*curr)->prev = obj;
58823 +
58824 + obj->next = *curr;
58825 + *curr = obj;
58826 +
58827 + return;
58828 +}
58829 +
58830 +static void
58831 +insert_acl_subj_label(struct acl_subject_label *obj,
58832 + struct acl_role_label *role)
58833 +{
58834 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58835 + struct acl_subject_label **curr;
58836 +
58837 + obj->prev = NULL;
58838 +
58839 + curr = &role->subj_hash[index];
58840 + if (*curr != NULL)
58841 + (*curr)->prev = obj;
58842 +
58843 + obj->next = *curr;
58844 + *curr = obj;
58845 +
58846 + return;
58847 +}
58848 +
58849 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58850 +
58851 +static void *
58852 +create_table(__u32 * len, int elementsize)
58853 +{
58854 + unsigned int table_sizes[] = {
58855 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58856 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58857 + 4194301, 8388593, 16777213, 33554393, 67108859
58858 + };
58859 + void *newtable = NULL;
58860 + unsigned int pwr = 0;
58861 +
58862 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58863 + table_sizes[pwr] <= *len)
58864 + pwr++;
58865 +
58866 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58867 + return newtable;
58868 +
58869 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58870 + newtable =
58871 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58872 + else
58873 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58874 +
58875 + *len = table_sizes[pwr];
58876 +
58877 + return newtable;
58878 +}
58879 +
58880 +static int
58881 +init_variables(const struct gr_arg *arg)
58882 +{
58883 + struct task_struct *reaper = init_pid_ns.child_reaper;
58884 + unsigned int stacksize;
58885 +
58886 + subj_map_set.s_size = arg->role_db.num_subjects;
58887 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58888 + name_set.n_size = arg->role_db.num_objects;
58889 + inodev_set.i_size = arg->role_db.num_objects;
58890 +
58891 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58892 + !name_set.n_size || !inodev_set.i_size)
58893 + return 1;
58894 +
58895 + if (!gr_init_uidset())
58896 + return 1;
58897 +
58898 + /* set up the stack that holds allocation info */
58899 +
58900 + stacksize = arg->role_db.num_pointers + 5;
58901 +
58902 + if (!acl_alloc_stack_init(stacksize))
58903 + return 1;
58904 +
58905 + /* grab reference for the real root dentry and vfsmount */
58906 + get_fs_root(reaper->fs, &real_root);
58907 +
58908 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58909 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
58910 +#endif
58911 +
58912 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
58913 + if (fakefs_obj_rw == NULL)
58914 + return 1;
58915 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
58916 +
58917 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
58918 + if (fakefs_obj_rwx == NULL)
58919 + return 1;
58920 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
58921 +
58922 + subj_map_set.s_hash =
58923 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
58924 + acl_role_set.r_hash =
58925 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
58926 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
58927 + inodev_set.i_hash =
58928 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
58929 +
58930 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
58931 + !name_set.n_hash || !inodev_set.i_hash)
58932 + return 1;
58933 +
58934 + memset(subj_map_set.s_hash, 0,
58935 + sizeof(struct subject_map *) * subj_map_set.s_size);
58936 + memset(acl_role_set.r_hash, 0,
58937 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
58938 + memset(name_set.n_hash, 0,
58939 + sizeof (struct name_entry *) * name_set.n_size);
58940 + memset(inodev_set.i_hash, 0,
58941 + sizeof (struct inodev_entry *) * inodev_set.i_size);
58942 +
58943 + return 0;
58944 +}
58945 +
58946 +/* free information not needed after startup
58947 + currently contains user->kernel pointer mappings for subjects
58948 +*/
58949 +
58950 +static void
58951 +free_init_variables(void)
58952 +{
58953 + __u32 i;
58954 +
58955 + if (subj_map_set.s_hash) {
58956 + for (i = 0; i < subj_map_set.s_size; i++) {
58957 + if (subj_map_set.s_hash[i]) {
58958 + kfree(subj_map_set.s_hash[i]);
58959 + subj_map_set.s_hash[i] = NULL;
58960 + }
58961 + }
58962 +
58963 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
58964 + PAGE_SIZE)
58965 + kfree(subj_map_set.s_hash);
58966 + else
58967 + vfree(subj_map_set.s_hash);
58968 + }
58969 +
58970 + return;
58971 +}
58972 +
58973 +static void
58974 +free_variables(void)
58975 +{
58976 + struct acl_subject_label *s;
58977 + struct acl_role_label *r;
58978 + struct task_struct *task, *task2;
58979 + unsigned int x;
58980 +
58981 + gr_clear_learn_entries();
58982 +
58983 + read_lock(&tasklist_lock);
58984 + do_each_thread(task2, task) {
58985 + task->acl_sp_role = 0;
58986 + task->acl_role_id = 0;
58987 + task->acl = NULL;
58988 + task->role = NULL;
58989 + } while_each_thread(task2, task);
58990 + read_unlock(&tasklist_lock);
58991 +
58992 + /* release the reference to the real root dentry and vfsmount */
58993 + path_put(&real_root);
58994 + memset(&real_root, 0, sizeof(real_root));
58995 +
58996 + /* free all object hash tables */
58997 +
58998 + FOR_EACH_ROLE_START(r)
58999 + if (r->subj_hash == NULL)
59000 + goto next_role;
59001 + FOR_EACH_SUBJECT_START(r, s, x)
59002 + if (s->obj_hash == NULL)
59003 + break;
59004 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59005 + kfree(s->obj_hash);
59006 + else
59007 + vfree(s->obj_hash);
59008 + FOR_EACH_SUBJECT_END(s, x)
59009 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59010 + if (s->obj_hash == NULL)
59011 + break;
59012 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59013 + kfree(s->obj_hash);
59014 + else
59015 + vfree(s->obj_hash);
59016 + FOR_EACH_NESTED_SUBJECT_END(s)
59017 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59018 + kfree(r->subj_hash);
59019 + else
59020 + vfree(r->subj_hash);
59021 + r->subj_hash = NULL;
59022 +next_role:
59023 + FOR_EACH_ROLE_END(r)
59024 +
59025 + acl_free_all();
59026 +
59027 + if (acl_role_set.r_hash) {
59028 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59029 + PAGE_SIZE)
59030 + kfree(acl_role_set.r_hash);
59031 + else
59032 + vfree(acl_role_set.r_hash);
59033 + }
59034 + if (name_set.n_hash) {
59035 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59036 + PAGE_SIZE)
59037 + kfree(name_set.n_hash);
59038 + else
59039 + vfree(name_set.n_hash);
59040 + }
59041 +
59042 + if (inodev_set.i_hash) {
59043 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59044 + PAGE_SIZE)
59045 + kfree(inodev_set.i_hash);
59046 + else
59047 + vfree(inodev_set.i_hash);
59048 + }
59049 +
59050 + gr_free_uidset();
59051 +
59052 + memset(&name_set, 0, sizeof (struct name_db));
59053 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59054 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59055 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59056 +
59057 + default_role = NULL;
59058 + kernel_role = NULL;
59059 + role_list = NULL;
59060 +
59061 + return;
59062 +}
59063 +
59064 +static __u32
59065 +count_user_objs(struct acl_object_label *userp)
59066 +{
59067 + struct acl_object_label o_tmp;
59068 + __u32 num = 0;
59069 +
59070 + while (userp) {
59071 + if (copy_from_user(&o_tmp, userp,
59072 + sizeof (struct acl_object_label)))
59073 + break;
59074 +
59075 + userp = o_tmp.prev;
59076 + num++;
59077 + }
59078 +
59079 + return num;
59080 +}
59081 +
59082 +static struct acl_subject_label *
59083 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59084 +
59085 +static int
59086 +copy_user_glob(struct acl_object_label *obj)
59087 +{
59088 + struct acl_object_label *g_tmp, **guser;
59089 + unsigned int len;
59090 + char *tmp;
59091 +
59092 + if (obj->globbed == NULL)
59093 + return 0;
59094 +
59095 + guser = &obj->globbed;
59096 + while (*guser) {
59097 + g_tmp = (struct acl_object_label *)
59098 + acl_alloc(sizeof (struct acl_object_label));
59099 + if (g_tmp == NULL)
59100 + return -ENOMEM;
59101 +
59102 + if (copy_from_user(g_tmp, *guser,
59103 + sizeof (struct acl_object_label)))
59104 + return -EFAULT;
59105 +
59106 + len = strnlen_user(g_tmp->filename, PATH_MAX);
59107 +
59108 + if (!len || len >= PATH_MAX)
59109 + return -EINVAL;
59110 +
59111 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59112 + return -ENOMEM;
59113 +
59114 + if (copy_from_user(tmp, g_tmp->filename, len))
59115 + return -EFAULT;
59116 + tmp[len-1] = '\0';
59117 + g_tmp->filename = tmp;
59118 +
59119 + *guser = g_tmp;
59120 + guser = &(g_tmp->next);
59121 + }
59122 +
59123 + return 0;
59124 +}
59125 +
59126 +static int
59127 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59128 + struct acl_role_label *role)
59129 +{
59130 + struct acl_object_label *o_tmp;
59131 + unsigned int len;
59132 + int ret;
59133 + char *tmp;
59134 +
59135 + while (userp) {
59136 + if ((o_tmp = (struct acl_object_label *)
59137 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59138 + return -ENOMEM;
59139 +
59140 + if (copy_from_user(o_tmp, userp,
59141 + sizeof (struct acl_object_label)))
59142 + return -EFAULT;
59143 +
59144 + userp = o_tmp->prev;
59145 +
59146 + len = strnlen_user(o_tmp->filename, PATH_MAX);
59147 +
59148 + if (!len || len >= PATH_MAX)
59149 + return -EINVAL;
59150 +
59151 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59152 + return -ENOMEM;
59153 +
59154 + if (copy_from_user(tmp, o_tmp->filename, len))
59155 + return -EFAULT;
59156 + tmp[len-1] = '\0';
59157 + o_tmp->filename = tmp;
59158 +
59159 + insert_acl_obj_label(o_tmp, subj);
59160 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59161 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59162 + return -ENOMEM;
59163 +
59164 + ret = copy_user_glob(o_tmp);
59165 + if (ret)
59166 + return ret;
59167 +
59168 + if (o_tmp->nested) {
59169 + int already_copied;
59170 +
59171 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59172 + if (IS_ERR(o_tmp->nested))
59173 + return PTR_ERR(o_tmp->nested);
59174 +
59175 + /* insert into nested subject list if we haven't copied this one yet
59176 + to prevent duplicate entries */
59177 + if (!already_copied) {
59178 + o_tmp->nested->next = role->hash->first;
59179 + role->hash->first = o_tmp->nested;
59180 + }
59181 + }
59182 + }
59183 +
59184 + return 0;
59185 +}
59186 +
59187 +static __u32
59188 +count_user_subjs(struct acl_subject_label *userp)
59189 +{
59190 + struct acl_subject_label s_tmp;
59191 + __u32 num = 0;
59192 +
59193 + while (userp) {
59194 + if (copy_from_user(&s_tmp, userp,
59195 + sizeof (struct acl_subject_label)))
59196 + break;
59197 +
59198 + userp = s_tmp.prev;
59199 + }
59200 +
59201 + return num;
59202 +}
59203 +
59204 +static int
59205 +copy_user_allowedips(struct acl_role_label *rolep)
59206 +{
59207 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59208 +
59209 + ruserip = rolep->allowed_ips;
59210 +
59211 + while (ruserip) {
59212 + rlast = rtmp;
59213 +
59214 + if ((rtmp = (struct role_allowed_ip *)
59215 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59216 + return -ENOMEM;
59217 +
59218 + if (copy_from_user(rtmp, ruserip,
59219 + sizeof (struct role_allowed_ip)))
59220 + return -EFAULT;
59221 +
59222 + ruserip = rtmp->prev;
59223 +
59224 + if (!rlast) {
59225 + rtmp->prev = NULL;
59226 + rolep->allowed_ips = rtmp;
59227 + } else {
59228 + rlast->next = rtmp;
59229 + rtmp->prev = rlast;
59230 + }
59231 +
59232 + if (!ruserip)
59233 + rtmp->next = NULL;
59234 + }
59235 +
59236 + return 0;
59237 +}
59238 +
59239 +static int
59240 +copy_user_transitions(struct acl_role_label *rolep)
59241 +{
59242 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59243 +
59244 + unsigned int len;
59245 + char *tmp;
59246 +
59247 + rusertp = rolep->transitions;
59248 +
59249 + while (rusertp) {
59250 + rlast = rtmp;
59251 +
59252 + if ((rtmp = (struct role_transition *)
59253 + acl_alloc(sizeof (struct role_transition))) == NULL)
59254 + return -ENOMEM;
59255 +
59256 + if (copy_from_user(rtmp, rusertp,
59257 + sizeof (struct role_transition)))
59258 + return -EFAULT;
59259 +
59260 + rusertp = rtmp->prev;
59261 +
59262 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59263 +
59264 + if (!len || len >= GR_SPROLE_LEN)
59265 + return -EINVAL;
59266 +
59267 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59268 + return -ENOMEM;
59269 +
59270 + if (copy_from_user(tmp, rtmp->rolename, len))
59271 + return -EFAULT;
59272 + tmp[len-1] = '\0';
59273 + rtmp->rolename = tmp;
59274 +
59275 + if (!rlast) {
59276 + rtmp->prev = NULL;
59277 + rolep->transitions = rtmp;
59278 + } else {
59279 + rlast->next = rtmp;
59280 + rtmp->prev = rlast;
59281 + }
59282 +
59283 + if (!rusertp)
59284 + rtmp->next = NULL;
59285 + }
59286 +
59287 + return 0;
59288 +}
59289 +
59290 +static struct acl_subject_label *
59291 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59292 +{
59293 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59294 + unsigned int len;
59295 + char *tmp;
59296 + __u32 num_objs;
59297 + struct acl_ip_label **i_tmp, *i_utmp2;
59298 + struct gr_hash_struct ghash;
59299 + struct subject_map *subjmap;
59300 + unsigned int i_num;
59301 + int err;
59302 +
59303 + if (already_copied != NULL)
59304 + *already_copied = 0;
59305 +
59306 + s_tmp = lookup_subject_map(userp);
59307 +
59308 + /* we've already copied this subject into the kernel, just return
59309 + the reference to it, and don't copy it over again
59310 + */
59311 + if (s_tmp) {
59312 + if (already_copied != NULL)
59313 + *already_copied = 1;
59314 + return(s_tmp);
59315 + }
59316 +
59317 + if ((s_tmp = (struct acl_subject_label *)
59318 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59319 + return ERR_PTR(-ENOMEM);
59320 +
59321 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59322 + if (subjmap == NULL)
59323 + return ERR_PTR(-ENOMEM);
59324 +
59325 + subjmap->user = userp;
59326 + subjmap->kernel = s_tmp;
59327 + insert_subj_map_entry(subjmap);
59328 +
59329 + if (copy_from_user(s_tmp, userp,
59330 + sizeof (struct acl_subject_label)))
59331 + return ERR_PTR(-EFAULT);
59332 +
59333 + len = strnlen_user(s_tmp->filename, PATH_MAX);
59334 +
59335 + if (!len || len >= PATH_MAX)
59336 + return ERR_PTR(-EINVAL);
59337 +
59338 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59339 + return ERR_PTR(-ENOMEM);
59340 +
59341 + if (copy_from_user(tmp, s_tmp->filename, len))
59342 + return ERR_PTR(-EFAULT);
59343 + tmp[len-1] = '\0';
59344 + s_tmp->filename = tmp;
59345 +
59346 + if (!strcmp(s_tmp->filename, "/"))
59347 + role->root_label = s_tmp;
59348 +
59349 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59350 + return ERR_PTR(-EFAULT);
59351 +
59352 + /* copy user and group transition tables */
59353 +
59354 + if (s_tmp->user_trans_num) {
59355 + uid_t *uidlist;
59356 +
59357 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59358 + if (uidlist == NULL)
59359 + return ERR_PTR(-ENOMEM);
59360 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59361 + return ERR_PTR(-EFAULT);
59362 +
59363 + s_tmp->user_transitions = uidlist;
59364 + }
59365 +
59366 + if (s_tmp->group_trans_num) {
59367 + gid_t *gidlist;
59368 +
59369 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59370 + if (gidlist == NULL)
59371 + return ERR_PTR(-ENOMEM);
59372 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59373 + return ERR_PTR(-EFAULT);
59374 +
59375 + s_tmp->group_transitions = gidlist;
59376 + }
59377 +
59378 + /* set up object hash table */
59379 + num_objs = count_user_objs(ghash.first);
59380 +
59381 + s_tmp->obj_hash_size = num_objs;
59382 + s_tmp->obj_hash =
59383 + (struct acl_object_label **)
59384 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59385 +
59386 + if (!s_tmp->obj_hash)
59387 + return ERR_PTR(-ENOMEM);
59388 +
59389 + memset(s_tmp->obj_hash, 0,
59390 + s_tmp->obj_hash_size *
59391 + sizeof (struct acl_object_label *));
59392 +
59393 + /* add in objects */
59394 + err = copy_user_objs(ghash.first, s_tmp, role);
59395 +
59396 + if (err)
59397 + return ERR_PTR(err);
59398 +
59399 + /* set pointer for parent subject */
59400 + if (s_tmp->parent_subject) {
59401 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59402 +
59403 + if (IS_ERR(s_tmp2))
59404 + return s_tmp2;
59405 +
59406 + s_tmp->parent_subject = s_tmp2;
59407 + }
59408 +
59409 + /* add in ip acls */
59410 +
59411 + if (!s_tmp->ip_num) {
59412 + s_tmp->ips = NULL;
59413 + goto insert;
59414 + }
59415 +
59416 + i_tmp =
59417 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59418 + sizeof (struct acl_ip_label *));
59419 +
59420 + if (!i_tmp)
59421 + return ERR_PTR(-ENOMEM);
59422 +
59423 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59424 + *(i_tmp + i_num) =
59425 + (struct acl_ip_label *)
59426 + acl_alloc(sizeof (struct acl_ip_label));
59427 + if (!*(i_tmp + i_num))
59428 + return ERR_PTR(-ENOMEM);
59429 +
59430 + if (copy_from_user
59431 + (&i_utmp2, s_tmp->ips + i_num,
59432 + sizeof (struct acl_ip_label *)))
59433 + return ERR_PTR(-EFAULT);
59434 +
59435 + if (copy_from_user
59436 + (*(i_tmp + i_num), i_utmp2,
59437 + sizeof (struct acl_ip_label)))
59438 + return ERR_PTR(-EFAULT);
59439 +
59440 + if ((*(i_tmp + i_num))->iface == NULL)
59441 + continue;
59442 +
59443 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59444 + if (!len || len >= IFNAMSIZ)
59445 + return ERR_PTR(-EINVAL);
59446 + tmp = acl_alloc(len);
59447 + if (tmp == NULL)
59448 + return ERR_PTR(-ENOMEM);
59449 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59450 + return ERR_PTR(-EFAULT);
59451 + (*(i_tmp + i_num))->iface = tmp;
59452 + }
59453 +
59454 + s_tmp->ips = i_tmp;
59455 +
59456 +insert:
59457 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59458 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59459 + return ERR_PTR(-ENOMEM);
59460 +
59461 + return s_tmp;
59462 +}
59463 +
59464 +static int
59465 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59466 +{
59467 + struct acl_subject_label s_pre;
59468 + struct acl_subject_label * ret;
59469 + int err;
59470 +
59471 + while (userp) {
59472 + if (copy_from_user(&s_pre, userp,
59473 + sizeof (struct acl_subject_label)))
59474 + return -EFAULT;
59475 +
59476 + ret = do_copy_user_subj(userp, role, NULL);
59477 +
59478 + err = PTR_ERR(ret);
59479 + if (IS_ERR(ret))
59480 + return err;
59481 +
59482 + insert_acl_subj_label(ret, role);
59483 +
59484 + userp = s_pre.prev;
59485 + }
59486 +
59487 + return 0;
59488 +}
59489 +
59490 +static int
59491 +copy_user_acl(struct gr_arg *arg)
59492 +{
59493 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59494 + struct acl_subject_label *subj_list;
59495 + struct sprole_pw *sptmp;
59496 + struct gr_hash_struct *ghash;
59497 + uid_t *domainlist;
59498 + unsigned int r_num;
59499 + unsigned int len;
59500 + char *tmp;
59501 + int err = 0;
59502 + __u16 i;
59503 + __u32 num_subjs;
59504 +
59505 + /* we need a default and kernel role */
59506 + if (arg->role_db.num_roles < 2)
59507 + return -EINVAL;
59508 +
59509 + /* copy special role authentication info from userspace */
59510 +
59511 + num_sprole_pws = arg->num_sprole_pws;
59512 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59513 +
59514 + if (!acl_special_roles && num_sprole_pws)
59515 + return -ENOMEM;
59516 +
59517 + for (i = 0; i < num_sprole_pws; i++) {
59518 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59519 + if (!sptmp)
59520 + return -ENOMEM;
59521 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59522 + sizeof (struct sprole_pw)))
59523 + return -EFAULT;
59524 +
59525 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59526 +
59527 + if (!len || len >= GR_SPROLE_LEN)
59528 + return -EINVAL;
59529 +
59530 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59531 + return -ENOMEM;
59532 +
59533 + if (copy_from_user(tmp, sptmp->rolename, len))
59534 + return -EFAULT;
59535 +
59536 + tmp[len-1] = '\0';
59537 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59538 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59539 +#endif
59540 + sptmp->rolename = tmp;
59541 + acl_special_roles[i] = sptmp;
59542 + }
59543 +
59544 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59545 +
59546 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59547 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59548 +
59549 + if (!r_tmp)
59550 + return -ENOMEM;
59551 +
59552 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59553 + sizeof (struct acl_role_label *)))
59554 + return -EFAULT;
59555 +
59556 + if (copy_from_user(r_tmp, r_utmp2,
59557 + sizeof (struct acl_role_label)))
59558 + return -EFAULT;
59559 +
59560 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59561 +
59562 + if (!len || len >= PATH_MAX)
59563 + return -EINVAL;
59564 +
59565 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59566 + return -ENOMEM;
59567 +
59568 + if (copy_from_user(tmp, r_tmp->rolename, len))
59569 + return -EFAULT;
59570 +
59571 + tmp[len-1] = '\0';
59572 + r_tmp->rolename = tmp;
59573 +
59574 + if (!strcmp(r_tmp->rolename, "default")
59575 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59576 + default_role = r_tmp;
59577 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59578 + kernel_role = r_tmp;
59579 + }
59580 +
59581 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59582 + return -ENOMEM;
59583 +
59584 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59585 + return -EFAULT;
59586 +
59587 + r_tmp->hash = ghash;
59588 +
59589 + num_subjs = count_user_subjs(r_tmp->hash->first);
59590 +
59591 + r_tmp->subj_hash_size = num_subjs;
59592 + r_tmp->subj_hash =
59593 + (struct acl_subject_label **)
59594 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59595 +
59596 + if (!r_tmp->subj_hash)
59597 + return -ENOMEM;
59598 +
59599 + err = copy_user_allowedips(r_tmp);
59600 + if (err)
59601 + return err;
59602 +
59603 + /* copy domain info */
59604 + if (r_tmp->domain_children != NULL) {
59605 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59606 + if (domainlist == NULL)
59607 + return -ENOMEM;
59608 +
59609 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59610 + return -EFAULT;
59611 +
59612 + r_tmp->domain_children = domainlist;
59613 + }
59614 +
59615 + err = copy_user_transitions(r_tmp);
59616 + if (err)
59617 + return err;
59618 +
59619 + memset(r_tmp->subj_hash, 0,
59620 + r_tmp->subj_hash_size *
59621 + sizeof (struct acl_subject_label *));
59622 +
59623 + /* acquire the list of subjects, then NULL out
59624 + the list prior to parsing the subjects for this role,
59625 + as during this parsing the list is replaced with a list
59626 + of *nested* subjects for the role
59627 + */
59628 + subj_list = r_tmp->hash->first;
59629 +
59630 + /* set nested subject list to null */
59631 + r_tmp->hash->first = NULL;
59632 +
59633 + err = copy_user_subjs(subj_list, r_tmp);
59634 +
59635 + if (err)
59636 + return err;
59637 +
59638 + insert_acl_role_label(r_tmp);
59639 + }
59640 +
59641 + if (default_role == NULL || kernel_role == NULL)
59642 + return -EINVAL;
59643 +
59644 + return err;
59645 +}
59646 +
59647 +static int
59648 +gracl_init(struct gr_arg *args)
59649 +{
59650 + int error = 0;
59651 +
59652 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59653 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59654 +
59655 + if (init_variables(args)) {
59656 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59657 + error = -ENOMEM;
59658 + free_variables();
59659 + goto out;
59660 + }
59661 +
59662 + error = copy_user_acl(args);
59663 + free_init_variables();
59664 + if (error) {
59665 + free_variables();
59666 + goto out;
59667 + }
59668 +
59669 + if ((error = gr_set_acls(0))) {
59670 + free_variables();
59671 + goto out;
59672 + }
59673 +
59674 + pax_open_kernel();
59675 + gr_status |= GR_READY;
59676 + pax_close_kernel();
59677 +
59678 + out:
59679 + return error;
59680 +}
59681 +
59682 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59683 +
59684 +static int
59685 +glob_match(const char *p, const char *n)
59686 +{
59687 + char c;
59688 +
59689 + while ((c = *p++) != '\0') {
59690 + switch (c) {
59691 + case '?':
59692 + if (*n == '\0')
59693 + return 1;
59694 + else if (*n == '/')
59695 + return 1;
59696 + break;
59697 + case '\\':
59698 + if (*n != c)
59699 + return 1;
59700 + break;
59701 + case '*':
59702 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59703 + if (*n == '/')
59704 + return 1;
59705 + else if (c == '?') {
59706 + if (*n == '\0')
59707 + return 1;
59708 + else
59709 + ++n;
59710 + }
59711 + }
59712 + if (c == '\0') {
59713 + return 0;
59714 + } else {
59715 + const char *endp;
59716 +
59717 + if ((endp = strchr(n, '/')) == NULL)
59718 + endp = n + strlen(n);
59719 +
59720 + if (c == '[') {
59721 + for (--p; n < endp; ++n)
59722 + if (!glob_match(p, n))
59723 + return 0;
59724 + } else if (c == '/') {
59725 + while (*n != '\0' && *n != '/')
59726 + ++n;
59727 + if (*n == '/' && !glob_match(p, n + 1))
59728 + return 0;
59729 + } else {
59730 + for (--p; n < endp; ++n)
59731 + if (*n == c && !glob_match(p, n))
59732 + return 0;
59733 + }
59734 +
59735 + return 1;
59736 + }
59737 + case '[':
59738 + {
59739 + int not;
59740 + char cold;
59741 +
59742 + if (*n == '\0' || *n == '/')
59743 + return 1;
59744 +
59745 + not = (*p == '!' || *p == '^');
59746 + if (not)
59747 + ++p;
59748 +
59749 + c = *p++;
59750 + for (;;) {
59751 + unsigned char fn = (unsigned char)*n;
59752 +
59753 + if (c == '\0')
59754 + return 1;
59755 + else {
59756 + if (c == fn)
59757 + goto matched;
59758 + cold = c;
59759 + c = *p++;
59760 +
59761 + if (c == '-' && *p != ']') {
59762 + unsigned char cend = *p++;
59763 +
59764 + if (cend == '\0')
59765 + return 1;
59766 +
59767 + if (cold <= fn && fn <= cend)
59768 + goto matched;
59769 +
59770 + c = *p++;
59771 + }
59772 + }
59773 +
59774 + if (c == ']')
59775 + break;
59776 + }
59777 + if (!not)
59778 + return 1;
59779 + break;
59780 + matched:
59781 + while (c != ']') {
59782 + if (c == '\0')
59783 + return 1;
59784 +
59785 + c = *p++;
59786 + }
59787 + if (not)
59788 + return 1;
59789 + }
59790 + break;
59791 + default:
59792 + if (c != *n)
59793 + return 1;
59794 + }
59795 +
59796 + ++n;
59797 + }
59798 +
59799 + if (*n == '\0')
59800 + return 0;
59801 +
59802 + if (*n == '/')
59803 + return 0;
59804 +
59805 + return 1;
59806 +}
59807 +
59808 +static struct acl_object_label *
59809 +chk_glob_label(struct acl_object_label *globbed,
59810 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59811 +{
59812 + struct acl_object_label *tmp;
59813 +
59814 + if (*path == NULL)
59815 + *path = gr_to_filename_nolock(dentry, mnt);
59816 +
59817 + tmp = globbed;
59818 +
59819 + while (tmp) {
59820 + if (!glob_match(tmp->filename, *path))
59821 + return tmp;
59822 + tmp = tmp->next;
59823 + }
59824 +
59825 + return NULL;
59826 +}
59827 +
59828 +static struct acl_object_label *
59829 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59830 + const ino_t curr_ino, const dev_t curr_dev,
59831 + const struct acl_subject_label *subj, char **path, const int checkglob)
59832 +{
59833 + struct acl_subject_label *tmpsubj;
59834 + struct acl_object_label *retval;
59835 + struct acl_object_label *retval2;
59836 +
59837 + tmpsubj = (struct acl_subject_label *) subj;
59838 + read_lock(&gr_inode_lock);
59839 + do {
59840 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
59841 + if (retval) {
59842 + if (checkglob && retval->globbed) {
59843 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59844 + if (retval2)
59845 + retval = retval2;
59846 + }
59847 + break;
59848 + }
59849 + } while ((tmpsubj = tmpsubj->parent_subject));
59850 + read_unlock(&gr_inode_lock);
59851 +
59852 + return retval;
59853 +}
59854 +
59855 +static __inline__ struct acl_object_label *
59856 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59857 + struct dentry *curr_dentry,
59858 + const struct acl_subject_label *subj, char **path, const int checkglob)
59859 +{
59860 + int newglob = checkglob;
59861 + ino_t inode;
59862 + dev_t device;
59863 +
59864 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59865 + as we don't want a / * rule to match instead of the / object
59866 + don't do this for create lookups that call this function though, since they're looking up
59867 + on the parent and thus need globbing checks on all paths
59868 + */
59869 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59870 + newglob = GR_NO_GLOB;
59871 +
59872 + spin_lock(&curr_dentry->d_lock);
59873 + inode = curr_dentry->d_inode->i_ino;
59874 + device = __get_dev(curr_dentry);
59875 + spin_unlock(&curr_dentry->d_lock);
59876 +
59877 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59878 +}
59879 +
59880 +#ifdef CONFIG_HUGETLBFS
59881 +static inline bool
59882 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59883 +{
59884 + int i;
59885 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59886 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59887 + return true;
59888 + }
59889 +
59890 + return false;
59891 +}
59892 +#endif
59893 +
59894 +static struct acl_object_label *
59895 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59896 + const struct acl_subject_label *subj, char *path, const int checkglob)
59897 +{
59898 + struct dentry *dentry = (struct dentry *) l_dentry;
59899 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59900 + struct mount *real_mnt = real_mount(mnt);
59901 + struct acl_object_label *retval;
59902 + struct dentry *parent;
59903 +
59904 + br_read_lock(&vfsmount_lock);
59905 + write_seqlock(&rename_lock);
59906 +
59907 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59908 +#ifdef CONFIG_NET
59909 + mnt == sock_mnt ||
59910 +#endif
59911 +#ifdef CONFIG_HUGETLBFS
59912 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
59913 +#endif
59914 + /* ignore Eric Biederman */
59915 + IS_PRIVATE(l_dentry->d_inode))) {
59916 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
59917 + goto out;
59918 + }
59919 +
59920 + for (;;) {
59921 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59922 + break;
59923 +
59924 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59925 + if (!mnt_has_parent(real_mnt))
59926 + break;
59927 +
59928 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59929 + if (retval != NULL)
59930 + goto out;
59931 +
59932 + dentry = real_mnt->mnt_mountpoint;
59933 + real_mnt = real_mnt->mnt_parent;
59934 + mnt = &real_mnt->mnt;
59935 + continue;
59936 + }
59937 +
59938 + parent = dentry->d_parent;
59939 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59940 + if (retval != NULL)
59941 + goto out;
59942 +
59943 + dentry = parent;
59944 + }
59945 +
59946 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59947 +
59948 + /* real_root is pinned so we don't have to hold a reference */
59949 + if (retval == NULL)
59950 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
59951 +out:
59952 + write_sequnlock(&rename_lock);
59953 + br_read_unlock(&vfsmount_lock);
59954 +
59955 + BUG_ON(retval == NULL);
59956 +
59957 + return retval;
59958 +}
59959 +
59960 +static __inline__ struct acl_object_label *
59961 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59962 + const struct acl_subject_label *subj)
59963 +{
59964 + char *path = NULL;
59965 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
59966 +}
59967 +
59968 +static __inline__ struct acl_object_label *
59969 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59970 + const struct acl_subject_label *subj)
59971 +{
59972 + char *path = NULL;
59973 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
59974 +}
59975 +
59976 +static __inline__ struct acl_object_label *
59977 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59978 + const struct acl_subject_label *subj, char *path)
59979 +{
59980 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
59981 +}
59982 +
59983 +static struct acl_subject_label *
59984 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59985 + const struct acl_role_label *role)
59986 +{
59987 + struct dentry *dentry = (struct dentry *) l_dentry;
59988 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59989 + struct mount *real_mnt = real_mount(mnt);
59990 + struct acl_subject_label *retval;
59991 + struct dentry *parent;
59992 +
59993 + br_read_lock(&vfsmount_lock);
59994 + write_seqlock(&rename_lock);
59995 +
59996 + for (;;) {
59997 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59998 + break;
59999 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60000 + if (!mnt_has_parent(real_mnt))
60001 + break;
60002 +
60003 + spin_lock(&dentry->d_lock);
60004 + read_lock(&gr_inode_lock);
60005 + retval =
60006 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60007 + __get_dev(dentry), role);
60008 + read_unlock(&gr_inode_lock);
60009 + spin_unlock(&dentry->d_lock);
60010 + if (retval != NULL)
60011 + goto out;
60012 +
60013 + dentry = real_mnt->mnt_mountpoint;
60014 + real_mnt = real_mnt->mnt_parent;
60015 + mnt = &real_mnt->mnt;
60016 + continue;
60017 + }
60018 +
60019 + spin_lock(&dentry->d_lock);
60020 + read_lock(&gr_inode_lock);
60021 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60022 + __get_dev(dentry), role);
60023 + read_unlock(&gr_inode_lock);
60024 + parent = dentry->d_parent;
60025 + spin_unlock(&dentry->d_lock);
60026 +
60027 + if (retval != NULL)
60028 + goto out;
60029 +
60030 + dentry = parent;
60031 + }
60032 +
60033 + spin_lock(&dentry->d_lock);
60034 + read_lock(&gr_inode_lock);
60035 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60036 + __get_dev(dentry), role);
60037 + read_unlock(&gr_inode_lock);
60038 + spin_unlock(&dentry->d_lock);
60039 +
60040 + if (unlikely(retval == NULL)) {
60041 + /* real_root is pinned, we don't need to hold a reference */
60042 + read_lock(&gr_inode_lock);
60043 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60044 + __get_dev(real_root.dentry), role);
60045 + read_unlock(&gr_inode_lock);
60046 + }
60047 +out:
60048 + write_sequnlock(&rename_lock);
60049 + br_read_unlock(&vfsmount_lock);
60050 +
60051 + BUG_ON(retval == NULL);
60052 +
60053 + return retval;
60054 +}
60055 +
60056 +static void
60057 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60058 +{
60059 + struct task_struct *task = current;
60060 + const struct cred *cred = current_cred();
60061 +
60062 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60063 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60064 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60065 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60066 +
60067 + return;
60068 +}
60069 +
60070 +static void
60071 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60072 +{
60073 + struct task_struct *task = current;
60074 + const struct cred *cred = current_cred();
60075 +
60076 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60077 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60078 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60079 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60080 +
60081 + return;
60082 +}
60083 +
60084 +static void
60085 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60086 +{
60087 + struct task_struct *task = current;
60088 + const struct cred *cred = current_cred();
60089 +
60090 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60091 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60092 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60093 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60094 +
60095 + return;
60096 +}
60097 +
60098 +__u32
60099 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60100 + const struct vfsmount * mnt)
60101 +{
60102 + __u32 retval = mode;
60103 + struct acl_subject_label *curracl;
60104 + struct acl_object_label *currobj;
60105 +
60106 + if (unlikely(!(gr_status & GR_READY)))
60107 + return (mode & ~GR_AUDITS);
60108 +
60109 + curracl = current->acl;
60110 +
60111 + currobj = chk_obj_label(dentry, mnt, curracl);
60112 + retval = currobj->mode & mode;
60113 +
60114 + /* if we're opening a specified transfer file for writing
60115 + (e.g. /dev/initctl), then transfer our role to init
60116 + */
60117 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60118 + current->role->roletype & GR_ROLE_PERSIST)) {
60119 + struct task_struct *task = init_pid_ns.child_reaper;
60120 +
60121 + if (task->role != current->role) {
60122 + task->acl_sp_role = 0;
60123 + task->acl_role_id = current->acl_role_id;
60124 + task->role = current->role;
60125 + rcu_read_lock();
60126 + read_lock(&grsec_exec_file_lock);
60127 + gr_apply_subject_to_task(task);
60128 + read_unlock(&grsec_exec_file_lock);
60129 + rcu_read_unlock();
60130 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60131 + }
60132 + }
60133 +
60134 + if (unlikely
60135 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60136 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60137 + __u32 new_mode = mode;
60138 +
60139 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60140 +
60141 + retval = new_mode;
60142 +
60143 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60144 + new_mode |= GR_INHERIT;
60145 +
60146 + if (!(mode & GR_NOLEARN))
60147 + gr_log_learn(dentry, mnt, new_mode);
60148 + }
60149 +
60150 + return retval;
60151 +}
60152 +
60153 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60154 + const struct dentry *parent,
60155 + const struct vfsmount *mnt)
60156 +{
60157 + struct name_entry *match;
60158 + struct acl_object_label *matchpo;
60159 + struct acl_subject_label *curracl;
60160 + char *path;
60161 +
60162 + if (unlikely(!(gr_status & GR_READY)))
60163 + return NULL;
60164 +
60165 + preempt_disable();
60166 + path = gr_to_filename_rbac(new_dentry, mnt);
60167 + match = lookup_name_entry_create(path);
60168 +
60169 + curracl = current->acl;
60170 +
60171 + if (match) {
60172 + read_lock(&gr_inode_lock);
60173 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60174 + read_unlock(&gr_inode_lock);
60175 +
60176 + if (matchpo) {
60177 + preempt_enable();
60178 + return matchpo;
60179 + }
60180 + }
60181 +
60182 + // lookup parent
60183 +
60184 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60185 +
60186 + preempt_enable();
60187 + return matchpo;
60188 +}
60189 +
60190 +__u32
60191 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60192 + const struct vfsmount * mnt, const __u32 mode)
60193 +{
60194 + struct acl_object_label *matchpo;
60195 + __u32 retval;
60196 +
60197 + if (unlikely(!(gr_status & GR_READY)))
60198 + return (mode & ~GR_AUDITS);
60199 +
60200 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60201 +
60202 + retval = matchpo->mode & mode;
60203 +
60204 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60205 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60206 + __u32 new_mode = mode;
60207 +
60208 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60209 +
60210 + gr_log_learn(new_dentry, mnt, new_mode);
60211 + return new_mode;
60212 + }
60213 +
60214 + return retval;
60215 +}
60216 +
60217 +__u32
60218 +gr_check_link(const struct dentry * new_dentry,
60219 + const struct dentry * parent_dentry,
60220 + const struct vfsmount * parent_mnt,
60221 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60222 +{
60223 + struct acl_object_label *obj;
60224 + __u32 oldmode, newmode;
60225 + __u32 needmode;
60226 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60227 + GR_DELETE | GR_INHERIT;
60228 +
60229 + if (unlikely(!(gr_status & GR_READY)))
60230 + return (GR_CREATE | GR_LINK);
60231 +
60232 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60233 + oldmode = obj->mode;
60234 +
60235 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60236 + newmode = obj->mode;
60237 +
60238 + needmode = newmode & checkmodes;
60239 +
60240 + // old name for hardlink must have at least the permissions of the new name
60241 + if ((oldmode & needmode) != needmode)
60242 + goto bad;
60243 +
60244 + // if old name had restrictions/auditing, make sure the new name does as well
60245 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60246 +
60247 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60248 + if (is_privileged_binary(old_dentry))
60249 + needmode |= GR_SETID;
60250 +
60251 + if ((newmode & needmode) != needmode)
60252 + goto bad;
60253 +
60254 + // enforce minimum permissions
60255 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60256 + return newmode;
60257 +bad:
60258 + needmode = oldmode;
60259 + if (is_privileged_binary(old_dentry))
60260 + needmode |= GR_SETID;
60261 +
60262 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60263 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60264 + return (GR_CREATE | GR_LINK);
60265 + } else if (newmode & GR_SUPPRESS)
60266 + return GR_SUPPRESS;
60267 + else
60268 + return 0;
60269 +}
60270 +
60271 +int
60272 +gr_check_hidden_task(const struct task_struct *task)
60273 +{
60274 + if (unlikely(!(gr_status & GR_READY)))
60275 + return 0;
60276 +
60277 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60278 + return 1;
60279 +
60280 + return 0;
60281 +}
60282 +
60283 +int
60284 +gr_check_protected_task(const struct task_struct *task)
60285 +{
60286 + if (unlikely(!(gr_status & GR_READY) || !task))
60287 + return 0;
60288 +
60289 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60290 + task->acl != current->acl)
60291 + return 1;
60292 +
60293 + return 0;
60294 +}
60295 +
60296 +int
60297 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60298 +{
60299 + struct task_struct *p;
60300 + int ret = 0;
60301 +
60302 + if (unlikely(!(gr_status & GR_READY) || !pid))
60303 + return ret;
60304 +
60305 + read_lock(&tasklist_lock);
60306 + do_each_pid_task(pid, type, p) {
60307 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60308 + p->acl != current->acl) {
60309 + ret = 1;
60310 + goto out;
60311 + }
60312 + } while_each_pid_task(pid, type, p);
60313 +out:
60314 + read_unlock(&tasklist_lock);
60315 +
60316 + return ret;
60317 +}
60318 +
60319 +void
60320 +gr_copy_label(struct task_struct *tsk)
60321 +{
60322 + tsk->signal->used_accept = 0;
60323 + tsk->acl_sp_role = 0;
60324 + tsk->acl_role_id = current->acl_role_id;
60325 + tsk->acl = current->acl;
60326 + tsk->role = current->role;
60327 + tsk->signal->curr_ip = current->signal->curr_ip;
60328 + tsk->signal->saved_ip = current->signal->saved_ip;
60329 + if (current->exec_file)
60330 + get_file(current->exec_file);
60331 + tsk->exec_file = current->exec_file;
60332 + tsk->is_writable = current->is_writable;
60333 + if (unlikely(current->signal->used_accept)) {
60334 + current->signal->curr_ip = 0;
60335 + current->signal->saved_ip = 0;
60336 + }
60337 +
60338 + return;
60339 +}
60340 +
60341 +static void
60342 +gr_set_proc_res(struct task_struct *task)
60343 +{
60344 + struct acl_subject_label *proc;
60345 + unsigned short i;
60346 +
60347 + proc = task->acl;
60348 +
60349 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60350 + return;
60351 +
60352 + for (i = 0; i < RLIM_NLIMITS; i++) {
60353 + if (!(proc->resmask & (1U << i)))
60354 + continue;
60355 +
60356 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60357 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60358 +
60359 + if (i == RLIMIT_CPU)
60360 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60361 + }
60362 +
60363 + return;
60364 +}
60365 +
60366 +extern int __gr_process_user_ban(struct user_struct *user);
60367 +
60368 +int
60369 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60370 +{
60371 + unsigned int i;
60372 + __u16 num;
60373 + uid_t *uidlist;
60374 + uid_t curuid;
60375 + int realok = 0;
60376 + int effectiveok = 0;
60377 + int fsok = 0;
60378 + uid_t globalreal, globaleffective, globalfs;
60379 +
60380 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
60381 + struct user_struct *user;
60382 +
60383 + if (!uid_valid(real))
60384 + goto skipit;
60385 +
60386 + /* find user based on global namespace */
60387 +
60388 + globalreal = GR_GLOBAL_UID(real);
60389 +
60390 + user = find_user(make_kuid(&init_user_ns, globalreal));
60391 + if (user == NULL)
60392 + goto skipit;
60393 +
60394 + if (__gr_process_user_ban(user)) {
60395 + /* for find_user */
60396 + free_uid(user);
60397 + return 1;
60398 + }
60399 +
60400 + /* for find_user */
60401 + free_uid(user);
60402 +
60403 +skipit:
60404 +#endif
60405 +
60406 + if (unlikely(!(gr_status & GR_READY)))
60407 + return 0;
60408 +
60409 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60410 + gr_log_learn_uid_change(real, effective, fs);
60411 +
60412 + num = current->acl->user_trans_num;
60413 + uidlist = current->acl->user_transitions;
60414 +
60415 + if (uidlist == NULL)
60416 + return 0;
60417 +
60418 + if (!uid_valid(real)) {
60419 + realok = 1;
60420 + globalreal = (uid_t)-1;
60421 + } else {
60422 + globalreal = GR_GLOBAL_UID(real);
60423 + }
60424 + if (!uid_valid(effective)) {
60425 + effectiveok = 1;
60426 + globaleffective = (uid_t)-1;
60427 + } else {
60428 + globaleffective = GR_GLOBAL_UID(effective);
60429 + }
60430 + if (!uid_valid(fs)) {
60431 + fsok = 1;
60432 + globalfs = (uid_t)-1;
60433 + } else {
60434 + globalfs = GR_GLOBAL_UID(fs);
60435 + }
60436 +
60437 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60438 + for (i = 0; i < num; i++) {
60439 + curuid = uidlist[i];
60440 + if (globalreal == curuid)
60441 + realok = 1;
60442 + if (globaleffective == curuid)
60443 + effectiveok = 1;
60444 + if (globalfs == curuid)
60445 + fsok = 1;
60446 + }
60447 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60448 + for (i = 0; i < num; i++) {
60449 + curuid = uidlist[i];
60450 + if (globalreal == curuid)
60451 + break;
60452 + if (globaleffective == curuid)
60453 + break;
60454 + if (globalfs == curuid)
60455 + break;
60456 + }
60457 + /* not in deny list */
60458 + if (i == num) {
60459 + realok = 1;
60460 + effectiveok = 1;
60461 + fsok = 1;
60462 + }
60463 + }
60464 +
60465 + if (realok && effectiveok && fsok)
60466 + return 0;
60467 + else {
60468 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60469 + return 1;
60470 + }
60471 +}
60472 +
60473 +int
60474 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60475 +{
60476 + unsigned int i;
60477 + __u16 num;
60478 + gid_t *gidlist;
60479 + gid_t curgid;
60480 + int realok = 0;
60481 + int effectiveok = 0;
60482 + int fsok = 0;
60483 + gid_t globalreal, globaleffective, globalfs;
60484 +
60485 + if (unlikely(!(gr_status & GR_READY)))
60486 + return 0;
60487 +
60488 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60489 + gr_log_learn_gid_change(real, effective, fs);
60490 +
60491 + num = current->acl->group_trans_num;
60492 + gidlist = current->acl->group_transitions;
60493 +
60494 + if (gidlist == NULL)
60495 + return 0;
60496 +
60497 + if (!gid_valid(real)) {
60498 + realok = 1;
60499 + globalreal = (gid_t)-1;
60500 + } else {
60501 + globalreal = GR_GLOBAL_GID(real);
60502 + }
60503 + if (!gid_valid(effective)) {
60504 + effectiveok = 1;
60505 + globaleffective = (gid_t)-1;
60506 + } else {
60507 + globaleffective = GR_GLOBAL_GID(effective);
60508 + }
60509 + if (!gid_valid(fs)) {
60510 + fsok = 1;
60511 + globalfs = (gid_t)-1;
60512 + } else {
60513 + globalfs = GR_GLOBAL_GID(fs);
60514 + }
60515 +
60516 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60517 + for (i = 0; i < num; i++) {
60518 + curgid = gidlist[i];
60519 + if (globalreal == curgid)
60520 + realok = 1;
60521 + if (globaleffective == curgid)
60522 + effectiveok = 1;
60523 + if (globalfs == curgid)
60524 + fsok = 1;
60525 + }
60526 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60527 + for (i = 0; i < num; i++) {
60528 + curgid = gidlist[i];
60529 + if (globalreal == curgid)
60530 + break;
60531 + if (globaleffective == curgid)
60532 + break;
60533 + if (globalfs == curgid)
60534 + break;
60535 + }
60536 + /* not in deny list */
60537 + if (i == num) {
60538 + realok = 1;
60539 + effectiveok = 1;
60540 + fsok = 1;
60541 + }
60542 + }
60543 +
60544 + if (realok && effectiveok && fsok)
60545 + return 0;
60546 + else {
60547 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60548 + return 1;
60549 + }
60550 +}
60551 +
60552 +extern int gr_acl_is_capable(const int cap);
60553 +
60554 +void
60555 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60556 +{
60557 + struct acl_role_label *role = task->role;
60558 + struct acl_subject_label *subj = NULL;
60559 + struct acl_object_label *obj;
60560 + struct file *filp;
60561 + uid_t uid;
60562 + gid_t gid;
60563 +
60564 + if (unlikely(!(gr_status & GR_READY)))
60565 + return;
60566 +
60567 + uid = GR_GLOBAL_UID(kuid);
60568 + gid = GR_GLOBAL_GID(kgid);
60569 +
60570 + filp = task->exec_file;
60571 +
60572 + /* kernel process, we'll give them the kernel role */
60573 + if (unlikely(!filp)) {
60574 + task->role = kernel_role;
60575 + task->acl = kernel_role->root_label;
60576 + return;
60577 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60578 + role = lookup_acl_role_label(task, uid, gid);
60579 +
60580 + /* don't change the role if we're not a privileged process */
60581 + if (role && task->role != role &&
60582 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60583 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60584 + return;
60585 +
60586 + /* perform subject lookup in possibly new role
60587 + we can use this result below in the case where role == task->role
60588 + */
60589 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60590 +
60591 + /* if we changed uid/gid, but result in the same role
60592 + and are using inheritance, don't lose the inherited subject
60593 + if current subject is other than what normal lookup
60594 + would result in, we arrived via inheritance, don't
60595 + lose subject
60596 + */
60597 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60598 + (subj == task->acl)))
60599 + task->acl = subj;
60600 +
60601 + task->role = role;
60602 +
60603 + task->is_writable = 0;
60604 +
60605 + /* ignore additional mmap checks for processes that are writable
60606 + by the default ACL */
60607 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60608 + if (unlikely(obj->mode & GR_WRITE))
60609 + task->is_writable = 1;
60610 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60611 + if (unlikely(obj->mode & GR_WRITE))
60612 + task->is_writable = 1;
60613 +
60614 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60615 + 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);
60616 +#endif
60617 +
60618 + gr_set_proc_res(task);
60619 +
60620 + return;
60621 +}
60622 +
60623 +int
60624 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60625 + const int unsafe_flags)
60626 +{
60627 + struct task_struct *task = current;
60628 + struct acl_subject_label *newacl;
60629 + struct acl_object_label *obj;
60630 + __u32 retmode;
60631 +
60632 + if (unlikely(!(gr_status & GR_READY)))
60633 + return 0;
60634 +
60635 + newacl = chk_subj_label(dentry, mnt, task->role);
60636 +
60637 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60638 + did an exec
60639 + */
60640 + rcu_read_lock();
60641 + read_lock(&tasklist_lock);
60642 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60643 + (task->parent->acl->mode & GR_POVERRIDE))) {
60644 + read_unlock(&tasklist_lock);
60645 + rcu_read_unlock();
60646 + goto skip_check;
60647 + }
60648 + read_unlock(&tasklist_lock);
60649 + rcu_read_unlock();
60650 +
60651 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60652 + !(task->role->roletype & GR_ROLE_GOD) &&
60653 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60654 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60655 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60656 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60657 + else
60658 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60659 + return -EACCES;
60660 + }
60661 +
60662 +skip_check:
60663 +
60664 + obj = chk_obj_label(dentry, mnt, task->acl);
60665 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60666 +
60667 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60668 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60669 + if (obj->nested)
60670 + task->acl = obj->nested;
60671 + else
60672 + task->acl = newacl;
60673 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60674 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60675 +
60676 + task->is_writable = 0;
60677 +
60678 + /* ignore additional mmap checks for processes that are writable
60679 + by the default ACL */
60680 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60681 + if (unlikely(obj->mode & GR_WRITE))
60682 + task->is_writable = 1;
60683 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60684 + if (unlikely(obj->mode & GR_WRITE))
60685 + task->is_writable = 1;
60686 +
60687 + gr_set_proc_res(task);
60688 +
60689 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60690 + 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);
60691 +#endif
60692 + return 0;
60693 +}
60694 +
60695 +/* always called with valid inodev ptr */
60696 +static void
60697 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60698 +{
60699 + struct acl_object_label *matchpo;
60700 + struct acl_subject_label *matchps;
60701 + struct acl_subject_label *subj;
60702 + struct acl_role_label *role;
60703 + unsigned int x;
60704 +
60705 + FOR_EACH_ROLE_START(role)
60706 + FOR_EACH_SUBJECT_START(role, subj, x)
60707 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60708 + matchpo->mode |= GR_DELETED;
60709 + FOR_EACH_SUBJECT_END(subj,x)
60710 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60711 + /* nested subjects aren't in the role's subj_hash table */
60712 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60713 + matchpo->mode |= GR_DELETED;
60714 + FOR_EACH_NESTED_SUBJECT_END(subj)
60715 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60716 + matchps->mode |= GR_DELETED;
60717 + FOR_EACH_ROLE_END(role)
60718 +
60719 + inodev->nentry->deleted = 1;
60720 +
60721 + return;
60722 +}
60723 +
60724 +void
60725 +gr_handle_delete(const ino_t ino, const dev_t dev)
60726 +{
60727 + struct inodev_entry *inodev;
60728 +
60729 + if (unlikely(!(gr_status & GR_READY)))
60730 + return;
60731 +
60732 + write_lock(&gr_inode_lock);
60733 + inodev = lookup_inodev_entry(ino, dev);
60734 + if (inodev != NULL)
60735 + do_handle_delete(inodev, ino, dev);
60736 + write_unlock(&gr_inode_lock);
60737 +
60738 + return;
60739 +}
60740 +
60741 +static void
60742 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60743 + const ino_t newinode, const dev_t newdevice,
60744 + struct acl_subject_label *subj)
60745 +{
60746 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60747 + struct acl_object_label *match;
60748 +
60749 + match = subj->obj_hash[index];
60750 +
60751 + while (match && (match->inode != oldinode ||
60752 + match->device != olddevice ||
60753 + !(match->mode & GR_DELETED)))
60754 + match = match->next;
60755 +
60756 + if (match && (match->inode == oldinode)
60757 + && (match->device == olddevice)
60758 + && (match->mode & GR_DELETED)) {
60759 + if (match->prev == NULL) {
60760 + subj->obj_hash[index] = match->next;
60761 + if (match->next != NULL)
60762 + match->next->prev = NULL;
60763 + } else {
60764 + match->prev->next = match->next;
60765 + if (match->next != NULL)
60766 + match->next->prev = match->prev;
60767 + }
60768 + match->prev = NULL;
60769 + match->next = NULL;
60770 + match->inode = newinode;
60771 + match->device = newdevice;
60772 + match->mode &= ~GR_DELETED;
60773 +
60774 + insert_acl_obj_label(match, subj);
60775 + }
60776 +
60777 + return;
60778 +}
60779 +
60780 +static void
60781 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60782 + const ino_t newinode, const dev_t newdevice,
60783 + struct acl_role_label *role)
60784 +{
60785 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60786 + struct acl_subject_label *match;
60787 +
60788 + match = role->subj_hash[index];
60789 +
60790 + while (match && (match->inode != oldinode ||
60791 + match->device != olddevice ||
60792 + !(match->mode & GR_DELETED)))
60793 + match = match->next;
60794 +
60795 + if (match && (match->inode == oldinode)
60796 + && (match->device == olddevice)
60797 + && (match->mode & GR_DELETED)) {
60798 + if (match->prev == NULL) {
60799 + role->subj_hash[index] = match->next;
60800 + if (match->next != NULL)
60801 + match->next->prev = NULL;
60802 + } else {
60803 + match->prev->next = match->next;
60804 + if (match->next != NULL)
60805 + match->next->prev = match->prev;
60806 + }
60807 + match->prev = NULL;
60808 + match->next = NULL;
60809 + match->inode = newinode;
60810 + match->device = newdevice;
60811 + match->mode &= ~GR_DELETED;
60812 +
60813 + insert_acl_subj_label(match, role);
60814 + }
60815 +
60816 + return;
60817 +}
60818 +
60819 +static void
60820 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60821 + const ino_t newinode, const dev_t newdevice)
60822 +{
60823 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60824 + struct inodev_entry *match;
60825 +
60826 + match = inodev_set.i_hash[index];
60827 +
60828 + while (match && (match->nentry->inode != oldinode ||
60829 + match->nentry->device != olddevice || !match->nentry->deleted))
60830 + match = match->next;
60831 +
60832 + if (match && (match->nentry->inode == oldinode)
60833 + && (match->nentry->device == olddevice) &&
60834 + match->nentry->deleted) {
60835 + if (match->prev == NULL) {
60836 + inodev_set.i_hash[index] = match->next;
60837 + if (match->next != NULL)
60838 + match->next->prev = NULL;
60839 + } else {
60840 + match->prev->next = match->next;
60841 + if (match->next != NULL)
60842 + match->next->prev = match->prev;
60843 + }
60844 + match->prev = NULL;
60845 + match->next = NULL;
60846 + match->nentry->inode = newinode;
60847 + match->nentry->device = newdevice;
60848 + match->nentry->deleted = 0;
60849 +
60850 + insert_inodev_entry(match);
60851 + }
60852 +
60853 + return;
60854 +}
60855 +
60856 +static void
60857 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60858 +{
60859 + struct acl_subject_label *subj;
60860 + struct acl_role_label *role;
60861 + unsigned int x;
60862 +
60863 + FOR_EACH_ROLE_START(role)
60864 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60865 +
60866 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60867 + if ((subj->inode == ino) && (subj->device == dev)) {
60868 + subj->inode = ino;
60869 + subj->device = dev;
60870 + }
60871 + /* nested subjects aren't in the role's subj_hash table */
60872 + update_acl_obj_label(matchn->inode, matchn->device,
60873 + ino, dev, subj);
60874 + FOR_EACH_NESTED_SUBJECT_END(subj)
60875 + FOR_EACH_SUBJECT_START(role, subj, x)
60876 + update_acl_obj_label(matchn->inode, matchn->device,
60877 + ino, dev, subj);
60878 + FOR_EACH_SUBJECT_END(subj,x)
60879 + FOR_EACH_ROLE_END(role)
60880 +
60881 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60882 +
60883 + return;
60884 +}
60885 +
60886 +static void
60887 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60888 + const struct vfsmount *mnt)
60889 +{
60890 + ino_t ino = dentry->d_inode->i_ino;
60891 + dev_t dev = __get_dev(dentry);
60892 +
60893 + __do_handle_create(matchn, ino, dev);
60894 +
60895 + return;
60896 +}
60897 +
60898 +void
60899 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60900 +{
60901 + struct name_entry *matchn;
60902 +
60903 + if (unlikely(!(gr_status & GR_READY)))
60904 + return;
60905 +
60906 + preempt_disable();
60907 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60908 +
60909 + if (unlikely((unsigned long)matchn)) {
60910 + write_lock(&gr_inode_lock);
60911 + do_handle_create(matchn, dentry, mnt);
60912 + write_unlock(&gr_inode_lock);
60913 + }
60914 + preempt_enable();
60915 +
60916 + return;
60917 +}
60918 +
60919 +void
60920 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
60921 +{
60922 + struct name_entry *matchn;
60923 +
60924 + if (unlikely(!(gr_status & GR_READY)))
60925 + return;
60926 +
60927 + preempt_disable();
60928 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
60929 +
60930 + if (unlikely((unsigned long)matchn)) {
60931 + write_lock(&gr_inode_lock);
60932 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
60933 + write_unlock(&gr_inode_lock);
60934 + }
60935 + preempt_enable();
60936 +
60937 + return;
60938 +}
60939 +
60940 +void
60941 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
60942 + struct dentry *old_dentry,
60943 + struct dentry *new_dentry,
60944 + struct vfsmount *mnt, const __u8 replace)
60945 +{
60946 + struct name_entry *matchn;
60947 + struct inodev_entry *inodev;
60948 + struct inode *inode = new_dentry->d_inode;
60949 + ino_t old_ino = old_dentry->d_inode->i_ino;
60950 + dev_t old_dev = __get_dev(old_dentry);
60951 +
60952 + /* vfs_rename swaps the name and parent link for old_dentry and
60953 + new_dentry
60954 + at this point, old_dentry has the new name, parent link, and inode
60955 + for the renamed file
60956 + if a file is being replaced by a rename, new_dentry has the inode
60957 + and name for the replaced file
60958 + */
60959 +
60960 + if (unlikely(!(gr_status & GR_READY)))
60961 + return;
60962 +
60963 + preempt_disable();
60964 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
60965 +
60966 + /* we wouldn't have to check d_inode if it weren't for
60967 + NFS silly-renaming
60968 + */
60969 +
60970 + write_lock(&gr_inode_lock);
60971 + if (unlikely(replace && inode)) {
60972 + ino_t new_ino = inode->i_ino;
60973 + dev_t new_dev = __get_dev(new_dentry);
60974 +
60975 + inodev = lookup_inodev_entry(new_ino, new_dev);
60976 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
60977 + do_handle_delete(inodev, new_ino, new_dev);
60978 + }
60979 +
60980 + inodev = lookup_inodev_entry(old_ino, old_dev);
60981 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
60982 + do_handle_delete(inodev, old_ino, old_dev);
60983 +
60984 + if (unlikely((unsigned long)matchn))
60985 + do_handle_create(matchn, old_dentry, mnt);
60986 +
60987 + write_unlock(&gr_inode_lock);
60988 + preempt_enable();
60989 +
60990 + return;
60991 +}
60992 +
60993 +static int
60994 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
60995 + unsigned char **sum)
60996 +{
60997 + struct acl_role_label *r;
60998 + struct role_allowed_ip *ipp;
60999 + struct role_transition *trans;
61000 + unsigned int i;
61001 + int found = 0;
61002 + u32 curr_ip = current->signal->curr_ip;
61003 +
61004 + current->signal->saved_ip = curr_ip;
61005 +
61006 + /* check transition table */
61007 +
61008 + for (trans = current->role->transitions; trans; trans = trans->next) {
61009 + if (!strcmp(rolename, trans->rolename)) {
61010 + found = 1;
61011 + break;
61012 + }
61013 + }
61014 +
61015 + if (!found)
61016 + return 0;
61017 +
61018 + /* handle special roles that do not require authentication
61019 + and check ip */
61020 +
61021 + FOR_EACH_ROLE_START(r)
61022 + if (!strcmp(rolename, r->rolename) &&
61023 + (r->roletype & GR_ROLE_SPECIAL)) {
61024 + found = 0;
61025 + if (r->allowed_ips != NULL) {
61026 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61027 + if ((ntohl(curr_ip) & ipp->netmask) ==
61028 + (ntohl(ipp->addr) & ipp->netmask))
61029 + found = 1;
61030 + }
61031 + } else
61032 + found = 2;
61033 + if (!found)
61034 + return 0;
61035 +
61036 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61037 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61038 + *salt = NULL;
61039 + *sum = NULL;
61040 + return 1;
61041 + }
61042 + }
61043 + FOR_EACH_ROLE_END(r)
61044 +
61045 + for (i = 0; i < num_sprole_pws; i++) {
61046 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61047 + *salt = acl_special_roles[i]->salt;
61048 + *sum = acl_special_roles[i]->sum;
61049 + return 1;
61050 + }
61051 + }
61052 +
61053 + return 0;
61054 +}
61055 +
61056 +static void
61057 +assign_special_role(char *rolename)
61058 +{
61059 + struct acl_object_label *obj;
61060 + struct acl_role_label *r;
61061 + struct acl_role_label *assigned = NULL;
61062 + struct task_struct *tsk;
61063 + struct file *filp;
61064 +
61065 + FOR_EACH_ROLE_START(r)
61066 + if (!strcmp(rolename, r->rolename) &&
61067 + (r->roletype & GR_ROLE_SPECIAL)) {
61068 + assigned = r;
61069 + break;
61070 + }
61071 + FOR_EACH_ROLE_END(r)
61072 +
61073 + if (!assigned)
61074 + return;
61075 +
61076 + read_lock(&tasklist_lock);
61077 + read_lock(&grsec_exec_file_lock);
61078 +
61079 + tsk = current->real_parent;
61080 + if (tsk == NULL)
61081 + goto out_unlock;
61082 +
61083 + filp = tsk->exec_file;
61084 + if (filp == NULL)
61085 + goto out_unlock;
61086 +
61087 + tsk->is_writable = 0;
61088 +
61089 + tsk->acl_sp_role = 1;
61090 + tsk->acl_role_id = ++acl_sp_role_value;
61091 + tsk->role = assigned;
61092 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61093 +
61094 + /* ignore additional mmap checks for processes that are writable
61095 + by the default ACL */
61096 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61097 + if (unlikely(obj->mode & GR_WRITE))
61098 + tsk->is_writable = 1;
61099 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61100 + if (unlikely(obj->mode & GR_WRITE))
61101 + tsk->is_writable = 1;
61102 +
61103 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61104 + 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));
61105 +#endif
61106 +
61107 +out_unlock:
61108 + read_unlock(&grsec_exec_file_lock);
61109 + read_unlock(&tasklist_lock);
61110 + return;
61111 +}
61112 +
61113 +int gr_check_secure_terminal(struct task_struct *task)
61114 +{
61115 + struct task_struct *p, *p2, *p3;
61116 + struct files_struct *files;
61117 + struct fdtable *fdt;
61118 + struct file *our_file = NULL, *file;
61119 + int i;
61120 +
61121 + if (task->signal->tty == NULL)
61122 + return 1;
61123 +
61124 + files = get_files_struct(task);
61125 + if (files != NULL) {
61126 + rcu_read_lock();
61127 + fdt = files_fdtable(files);
61128 + for (i=0; i < fdt->max_fds; i++) {
61129 + file = fcheck_files(files, i);
61130 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61131 + get_file(file);
61132 + our_file = file;
61133 + }
61134 + }
61135 + rcu_read_unlock();
61136 + put_files_struct(files);
61137 + }
61138 +
61139 + if (our_file == NULL)
61140 + return 1;
61141 +
61142 + read_lock(&tasklist_lock);
61143 + do_each_thread(p2, p) {
61144 + files = get_files_struct(p);
61145 + if (files == NULL ||
61146 + (p->signal && p->signal->tty == task->signal->tty)) {
61147 + if (files != NULL)
61148 + put_files_struct(files);
61149 + continue;
61150 + }
61151 + rcu_read_lock();
61152 + fdt = files_fdtable(files);
61153 + for (i=0; i < fdt->max_fds; i++) {
61154 + file = fcheck_files(files, i);
61155 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61156 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61157 + p3 = task;
61158 + while (task_pid_nr(p3) > 0) {
61159 + if (p3 == p)
61160 + break;
61161 + p3 = p3->real_parent;
61162 + }
61163 + if (p3 == p)
61164 + break;
61165 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61166 + gr_handle_alertkill(p);
61167 + rcu_read_unlock();
61168 + put_files_struct(files);
61169 + read_unlock(&tasklist_lock);
61170 + fput(our_file);
61171 + return 0;
61172 + }
61173 + }
61174 + rcu_read_unlock();
61175 + put_files_struct(files);
61176 + } while_each_thread(p2, p);
61177 + read_unlock(&tasklist_lock);
61178 +
61179 + fput(our_file);
61180 + return 1;
61181 +}
61182 +
61183 +static int gr_rbac_disable(void *unused)
61184 +{
61185 + pax_open_kernel();
61186 + gr_status &= ~GR_READY;
61187 + pax_close_kernel();
61188 +
61189 + return 0;
61190 +}
61191 +
61192 +ssize_t
61193 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61194 +{
61195 + struct gr_arg_wrapper uwrap;
61196 + unsigned char *sprole_salt = NULL;
61197 + unsigned char *sprole_sum = NULL;
61198 + int error = sizeof (struct gr_arg_wrapper);
61199 + int error2 = 0;
61200 +
61201 + mutex_lock(&gr_dev_mutex);
61202 +
61203 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61204 + error = -EPERM;
61205 + goto out;
61206 + }
61207 +
61208 + if (count != sizeof (struct gr_arg_wrapper)) {
61209 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61210 + error = -EINVAL;
61211 + goto out;
61212 + }
61213 +
61214 +
61215 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61216 + gr_auth_expires = 0;
61217 + gr_auth_attempts = 0;
61218 + }
61219 +
61220 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61221 + error = -EFAULT;
61222 + goto out;
61223 + }
61224 +
61225 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61226 + error = -EINVAL;
61227 + goto out;
61228 + }
61229 +
61230 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61231 + error = -EFAULT;
61232 + goto out;
61233 + }
61234 +
61235 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61236 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61237 + time_after(gr_auth_expires, get_seconds())) {
61238 + error = -EBUSY;
61239 + goto out;
61240 + }
61241 +
61242 + /* if non-root trying to do anything other than use a special role,
61243 + do not attempt authentication, do not count towards authentication
61244 + locking
61245 + */
61246 +
61247 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61248 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61249 + gr_is_global_nonroot(current_uid())) {
61250 + error = -EPERM;
61251 + goto out;
61252 + }
61253 +
61254 + /* ensure pw and special role name are null terminated */
61255 +
61256 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61257 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61258 +
61259 + /* Okay.
61260 + * We have our enough of the argument structure..(we have yet
61261 + * to copy_from_user the tables themselves) . Copy the tables
61262 + * only if we need them, i.e. for loading operations. */
61263 +
61264 + switch (gr_usermode->mode) {
61265 + case GR_STATUS:
61266 + if (gr_status & GR_READY) {
61267 + error = 1;
61268 + if (!gr_check_secure_terminal(current))
61269 + error = 3;
61270 + } else
61271 + error = 2;
61272 + goto out;
61273 + case GR_SHUTDOWN:
61274 + if ((gr_status & GR_READY)
61275 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61276 + stop_machine(gr_rbac_disable, NULL, NULL);
61277 + free_variables();
61278 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61279 + memset(gr_system_salt, 0, GR_SALT_LEN);
61280 + memset(gr_system_sum, 0, GR_SHA_LEN);
61281 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61282 + } else if (gr_status & GR_READY) {
61283 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61284 + error = -EPERM;
61285 + } else {
61286 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61287 + error = -EAGAIN;
61288 + }
61289 + break;
61290 + case GR_ENABLE:
61291 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61292 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61293 + else {
61294 + if (gr_status & GR_READY)
61295 + error = -EAGAIN;
61296 + else
61297 + error = error2;
61298 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61299 + }
61300 + break;
61301 + case GR_RELOAD:
61302 + if (!(gr_status & GR_READY)) {
61303 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61304 + error = -EAGAIN;
61305 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61306 + stop_machine(gr_rbac_disable, NULL, NULL);
61307 + free_variables();
61308 + error2 = gracl_init(gr_usermode);
61309 + if (!error2)
61310 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61311 + else {
61312 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61313 + error = error2;
61314 + }
61315 + } else {
61316 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61317 + error = -EPERM;
61318 + }
61319 + break;
61320 + case GR_SEGVMOD:
61321 + if (unlikely(!(gr_status & GR_READY))) {
61322 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61323 + error = -EAGAIN;
61324 + break;
61325 + }
61326 +
61327 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61328 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61329 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61330 + struct acl_subject_label *segvacl;
61331 + segvacl =
61332 + lookup_acl_subj_label(gr_usermode->segv_inode,
61333 + gr_usermode->segv_device,
61334 + current->role);
61335 + if (segvacl) {
61336 + segvacl->crashes = 0;
61337 + segvacl->expires = 0;
61338 + }
61339 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61340 + gr_remove_uid(gr_usermode->segv_uid);
61341 + }
61342 + } else {
61343 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61344 + error = -EPERM;
61345 + }
61346 + break;
61347 + case GR_SPROLE:
61348 + case GR_SPROLEPAM:
61349 + if (unlikely(!(gr_status & GR_READY))) {
61350 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61351 + error = -EAGAIN;
61352 + break;
61353 + }
61354 +
61355 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61356 + current->role->expires = 0;
61357 + current->role->auth_attempts = 0;
61358 + }
61359 +
61360 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61361 + time_after(current->role->expires, get_seconds())) {
61362 + error = -EBUSY;
61363 + goto out;
61364 + }
61365 +
61366 + if (lookup_special_role_auth
61367 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61368 + && ((!sprole_salt && !sprole_sum)
61369 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61370 + char *p = "";
61371 + assign_special_role(gr_usermode->sp_role);
61372 + read_lock(&tasklist_lock);
61373 + if (current->real_parent)
61374 + p = current->real_parent->role->rolename;
61375 + read_unlock(&tasklist_lock);
61376 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61377 + p, acl_sp_role_value);
61378 + } else {
61379 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61380 + error = -EPERM;
61381 + if(!(current->role->auth_attempts++))
61382 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61383 +
61384 + goto out;
61385 + }
61386 + break;
61387 + case GR_UNSPROLE:
61388 + if (unlikely(!(gr_status & GR_READY))) {
61389 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61390 + error = -EAGAIN;
61391 + break;
61392 + }
61393 +
61394 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61395 + char *p = "";
61396 + int i = 0;
61397 +
61398 + read_lock(&tasklist_lock);
61399 + if (current->real_parent) {
61400 + p = current->real_parent->role->rolename;
61401 + i = current->real_parent->acl_role_id;
61402 + }
61403 + read_unlock(&tasklist_lock);
61404 +
61405 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61406 + gr_set_acls(1);
61407 + } else {
61408 + error = -EPERM;
61409 + goto out;
61410 + }
61411 + break;
61412 + default:
61413 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61414 + error = -EINVAL;
61415 + break;
61416 + }
61417 +
61418 + if (error != -EPERM)
61419 + goto out;
61420 +
61421 + if(!(gr_auth_attempts++))
61422 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61423 +
61424 + out:
61425 + mutex_unlock(&gr_dev_mutex);
61426 + return error;
61427 +}
61428 +
61429 +/* must be called with
61430 + rcu_read_lock();
61431 + read_lock(&tasklist_lock);
61432 + read_lock(&grsec_exec_file_lock);
61433 +*/
61434 +int gr_apply_subject_to_task(struct task_struct *task)
61435 +{
61436 + struct acl_object_label *obj;
61437 + char *tmpname;
61438 + struct acl_subject_label *tmpsubj;
61439 + struct file *filp;
61440 + struct name_entry *nmatch;
61441 +
61442 + filp = task->exec_file;
61443 + if (filp == NULL)
61444 + return 0;
61445 +
61446 + /* the following is to apply the correct subject
61447 + on binaries running when the RBAC system
61448 + is enabled, when the binaries have been
61449 + replaced or deleted since their execution
61450 + -----
61451 + when the RBAC system starts, the inode/dev
61452 + from exec_file will be one the RBAC system
61453 + is unaware of. It only knows the inode/dev
61454 + of the present file on disk, or the absence
61455 + of it.
61456 + */
61457 + preempt_disable();
61458 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61459 +
61460 + nmatch = lookup_name_entry(tmpname);
61461 + preempt_enable();
61462 + tmpsubj = NULL;
61463 + if (nmatch) {
61464 + if (nmatch->deleted)
61465 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61466 + else
61467 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61468 + if (tmpsubj != NULL)
61469 + task->acl = tmpsubj;
61470 + }
61471 + if (tmpsubj == NULL)
61472 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61473 + task->role);
61474 + if (task->acl) {
61475 + task->is_writable = 0;
61476 + /* ignore additional mmap checks for processes that are writable
61477 + by the default ACL */
61478 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61479 + if (unlikely(obj->mode & GR_WRITE))
61480 + task->is_writable = 1;
61481 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61482 + if (unlikely(obj->mode & GR_WRITE))
61483 + task->is_writable = 1;
61484 +
61485 + gr_set_proc_res(task);
61486 +
61487 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61488 + 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);
61489 +#endif
61490 + } else {
61491 + return 1;
61492 + }
61493 +
61494 + return 0;
61495 +}
61496 +
61497 +int
61498 +gr_set_acls(const int type)
61499 +{
61500 + struct task_struct *task, *task2;
61501 + struct acl_role_label *role = current->role;
61502 + __u16 acl_role_id = current->acl_role_id;
61503 + const struct cred *cred;
61504 + int ret;
61505 +
61506 + rcu_read_lock();
61507 + read_lock(&tasklist_lock);
61508 + read_lock(&grsec_exec_file_lock);
61509 + do_each_thread(task2, task) {
61510 + /* check to see if we're called from the exit handler,
61511 + if so, only replace ACLs that have inherited the admin
61512 + ACL */
61513 +
61514 + if (type && (task->role != role ||
61515 + task->acl_role_id != acl_role_id))
61516 + continue;
61517 +
61518 + task->acl_role_id = 0;
61519 + task->acl_sp_role = 0;
61520 +
61521 + if (task->exec_file) {
61522 + cred = __task_cred(task);
61523 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61524 + ret = gr_apply_subject_to_task(task);
61525 + if (ret) {
61526 + read_unlock(&grsec_exec_file_lock);
61527 + read_unlock(&tasklist_lock);
61528 + rcu_read_unlock();
61529 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61530 + return ret;
61531 + }
61532 + } else {
61533 + // it's a kernel process
61534 + task->role = kernel_role;
61535 + task->acl = kernel_role->root_label;
61536 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61537 + task->acl->mode &= ~GR_PROCFIND;
61538 +#endif
61539 + }
61540 + } while_each_thread(task2, task);
61541 + read_unlock(&grsec_exec_file_lock);
61542 + read_unlock(&tasklist_lock);
61543 + rcu_read_unlock();
61544 +
61545 + return 0;
61546 +}
61547 +
61548 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61549 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61550 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61551 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61552 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61553 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61554 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61555 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61556 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61557 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61558 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61559 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61560 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61561 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61562 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61563 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61564 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61565 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61566 +};
61567 +
61568 +void
61569 +gr_learn_resource(const struct task_struct *task,
61570 + const int res, const unsigned long wanted, const int gt)
61571 +{
61572 + struct acl_subject_label *acl;
61573 + const struct cred *cred;
61574 +
61575 + if (unlikely((gr_status & GR_READY) &&
61576 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61577 + goto skip_reslog;
61578 +
61579 + gr_log_resource(task, res, wanted, gt);
61580 +skip_reslog:
61581 +
61582 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61583 + return;
61584 +
61585 + acl = task->acl;
61586 +
61587 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61588 + !(acl->resmask & (1U << (unsigned short) res))))
61589 + return;
61590 +
61591 + if (wanted >= acl->res[res].rlim_cur) {
61592 + unsigned long res_add;
61593 +
61594 + res_add = wanted + res_learn_bumps[res];
61595 +
61596 + acl->res[res].rlim_cur = res_add;
61597 +
61598 + if (wanted > acl->res[res].rlim_max)
61599 + acl->res[res].rlim_max = res_add;
61600 +
61601 + /* only log the subject filename, since resource logging is supported for
61602 + single-subject learning only */
61603 + rcu_read_lock();
61604 + cred = __task_cred(task);
61605 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61606 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61607 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61608 + "", (unsigned long) res, &task->signal->saved_ip);
61609 + rcu_read_unlock();
61610 + }
61611 +
61612 + return;
61613 +}
61614 +EXPORT_SYMBOL(gr_learn_resource);
61615 +#endif
61616 +
61617 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61618 +void
61619 +pax_set_initial_flags(struct linux_binprm *bprm)
61620 +{
61621 + struct task_struct *task = current;
61622 + struct acl_subject_label *proc;
61623 + unsigned long flags;
61624 +
61625 + if (unlikely(!(gr_status & GR_READY)))
61626 + return;
61627 +
61628 + flags = pax_get_flags(task);
61629 +
61630 + proc = task->acl;
61631 +
61632 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61633 + flags &= ~MF_PAX_PAGEEXEC;
61634 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61635 + flags &= ~MF_PAX_SEGMEXEC;
61636 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61637 + flags &= ~MF_PAX_RANDMMAP;
61638 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61639 + flags &= ~MF_PAX_EMUTRAMP;
61640 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61641 + flags &= ~MF_PAX_MPROTECT;
61642 +
61643 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61644 + flags |= MF_PAX_PAGEEXEC;
61645 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61646 + flags |= MF_PAX_SEGMEXEC;
61647 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61648 + flags |= MF_PAX_RANDMMAP;
61649 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61650 + flags |= MF_PAX_EMUTRAMP;
61651 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61652 + flags |= MF_PAX_MPROTECT;
61653 +
61654 + pax_set_flags(task, flags);
61655 +
61656 + return;
61657 +}
61658 +#endif
61659 +
61660 +int
61661 +gr_handle_proc_ptrace(struct task_struct *task)
61662 +{
61663 + struct file *filp;
61664 + struct task_struct *tmp = task;
61665 + struct task_struct *curtemp = current;
61666 + __u32 retmode;
61667 +
61668 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61669 + if (unlikely(!(gr_status & GR_READY)))
61670 + return 0;
61671 +#endif
61672 +
61673 + read_lock(&tasklist_lock);
61674 + read_lock(&grsec_exec_file_lock);
61675 + filp = task->exec_file;
61676 +
61677 + while (task_pid_nr(tmp) > 0) {
61678 + if (tmp == curtemp)
61679 + break;
61680 + tmp = tmp->real_parent;
61681 + }
61682 +
61683 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61684 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61685 + read_unlock(&grsec_exec_file_lock);
61686 + read_unlock(&tasklist_lock);
61687 + return 1;
61688 + }
61689 +
61690 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61691 + if (!(gr_status & GR_READY)) {
61692 + read_unlock(&grsec_exec_file_lock);
61693 + read_unlock(&tasklist_lock);
61694 + return 0;
61695 + }
61696 +#endif
61697 +
61698 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61699 + read_unlock(&grsec_exec_file_lock);
61700 + read_unlock(&tasklist_lock);
61701 +
61702 + if (retmode & GR_NOPTRACE)
61703 + return 1;
61704 +
61705 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61706 + && (current->acl != task->acl || (current->acl != current->role->root_label
61707 + && task_pid_nr(current) != task_pid_nr(task))))
61708 + return 1;
61709 +
61710 + return 0;
61711 +}
61712 +
61713 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61714 +{
61715 + if (unlikely(!(gr_status & GR_READY)))
61716 + return;
61717 +
61718 + if (!(current->role->roletype & GR_ROLE_GOD))
61719 + return;
61720 +
61721 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61722 + p->role->rolename, gr_task_roletype_to_char(p),
61723 + p->acl->filename);
61724 +}
61725 +
61726 +int
61727 +gr_handle_ptrace(struct task_struct *task, const long request)
61728 +{
61729 + struct task_struct *tmp = task;
61730 + struct task_struct *curtemp = current;
61731 + __u32 retmode;
61732 +
61733 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61734 + if (unlikely(!(gr_status & GR_READY)))
61735 + return 0;
61736 +#endif
61737 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61738 + read_lock(&tasklist_lock);
61739 + while (task_pid_nr(tmp) > 0) {
61740 + if (tmp == curtemp)
61741 + break;
61742 + tmp = tmp->real_parent;
61743 + }
61744 +
61745 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61746 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61747 + read_unlock(&tasklist_lock);
61748 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61749 + return 1;
61750 + }
61751 + read_unlock(&tasklist_lock);
61752 + }
61753 +
61754 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61755 + if (!(gr_status & GR_READY))
61756 + return 0;
61757 +#endif
61758 +
61759 + read_lock(&grsec_exec_file_lock);
61760 + if (unlikely(!task->exec_file)) {
61761 + read_unlock(&grsec_exec_file_lock);
61762 + return 0;
61763 + }
61764 +
61765 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61766 + read_unlock(&grsec_exec_file_lock);
61767 +
61768 + if (retmode & GR_NOPTRACE) {
61769 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61770 + return 1;
61771 + }
61772 +
61773 + if (retmode & GR_PTRACERD) {
61774 + switch (request) {
61775 + case PTRACE_SEIZE:
61776 + case PTRACE_POKETEXT:
61777 + case PTRACE_POKEDATA:
61778 + case PTRACE_POKEUSR:
61779 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61780 + case PTRACE_SETREGS:
61781 + case PTRACE_SETFPREGS:
61782 +#endif
61783 +#ifdef CONFIG_X86
61784 + case PTRACE_SETFPXREGS:
61785 +#endif
61786 +#ifdef CONFIG_ALTIVEC
61787 + case PTRACE_SETVRREGS:
61788 +#endif
61789 + return 1;
61790 + default:
61791 + return 0;
61792 + }
61793 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61794 + !(current->role->roletype & GR_ROLE_GOD) &&
61795 + (current->acl != task->acl)) {
61796 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61797 + return 1;
61798 + }
61799 +
61800 + return 0;
61801 +}
61802 +
61803 +static int is_writable_mmap(const struct file *filp)
61804 +{
61805 + struct task_struct *task = current;
61806 + struct acl_object_label *obj, *obj2;
61807 +
61808 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61809 + !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))) {
61810 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61811 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61812 + task->role->root_label);
61813 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61814 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61815 + return 1;
61816 + }
61817 + }
61818 + return 0;
61819 +}
61820 +
61821 +int
61822 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61823 +{
61824 + __u32 mode;
61825 +
61826 + if (unlikely(!file || !(prot & PROT_EXEC)))
61827 + return 1;
61828 +
61829 + if (is_writable_mmap(file))
61830 + return 0;
61831 +
61832 + mode =
61833 + gr_search_file(file->f_path.dentry,
61834 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61835 + file->f_path.mnt);
61836 +
61837 + if (!gr_tpe_allow(file))
61838 + return 0;
61839 +
61840 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61841 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61842 + return 0;
61843 + } else if (unlikely(!(mode & GR_EXEC))) {
61844 + return 0;
61845 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61846 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61847 + return 1;
61848 + }
61849 +
61850 + return 1;
61851 +}
61852 +
61853 +int
61854 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61855 +{
61856 + __u32 mode;
61857 +
61858 + if (unlikely(!file || !(prot & PROT_EXEC)))
61859 + return 1;
61860 +
61861 + if (is_writable_mmap(file))
61862 + return 0;
61863 +
61864 + mode =
61865 + gr_search_file(file->f_path.dentry,
61866 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61867 + file->f_path.mnt);
61868 +
61869 + if (!gr_tpe_allow(file))
61870 + return 0;
61871 +
61872 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61873 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61874 + return 0;
61875 + } else if (unlikely(!(mode & GR_EXEC))) {
61876 + return 0;
61877 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61878 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61879 + return 1;
61880 + }
61881 +
61882 + return 1;
61883 +}
61884 +
61885 +void
61886 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61887 +{
61888 + unsigned long runtime;
61889 + unsigned long cputime;
61890 + unsigned int wday, cday;
61891 + __u8 whr, chr;
61892 + __u8 wmin, cmin;
61893 + __u8 wsec, csec;
61894 + struct timespec timeval;
61895 +
61896 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61897 + !(task->acl->mode & GR_PROCACCT)))
61898 + return;
61899 +
61900 + do_posix_clock_monotonic_gettime(&timeval);
61901 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61902 + wday = runtime / (3600 * 24);
61903 + runtime -= wday * (3600 * 24);
61904 + whr = runtime / 3600;
61905 + runtime -= whr * 3600;
61906 + wmin = runtime / 60;
61907 + runtime -= wmin * 60;
61908 + wsec = runtime;
61909 +
61910 + cputime = (task->utime + task->stime) / HZ;
61911 + cday = cputime / (3600 * 24);
61912 + cputime -= cday * (3600 * 24);
61913 + chr = cputime / 3600;
61914 + cputime -= chr * 3600;
61915 + cmin = cputime / 60;
61916 + cputime -= cmin * 60;
61917 + csec = cputime;
61918 +
61919 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
61920 +
61921 + return;
61922 +}
61923 +
61924 +void gr_set_kernel_label(struct task_struct *task)
61925 +{
61926 + if (gr_status & GR_READY) {
61927 + task->role = kernel_role;
61928 + task->acl = kernel_role->root_label;
61929 + }
61930 + return;
61931 +}
61932 +
61933 +#ifdef CONFIG_TASKSTATS
61934 +int gr_is_taskstats_denied(int pid)
61935 +{
61936 + struct task_struct *task;
61937 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61938 + const struct cred *cred;
61939 +#endif
61940 + int ret = 0;
61941 +
61942 + /* restrict taskstats viewing to un-chrooted root users
61943 + who have the 'view' subject flag if the RBAC system is enabled
61944 + */
61945 +
61946 + rcu_read_lock();
61947 + read_lock(&tasklist_lock);
61948 + task = find_task_by_vpid(pid);
61949 + if (task) {
61950 +#ifdef CONFIG_GRKERNSEC_CHROOT
61951 + if (proc_is_chrooted(task))
61952 + ret = -EACCES;
61953 +#endif
61954 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61955 + cred = __task_cred(task);
61956 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61957 + if (gr_is_global_nonroot(cred->uid))
61958 + ret = -EACCES;
61959 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61960 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
61961 + ret = -EACCES;
61962 +#endif
61963 +#endif
61964 + if (gr_status & GR_READY) {
61965 + if (!(task->acl->mode & GR_VIEW))
61966 + ret = -EACCES;
61967 + }
61968 + } else
61969 + ret = -ENOENT;
61970 +
61971 + read_unlock(&tasklist_lock);
61972 + rcu_read_unlock();
61973 +
61974 + return ret;
61975 +}
61976 +#endif
61977 +
61978 +/* AUXV entries are filled via a descendant of search_binary_handler
61979 + after we've already applied the subject for the target
61980 +*/
61981 +int gr_acl_enable_at_secure(void)
61982 +{
61983 + if (unlikely(!(gr_status & GR_READY)))
61984 + return 0;
61985 +
61986 + if (current->acl->mode & GR_ATSECURE)
61987 + return 1;
61988 +
61989 + return 0;
61990 +}
61991 +
61992 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
61993 +{
61994 + struct task_struct *task = current;
61995 + struct dentry *dentry = file->f_path.dentry;
61996 + struct vfsmount *mnt = file->f_path.mnt;
61997 + struct acl_object_label *obj, *tmp;
61998 + struct acl_subject_label *subj;
61999 + unsigned int bufsize;
62000 + int is_not_root;
62001 + char *path;
62002 + dev_t dev = __get_dev(dentry);
62003 +
62004 + if (unlikely(!(gr_status & GR_READY)))
62005 + return 1;
62006 +
62007 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62008 + return 1;
62009 +
62010 + /* ignore Eric Biederman */
62011 + if (IS_PRIVATE(dentry->d_inode))
62012 + return 1;
62013 +
62014 + subj = task->acl;
62015 + read_lock(&gr_inode_lock);
62016 + do {
62017 + obj = lookup_acl_obj_label(ino, dev, subj);
62018 + if (obj != NULL) {
62019 + read_unlock(&gr_inode_lock);
62020 + return (obj->mode & GR_FIND) ? 1 : 0;
62021 + }
62022 + } while ((subj = subj->parent_subject));
62023 + read_unlock(&gr_inode_lock);
62024 +
62025 + /* this is purely an optimization since we're looking for an object
62026 + for the directory we're doing a readdir on
62027 + if it's possible for any globbed object to match the entry we're
62028 + filling into the directory, then the object we find here will be
62029 + an anchor point with attached globbed objects
62030 + */
62031 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62032 + if (obj->globbed == NULL)
62033 + return (obj->mode & GR_FIND) ? 1 : 0;
62034 +
62035 + is_not_root = ((obj->filename[0] == '/') &&
62036 + (obj->filename[1] == '\0')) ? 0 : 1;
62037 + bufsize = PAGE_SIZE - namelen - is_not_root;
62038 +
62039 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62040 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62041 + return 1;
62042 +
62043 + preempt_disable();
62044 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62045 + bufsize);
62046 +
62047 + bufsize = strlen(path);
62048 +
62049 + /* if base is "/", don't append an additional slash */
62050 + if (is_not_root)
62051 + *(path + bufsize) = '/';
62052 + memcpy(path + bufsize + is_not_root, name, namelen);
62053 + *(path + bufsize + namelen + is_not_root) = '\0';
62054 +
62055 + tmp = obj->globbed;
62056 + while (tmp) {
62057 + if (!glob_match(tmp->filename, path)) {
62058 + preempt_enable();
62059 + return (tmp->mode & GR_FIND) ? 1 : 0;
62060 + }
62061 + tmp = tmp->next;
62062 + }
62063 + preempt_enable();
62064 + return (obj->mode & GR_FIND) ? 1 : 0;
62065 +}
62066 +
62067 +void gr_put_exec_file(struct task_struct *task)
62068 +{
62069 + struct file *filp;
62070 +
62071 + write_lock(&grsec_exec_file_lock);
62072 + filp = task->exec_file;
62073 + task->exec_file = NULL;
62074 + write_unlock(&grsec_exec_file_lock);
62075 +
62076 + if (filp)
62077 + fput(filp);
62078 +
62079 + return;
62080 +}
62081 +
62082 +
62083 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62084 +EXPORT_SYMBOL(gr_acl_is_enabled);
62085 +#endif
62086 +EXPORT_SYMBOL(gr_set_kernel_label);
62087 +#ifdef CONFIG_SECURITY
62088 +EXPORT_SYMBOL(gr_check_user_change);
62089 +EXPORT_SYMBOL(gr_check_group_change);
62090 +#endif
62091 +
62092 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62093 new file mode 100644
62094 index 0000000..34fefda
62095 --- /dev/null
62096 +++ b/grsecurity/gracl_alloc.c
62097 @@ -0,0 +1,105 @@
62098 +#include <linux/kernel.h>
62099 +#include <linux/mm.h>
62100 +#include <linux/slab.h>
62101 +#include <linux/vmalloc.h>
62102 +#include <linux/gracl.h>
62103 +#include <linux/grsecurity.h>
62104 +
62105 +static unsigned long alloc_stack_next = 1;
62106 +static unsigned long alloc_stack_size = 1;
62107 +static void **alloc_stack;
62108 +
62109 +static __inline__ int
62110 +alloc_pop(void)
62111 +{
62112 + if (alloc_stack_next == 1)
62113 + return 0;
62114 +
62115 + kfree(alloc_stack[alloc_stack_next - 2]);
62116 +
62117 + alloc_stack_next--;
62118 +
62119 + return 1;
62120 +}
62121 +
62122 +static __inline__ int
62123 +alloc_push(void *buf)
62124 +{
62125 + if (alloc_stack_next >= alloc_stack_size)
62126 + return 1;
62127 +
62128 + alloc_stack[alloc_stack_next - 1] = buf;
62129 +
62130 + alloc_stack_next++;
62131 +
62132 + return 0;
62133 +}
62134 +
62135 +void *
62136 +acl_alloc(unsigned long len)
62137 +{
62138 + void *ret = NULL;
62139 +
62140 + if (!len || len > PAGE_SIZE)
62141 + goto out;
62142 +
62143 + ret = kmalloc(len, GFP_KERNEL);
62144 +
62145 + if (ret) {
62146 + if (alloc_push(ret)) {
62147 + kfree(ret);
62148 + ret = NULL;
62149 + }
62150 + }
62151 +
62152 +out:
62153 + return ret;
62154 +}
62155 +
62156 +void *
62157 +acl_alloc_num(unsigned long num, unsigned long len)
62158 +{
62159 + if (!len || (num > (PAGE_SIZE / len)))
62160 + return NULL;
62161 +
62162 + return acl_alloc(num * len);
62163 +}
62164 +
62165 +void
62166 +acl_free_all(void)
62167 +{
62168 + if (gr_acl_is_enabled() || !alloc_stack)
62169 + return;
62170 +
62171 + while (alloc_pop()) ;
62172 +
62173 + if (alloc_stack) {
62174 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62175 + kfree(alloc_stack);
62176 + else
62177 + vfree(alloc_stack);
62178 + }
62179 +
62180 + alloc_stack = NULL;
62181 + alloc_stack_size = 1;
62182 + alloc_stack_next = 1;
62183 +
62184 + return;
62185 +}
62186 +
62187 +int
62188 +acl_alloc_stack_init(unsigned long size)
62189 +{
62190 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62191 + alloc_stack =
62192 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62193 + else
62194 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62195 +
62196 + alloc_stack_size = size;
62197 +
62198 + if (!alloc_stack)
62199 + return 0;
62200 + else
62201 + return 1;
62202 +}
62203 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62204 new file mode 100644
62205 index 0000000..bdd51ea
62206 --- /dev/null
62207 +++ b/grsecurity/gracl_cap.c
62208 @@ -0,0 +1,110 @@
62209 +#include <linux/kernel.h>
62210 +#include <linux/module.h>
62211 +#include <linux/sched.h>
62212 +#include <linux/gracl.h>
62213 +#include <linux/grsecurity.h>
62214 +#include <linux/grinternal.h>
62215 +
62216 +extern const char *captab_log[];
62217 +extern int captab_log_entries;
62218 +
62219 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62220 +{
62221 + struct acl_subject_label *curracl;
62222 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62223 + kernel_cap_t cap_audit = __cap_empty_set;
62224 +
62225 + if (!gr_acl_is_enabled())
62226 + return 1;
62227 +
62228 + curracl = task->acl;
62229 +
62230 + cap_drop = curracl->cap_lower;
62231 + cap_mask = curracl->cap_mask;
62232 + cap_audit = curracl->cap_invert_audit;
62233 +
62234 + while ((curracl = curracl->parent_subject)) {
62235 + /* if the cap isn't specified in the current computed mask but is specified in the
62236 + current level subject, and is lowered in the current level subject, then add
62237 + it to the set of dropped capabilities
62238 + otherwise, add the current level subject's mask to the current computed mask
62239 + */
62240 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62241 + cap_raise(cap_mask, cap);
62242 + if (cap_raised(curracl->cap_lower, cap))
62243 + cap_raise(cap_drop, cap);
62244 + if (cap_raised(curracl->cap_invert_audit, cap))
62245 + cap_raise(cap_audit, cap);
62246 + }
62247 + }
62248 +
62249 + if (!cap_raised(cap_drop, cap)) {
62250 + if (cap_raised(cap_audit, cap))
62251 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62252 + return 1;
62253 + }
62254 +
62255 + curracl = task->acl;
62256 +
62257 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62258 + && cap_raised(cred->cap_effective, cap)) {
62259 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62260 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62261 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62262 + gr_to_filename(task->exec_file->f_path.dentry,
62263 + task->exec_file->f_path.mnt) : curracl->filename,
62264 + curracl->filename, 0UL,
62265 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62266 + return 1;
62267 + }
62268 +
62269 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62270 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62271 +
62272 + return 0;
62273 +}
62274 +
62275 +int
62276 +gr_acl_is_capable(const int cap)
62277 +{
62278 + return gr_task_acl_is_capable(current, current_cred(), cap);
62279 +}
62280 +
62281 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62282 +{
62283 + struct acl_subject_label *curracl;
62284 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62285 +
62286 + if (!gr_acl_is_enabled())
62287 + return 1;
62288 +
62289 + curracl = task->acl;
62290 +
62291 + cap_drop = curracl->cap_lower;
62292 + cap_mask = curracl->cap_mask;
62293 +
62294 + while ((curracl = curracl->parent_subject)) {
62295 + /* if the cap isn't specified in the current computed mask but is specified in the
62296 + current level subject, and is lowered in the current level subject, then add
62297 + it to the set of dropped capabilities
62298 + otherwise, add the current level subject's mask to the current computed mask
62299 + */
62300 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62301 + cap_raise(cap_mask, cap);
62302 + if (cap_raised(curracl->cap_lower, cap))
62303 + cap_raise(cap_drop, cap);
62304 + }
62305 + }
62306 +
62307 + if (!cap_raised(cap_drop, cap))
62308 + return 1;
62309 +
62310 + return 0;
62311 +}
62312 +
62313 +int
62314 +gr_acl_is_capable_nolog(const int cap)
62315 +{
62316 + return gr_task_acl_is_capable_nolog(current, cap);
62317 +}
62318 +
62319 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62320 new file mode 100644
62321 index 0000000..a340c17
62322 --- /dev/null
62323 +++ b/grsecurity/gracl_fs.c
62324 @@ -0,0 +1,431 @@
62325 +#include <linux/kernel.h>
62326 +#include <linux/sched.h>
62327 +#include <linux/types.h>
62328 +#include <linux/fs.h>
62329 +#include <linux/file.h>
62330 +#include <linux/stat.h>
62331 +#include <linux/grsecurity.h>
62332 +#include <linux/grinternal.h>
62333 +#include <linux/gracl.h>
62334 +
62335 +umode_t
62336 +gr_acl_umask(void)
62337 +{
62338 + if (unlikely(!gr_acl_is_enabled()))
62339 + return 0;
62340 +
62341 + return current->role->umask;
62342 +}
62343 +
62344 +__u32
62345 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62346 + const struct vfsmount * mnt)
62347 +{
62348 + __u32 mode;
62349 +
62350 + if (unlikely(!dentry->d_inode))
62351 + return GR_FIND;
62352 +
62353 + mode =
62354 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62355 +
62356 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62357 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62358 + return mode;
62359 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62360 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62361 + return 0;
62362 + } else if (unlikely(!(mode & GR_FIND)))
62363 + return 0;
62364 +
62365 + return GR_FIND;
62366 +}
62367 +
62368 +__u32
62369 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62370 + int acc_mode)
62371 +{
62372 + __u32 reqmode = GR_FIND;
62373 + __u32 mode;
62374 +
62375 + if (unlikely(!dentry->d_inode))
62376 + return reqmode;
62377 +
62378 + if (acc_mode & MAY_APPEND)
62379 + reqmode |= GR_APPEND;
62380 + else if (acc_mode & MAY_WRITE)
62381 + reqmode |= GR_WRITE;
62382 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62383 + reqmode |= GR_READ;
62384 +
62385 + mode =
62386 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62387 + mnt);
62388 +
62389 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62390 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62391 + reqmode & GR_READ ? " reading" : "",
62392 + reqmode & GR_WRITE ? " writing" : reqmode &
62393 + GR_APPEND ? " appending" : "");
62394 + return reqmode;
62395 + } else
62396 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62397 + {
62398 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62399 + reqmode & GR_READ ? " reading" : "",
62400 + reqmode & GR_WRITE ? " writing" : reqmode &
62401 + GR_APPEND ? " appending" : "");
62402 + return 0;
62403 + } else if (unlikely((mode & reqmode) != reqmode))
62404 + return 0;
62405 +
62406 + return reqmode;
62407 +}
62408 +
62409 +__u32
62410 +gr_acl_handle_creat(const struct dentry * dentry,
62411 + const struct dentry * p_dentry,
62412 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62413 + const int imode)
62414 +{
62415 + __u32 reqmode = GR_WRITE | GR_CREATE;
62416 + __u32 mode;
62417 +
62418 + if (acc_mode & MAY_APPEND)
62419 + reqmode |= GR_APPEND;
62420 + // if a directory was required or the directory already exists, then
62421 + // don't count this open as a read
62422 + if ((acc_mode & MAY_READ) &&
62423 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62424 + reqmode |= GR_READ;
62425 + if ((open_flags & O_CREAT) &&
62426 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62427 + reqmode |= GR_SETID;
62428 +
62429 + mode =
62430 + gr_check_create(dentry, p_dentry, p_mnt,
62431 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62432 +
62433 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62434 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62435 + reqmode & GR_READ ? " reading" : "",
62436 + reqmode & GR_WRITE ? " writing" : reqmode &
62437 + GR_APPEND ? " appending" : "");
62438 + return reqmode;
62439 + } else
62440 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62441 + {
62442 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62443 + reqmode & GR_READ ? " reading" : "",
62444 + reqmode & GR_WRITE ? " writing" : reqmode &
62445 + GR_APPEND ? " appending" : "");
62446 + return 0;
62447 + } else if (unlikely((mode & reqmode) != reqmode))
62448 + return 0;
62449 +
62450 + return reqmode;
62451 +}
62452 +
62453 +__u32
62454 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62455 + const int fmode)
62456 +{
62457 + __u32 mode, reqmode = GR_FIND;
62458 +
62459 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62460 + reqmode |= GR_EXEC;
62461 + if (fmode & S_IWOTH)
62462 + reqmode |= GR_WRITE;
62463 + if (fmode & S_IROTH)
62464 + reqmode |= GR_READ;
62465 +
62466 + mode =
62467 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62468 + mnt);
62469 +
62470 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62471 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62472 + reqmode & GR_READ ? " reading" : "",
62473 + reqmode & GR_WRITE ? " writing" : "",
62474 + reqmode & GR_EXEC ? " executing" : "");
62475 + return reqmode;
62476 + } else
62477 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62478 + {
62479 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62480 + reqmode & GR_READ ? " reading" : "",
62481 + reqmode & GR_WRITE ? " writing" : "",
62482 + reqmode & GR_EXEC ? " executing" : "");
62483 + return 0;
62484 + } else if (unlikely((mode & reqmode) != reqmode))
62485 + return 0;
62486 +
62487 + return reqmode;
62488 +}
62489 +
62490 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62491 +{
62492 + __u32 mode;
62493 +
62494 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62495 +
62496 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62497 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62498 + return mode;
62499 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62500 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62501 + return 0;
62502 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62503 + return 0;
62504 +
62505 + return (reqmode);
62506 +}
62507 +
62508 +__u32
62509 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62510 +{
62511 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62512 +}
62513 +
62514 +__u32
62515 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62516 +{
62517 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62518 +}
62519 +
62520 +__u32
62521 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62522 +{
62523 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62524 +}
62525 +
62526 +__u32
62527 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62528 +{
62529 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62530 +}
62531 +
62532 +__u32
62533 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62534 + umode_t *modeptr)
62535 +{
62536 + umode_t mode;
62537 +
62538 + *modeptr &= ~gr_acl_umask();
62539 + mode = *modeptr;
62540 +
62541 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62542 + return 1;
62543 +
62544 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62545 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62546 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62547 + GR_CHMOD_ACL_MSG);
62548 + } else {
62549 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62550 + }
62551 +}
62552 +
62553 +__u32
62554 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62555 +{
62556 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62557 +}
62558 +
62559 +__u32
62560 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62561 +{
62562 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62563 +}
62564 +
62565 +__u32
62566 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62567 +{
62568 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62569 +}
62570 +
62571 +__u32
62572 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62573 +{
62574 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62575 + GR_UNIXCONNECT_ACL_MSG);
62576 +}
62577 +
62578 +/* hardlinks require at minimum create and link permission,
62579 + any additional privilege required is based on the
62580 + privilege of the file being linked to
62581 +*/
62582 +__u32
62583 +gr_acl_handle_link(const struct dentry * new_dentry,
62584 + const struct dentry * parent_dentry,
62585 + const struct vfsmount * parent_mnt,
62586 + const struct dentry * old_dentry,
62587 + const struct vfsmount * old_mnt, const struct filename *to)
62588 +{
62589 + __u32 mode;
62590 + __u32 needmode = GR_CREATE | GR_LINK;
62591 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62592 +
62593 + mode =
62594 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62595 + old_mnt);
62596 +
62597 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62598 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62599 + return mode;
62600 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62601 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62602 + return 0;
62603 + } else if (unlikely((mode & needmode) != needmode))
62604 + return 0;
62605 +
62606 + return 1;
62607 +}
62608 +
62609 +__u32
62610 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62611 + const struct dentry * parent_dentry,
62612 + const struct vfsmount * parent_mnt, const struct filename *from)
62613 +{
62614 + __u32 needmode = GR_WRITE | GR_CREATE;
62615 + __u32 mode;
62616 +
62617 + mode =
62618 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62619 + GR_CREATE | GR_AUDIT_CREATE |
62620 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62621 +
62622 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62623 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62624 + return mode;
62625 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62626 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62627 + return 0;
62628 + } else if (unlikely((mode & needmode) != needmode))
62629 + return 0;
62630 +
62631 + return (GR_WRITE | GR_CREATE);
62632 +}
62633 +
62634 +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)
62635 +{
62636 + __u32 mode;
62637 +
62638 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62639 +
62640 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62641 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62642 + return mode;
62643 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62644 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62645 + return 0;
62646 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62647 + return 0;
62648 +
62649 + return (reqmode);
62650 +}
62651 +
62652 +__u32
62653 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62654 + const struct dentry * parent_dentry,
62655 + const struct vfsmount * parent_mnt,
62656 + const int mode)
62657 +{
62658 + __u32 reqmode = GR_WRITE | GR_CREATE;
62659 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62660 + reqmode |= GR_SETID;
62661 +
62662 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62663 + reqmode, GR_MKNOD_ACL_MSG);
62664 +}
62665 +
62666 +__u32
62667 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62668 + const struct dentry *parent_dentry,
62669 + const struct vfsmount *parent_mnt)
62670 +{
62671 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62672 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62673 +}
62674 +
62675 +#define RENAME_CHECK_SUCCESS(old, new) \
62676 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62677 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62678 +
62679 +int
62680 +gr_acl_handle_rename(struct dentry *new_dentry,
62681 + struct dentry *parent_dentry,
62682 + const struct vfsmount *parent_mnt,
62683 + struct dentry *old_dentry,
62684 + struct inode *old_parent_inode,
62685 + struct vfsmount *old_mnt, const struct filename *newname)
62686 +{
62687 + __u32 comp1, comp2;
62688 + int error = 0;
62689 +
62690 + if (unlikely(!gr_acl_is_enabled()))
62691 + return 0;
62692 +
62693 + if (!new_dentry->d_inode) {
62694 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62695 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62696 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62697 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62698 + GR_DELETE | GR_AUDIT_DELETE |
62699 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62700 + GR_SUPPRESS, old_mnt);
62701 + } else {
62702 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62703 + GR_CREATE | GR_DELETE |
62704 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62705 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62706 + GR_SUPPRESS, parent_mnt);
62707 + comp2 =
62708 + gr_search_file(old_dentry,
62709 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62710 + GR_DELETE | GR_AUDIT_DELETE |
62711 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62712 + }
62713 +
62714 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62715 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62716 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62717 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62718 + && !(comp2 & GR_SUPPRESS)) {
62719 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62720 + error = -EACCES;
62721 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62722 + error = -EACCES;
62723 +
62724 + return error;
62725 +}
62726 +
62727 +void
62728 +gr_acl_handle_exit(void)
62729 +{
62730 + u16 id;
62731 + char *rolename;
62732 +
62733 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62734 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62735 + id = current->acl_role_id;
62736 + rolename = current->role->rolename;
62737 + gr_set_acls(1);
62738 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62739 + }
62740 +
62741 + gr_put_exec_file(current);
62742 + return;
62743 +}
62744 +
62745 +int
62746 +gr_acl_handle_procpidmem(const struct task_struct *task)
62747 +{
62748 + if (unlikely(!gr_acl_is_enabled()))
62749 + return 0;
62750 +
62751 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62752 + return -EACCES;
62753 +
62754 + return 0;
62755 +}
62756 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62757 new file mode 100644
62758 index 0000000..8132048
62759 --- /dev/null
62760 +++ b/grsecurity/gracl_ip.c
62761 @@ -0,0 +1,387 @@
62762 +#include <linux/kernel.h>
62763 +#include <asm/uaccess.h>
62764 +#include <asm/errno.h>
62765 +#include <net/sock.h>
62766 +#include <linux/file.h>
62767 +#include <linux/fs.h>
62768 +#include <linux/net.h>
62769 +#include <linux/in.h>
62770 +#include <linux/skbuff.h>
62771 +#include <linux/ip.h>
62772 +#include <linux/udp.h>
62773 +#include <linux/types.h>
62774 +#include <linux/sched.h>
62775 +#include <linux/netdevice.h>
62776 +#include <linux/inetdevice.h>
62777 +#include <linux/gracl.h>
62778 +#include <linux/grsecurity.h>
62779 +#include <linux/grinternal.h>
62780 +
62781 +#define GR_BIND 0x01
62782 +#define GR_CONNECT 0x02
62783 +#define GR_INVERT 0x04
62784 +#define GR_BINDOVERRIDE 0x08
62785 +#define GR_CONNECTOVERRIDE 0x10
62786 +#define GR_SOCK_FAMILY 0x20
62787 +
62788 +static const char * gr_protocols[IPPROTO_MAX] = {
62789 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62790 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62791 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62792 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62793 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62794 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62795 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62796 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62797 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62798 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62799 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62800 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62801 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62802 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62803 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62804 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62805 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62806 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62807 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62808 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62809 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62810 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62811 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62812 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62813 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62814 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62815 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62816 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62817 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62818 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62819 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62820 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62821 + };
62822 +
62823 +static const char * gr_socktypes[SOCK_MAX] = {
62824 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62825 + "unknown:7", "unknown:8", "unknown:9", "packet"
62826 + };
62827 +
62828 +static const char * gr_sockfamilies[AF_MAX+1] = {
62829 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62830 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62831 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62832 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62833 + };
62834 +
62835 +const char *
62836 +gr_proto_to_name(unsigned char proto)
62837 +{
62838 + return gr_protocols[proto];
62839 +}
62840 +
62841 +const char *
62842 +gr_socktype_to_name(unsigned char type)
62843 +{
62844 + return gr_socktypes[type];
62845 +}
62846 +
62847 +const char *
62848 +gr_sockfamily_to_name(unsigned char family)
62849 +{
62850 + return gr_sockfamilies[family];
62851 +}
62852 +
62853 +int
62854 +gr_search_socket(const int domain, const int type, const int protocol)
62855 +{
62856 + struct acl_subject_label *curr;
62857 + const struct cred *cred = current_cred();
62858 +
62859 + if (unlikely(!gr_acl_is_enabled()))
62860 + goto exit;
62861 +
62862 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62863 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62864 + goto exit; // let the kernel handle it
62865 +
62866 + curr = current->acl;
62867 +
62868 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
62869 + /* the family is allowed, if this is PF_INET allow it only if
62870 + the extra sock type/protocol checks pass */
62871 + if (domain == PF_INET)
62872 + goto inet_check;
62873 + goto exit;
62874 + } else {
62875 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62876 + __u32 fakeip = 0;
62877 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62878 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62879 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62880 + gr_to_filename(current->exec_file->f_path.dentry,
62881 + current->exec_file->f_path.mnt) :
62882 + curr->filename, curr->filename,
62883 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62884 + &current->signal->saved_ip);
62885 + goto exit;
62886 + }
62887 + goto exit_fail;
62888 + }
62889 +
62890 +inet_check:
62891 + /* the rest of this checking is for IPv4 only */
62892 + if (!curr->ips)
62893 + goto exit;
62894 +
62895 + if ((curr->ip_type & (1U << type)) &&
62896 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
62897 + goto exit;
62898 +
62899 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62900 + /* we don't place acls on raw sockets , and sometimes
62901 + dgram/ip sockets are opened for ioctl and not
62902 + bind/connect, so we'll fake a bind learn log */
62903 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62904 + __u32 fakeip = 0;
62905 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62906 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62907 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62908 + gr_to_filename(current->exec_file->f_path.dentry,
62909 + current->exec_file->f_path.mnt) :
62910 + curr->filename, curr->filename,
62911 + &fakeip, 0, type,
62912 + protocol, GR_CONNECT, &current->signal->saved_ip);
62913 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
62914 + __u32 fakeip = 0;
62915 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62916 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62917 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62918 + gr_to_filename(current->exec_file->f_path.dentry,
62919 + current->exec_file->f_path.mnt) :
62920 + curr->filename, curr->filename,
62921 + &fakeip, 0, type,
62922 + protocol, GR_BIND, &current->signal->saved_ip);
62923 + }
62924 + /* we'll log when they use connect or bind */
62925 + goto exit;
62926 + }
62927 +
62928 +exit_fail:
62929 + if (domain == PF_INET)
62930 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
62931 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
62932 + else
62933 +#ifndef CONFIG_IPV6
62934 + if (domain != PF_INET6)
62935 +#endif
62936 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
62937 + gr_socktype_to_name(type), protocol);
62938 +
62939 + return 0;
62940 +exit:
62941 + return 1;
62942 +}
62943 +
62944 +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)
62945 +{
62946 + if ((ip->mode & mode) &&
62947 + (ip_port >= ip->low) &&
62948 + (ip_port <= ip->high) &&
62949 + ((ntohl(ip_addr) & our_netmask) ==
62950 + (ntohl(our_addr) & our_netmask))
62951 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
62952 + && (ip->type & (1U << type))) {
62953 + if (ip->mode & GR_INVERT)
62954 + return 2; // specifically denied
62955 + else
62956 + return 1; // allowed
62957 + }
62958 +
62959 + return 0; // not specifically allowed, may continue parsing
62960 +}
62961 +
62962 +static int
62963 +gr_search_connectbind(const int full_mode, struct sock *sk,
62964 + struct sockaddr_in *addr, const int type)
62965 +{
62966 + char iface[IFNAMSIZ] = {0};
62967 + struct acl_subject_label *curr;
62968 + struct acl_ip_label *ip;
62969 + struct inet_sock *isk;
62970 + struct net_device *dev;
62971 + struct in_device *idev;
62972 + unsigned long i;
62973 + int ret;
62974 + int mode = full_mode & (GR_BIND | GR_CONNECT);
62975 + __u32 ip_addr = 0;
62976 + __u32 our_addr;
62977 + __u32 our_netmask;
62978 + char *p;
62979 + __u16 ip_port = 0;
62980 + const struct cred *cred = current_cred();
62981 +
62982 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
62983 + return 0;
62984 +
62985 + curr = current->acl;
62986 + isk = inet_sk(sk);
62987 +
62988 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
62989 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
62990 + addr->sin_addr.s_addr = curr->inaddr_any_override;
62991 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
62992 + struct sockaddr_in saddr;
62993 + int err;
62994 +
62995 + saddr.sin_family = AF_INET;
62996 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
62997 + saddr.sin_port = isk->inet_sport;
62998 +
62999 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63000 + if (err)
63001 + return err;
63002 +
63003 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63004 + if (err)
63005 + return err;
63006 + }
63007 +
63008 + if (!curr->ips)
63009 + return 0;
63010 +
63011 + ip_addr = addr->sin_addr.s_addr;
63012 + ip_port = ntohs(addr->sin_port);
63013 +
63014 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63015 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63016 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63017 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63018 + gr_to_filename(current->exec_file->f_path.dentry,
63019 + current->exec_file->f_path.mnt) :
63020 + curr->filename, curr->filename,
63021 + &ip_addr, ip_port, type,
63022 + sk->sk_protocol, mode, &current->signal->saved_ip);
63023 + return 0;
63024 + }
63025 +
63026 + for (i = 0; i < curr->ip_num; i++) {
63027 + ip = *(curr->ips + i);
63028 + if (ip->iface != NULL) {
63029 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63030 + p = strchr(iface, ':');
63031 + if (p != NULL)
63032 + *p = '\0';
63033 + dev = dev_get_by_name(sock_net(sk), iface);
63034 + if (dev == NULL)
63035 + continue;
63036 + idev = in_dev_get(dev);
63037 + if (idev == NULL) {
63038 + dev_put(dev);
63039 + continue;
63040 + }
63041 + rcu_read_lock();
63042 + for_ifa(idev) {
63043 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63044 + our_addr = ifa->ifa_address;
63045 + our_netmask = 0xffffffff;
63046 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63047 + if (ret == 1) {
63048 + rcu_read_unlock();
63049 + in_dev_put(idev);
63050 + dev_put(dev);
63051 + return 0;
63052 + } else if (ret == 2) {
63053 + rcu_read_unlock();
63054 + in_dev_put(idev);
63055 + dev_put(dev);
63056 + goto denied;
63057 + }
63058 + }
63059 + } endfor_ifa(idev);
63060 + rcu_read_unlock();
63061 + in_dev_put(idev);
63062 + dev_put(dev);
63063 + } else {
63064 + our_addr = ip->addr;
63065 + our_netmask = ip->netmask;
63066 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63067 + if (ret == 1)
63068 + return 0;
63069 + else if (ret == 2)
63070 + goto denied;
63071 + }
63072 + }
63073 +
63074 +denied:
63075 + if (mode == GR_BIND)
63076 + 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));
63077 + else if (mode == GR_CONNECT)
63078 + 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));
63079 +
63080 + return -EACCES;
63081 +}
63082 +
63083 +int
63084 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63085 +{
63086 + /* always allow disconnection of dgram sockets with connect */
63087 + if (addr->sin_family == AF_UNSPEC)
63088 + return 0;
63089 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63090 +}
63091 +
63092 +int
63093 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63094 +{
63095 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63096 +}
63097 +
63098 +int gr_search_listen(struct socket *sock)
63099 +{
63100 + struct sock *sk = sock->sk;
63101 + struct sockaddr_in addr;
63102 +
63103 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63104 + addr.sin_port = inet_sk(sk)->inet_sport;
63105 +
63106 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63107 +}
63108 +
63109 +int gr_search_accept(struct socket *sock)
63110 +{
63111 + struct sock *sk = sock->sk;
63112 + struct sockaddr_in addr;
63113 +
63114 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63115 + addr.sin_port = inet_sk(sk)->inet_sport;
63116 +
63117 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63118 +}
63119 +
63120 +int
63121 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63122 +{
63123 + if (addr)
63124 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63125 + else {
63126 + struct sockaddr_in sin;
63127 + const struct inet_sock *inet = inet_sk(sk);
63128 +
63129 + sin.sin_addr.s_addr = inet->inet_daddr;
63130 + sin.sin_port = inet->inet_dport;
63131 +
63132 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63133 + }
63134 +}
63135 +
63136 +int
63137 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63138 +{
63139 + struct sockaddr_in sin;
63140 +
63141 + if (unlikely(skb->len < sizeof (struct udphdr)))
63142 + return 0; // skip this packet
63143 +
63144 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63145 + sin.sin_port = udp_hdr(skb)->source;
63146 +
63147 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63148 +}
63149 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63150 new file mode 100644
63151 index 0000000..25f54ef
63152 --- /dev/null
63153 +++ b/grsecurity/gracl_learn.c
63154 @@ -0,0 +1,207 @@
63155 +#include <linux/kernel.h>
63156 +#include <linux/mm.h>
63157 +#include <linux/sched.h>
63158 +#include <linux/poll.h>
63159 +#include <linux/string.h>
63160 +#include <linux/file.h>
63161 +#include <linux/types.h>
63162 +#include <linux/vmalloc.h>
63163 +#include <linux/grinternal.h>
63164 +
63165 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63166 + size_t count, loff_t *ppos);
63167 +extern int gr_acl_is_enabled(void);
63168 +
63169 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63170 +static int gr_learn_attached;
63171 +
63172 +/* use a 512k buffer */
63173 +#define LEARN_BUFFER_SIZE (512 * 1024)
63174 +
63175 +static DEFINE_SPINLOCK(gr_learn_lock);
63176 +static DEFINE_MUTEX(gr_learn_user_mutex);
63177 +
63178 +/* we need to maintain two buffers, so that the kernel context of grlearn
63179 + uses a semaphore around the userspace copying, and the other kernel contexts
63180 + use a spinlock when copying into the buffer, since they cannot sleep
63181 +*/
63182 +static char *learn_buffer;
63183 +static char *learn_buffer_user;
63184 +static int learn_buffer_len;
63185 +static int learn_buffer_user_len;
63186 +
63187 +static ssize_t
63188 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63189 +{
63190 + DECLARE_WAITQUEUE(wait, current);
63191 + ssize_t retval = 0;
63192 +
63193 + add_wait_queue(&learn_wait, &wait);
63194 + set_current_state(TASK_INTERRUPTIBLE);
63195 + do {
63196 + mutex_lock(&gr_learn_user_mutex);
63197 + spin_lock(&gr_learn_lock);
63198 + if (learn_buffer_len)
63199 + break;
63200 + spin_unlock(&gr_learn_lock);
63201 + mutex_unlock(&gr_learn_user_mutex);
63202 + if (file->f_flags & O_NONBLOCK) {
63203 + retval = -EAGAIN;
63204 + goto out;
63205 + }
63206 + if (signal_pending(current)) {
63207 + retval = -ERESTARTSYS;
63208 + goto out;
63209 + }
63210 +
63211 + schedule();
63212 + } while (1);
63213 +
63214 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63215 + learn_buffer_user_len = learn_buffer_len;
63216 + retval = learn_buffer_len;
63217 + learn_buffer_len = 0;
63218 +
63219 + spin_unlock(&gr_learn_lock);
63220 +
63221 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63222 + retval = -EFAULT;
63223 +
63224 + mutex_unlock(&gr_learn_user_mutex);
63225 +out:
63226 + set_current_state(TASK_RUNNING);
63227 + remove_wait_queue(&learn_wait, &wait);
63228 + return retval;
63229 +}
63230 +
63231 +static unsigned int
63232 +poll_learn(struct file * file, poll_table * wait)
63233 +{
63234 + poll_wait(file, &learn_wait, wait);
63235 +
63236 + if (learn_buffer_len)
63237 + return (POLLIN | POLLRDNORM);
63238 +
63239 + return 0;
63240 +}
63241 +
63242 +void
63243 +gr_clear_learn_entries(void)
63244 +{
63245 + char *tmp;
63246 +
63247 + mutex_lock(&gr_learn_user_mutex);
63248 + spin_lock(&gr_learn_lock);
63249 + tmp = learn_buffer;
63250 + learn_buffer = NULL;
63251 + spin_unlock(&gr_learn_lock);
63252 + if (tmp)
63253 + vfree(tmp);
63254 + if (learn_buffer_user != NULL) {
63255 + vfree(learn_buffer_user);
63256 + learn_buffer_user = NULL;
63257 + }
63258 + learn_buffer_len = 0;
63259 + mutex_unlock(&gr_learn_user_mutex);
63260 +
63261 + return;
63262 +}
63263 +
63264 +void
63265 +gr_add_learn_entry(const char *fmt, ...)
63266 +{
63267 + va_list args;
63268 + unsigned int len;
63269 +
63270 + if (!gr_learn_attached)
63271 + return;
63272 +
63273 + spin_lock(&gr_learn_lock);
63274 +
63275 + /* leave a gap at the end so we know when it's "full" but don't have to
63276 + compute the exact length of the string we're trying to append
63277 + */
63278 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63279 + spin_unlock(&gr_learn_lock);
63280 + wake_up_interruptible(&learn_wait);
63281 + return;
63282 + }
63283 + if (learn_buffer == NULL) {
63284 + spin_unlock(&gr_learn_lock);
63285 + return;
63286 + }
63287 +
63288 + va_start(args, fmt);
63289 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63290 + va_end(args);
63291 +
63292 + learn_buffer_len += len + 1;
63293 +
63294 + spin_unlock(&gr_learn_lock);
63295 + wake_up_interruptible(&learn_wait);
63296 +
63297 + return;
63298 +}
63299 +
63300 +static int
63301 +open_learn(struct inode *inode, struct file *file)
63302 +{
63303 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63304 + return -EBUSY;
63305 + if (file->f_mode & FMODE_READ) {
63306 + int retval = 0;
63307 + mutex_lock(&gr_learn_user_mutex);
63308 + if (learn_buffer == NULL)
63309 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63310 + if (learn_buffer_user == NULL)
63311 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63312 + if (learn_buffer == NULL) {
63313 + retval = -ENOMEM;
63314 + goto out_error;
63315 + }
63316 + if (learn_buffer_user == NULL) {
63317 + retval = -ENOMEM;
63318 + goto out_error;
63319 + }
63320 + learn_buffer_len = 0;
63321 + learn_buffer_user_len = 0;
63322 + gr_learn_attached = 1;
63323 +out_error:
63324 + mutex_unlock(&gr_learn_user_mutex);
63325 + return retval;
63326 + }
63327 + return 0;
63328 +}
63329 +
63330 +static int
63331 +close_learn(struct inode *inode, struct file *file)
63332 +{
63333 + if (file->f_mode & FMODE_READ) {
63334 + char *tmp = NULL;
63335 + mutex_lock(&gr_learn_user_mutex);
63336 + spin_lock(&gr_learn_lock);
63337 + tmp = learn_buffer;
63338 + learn_buffer = NULL;
63339 + spin_unlock(&gr_learn_lock);
63340 + if (tmp)
63341 + vfree(tmp);
63342 + if (learn_buffer_user != NULL) {
63343 + vfree(learn_buffer_user);
63344 + learn_buffer_user = NULL;
63345 + }
63346 + learn_buffer_len = 0;
63347 + learn_buffer_user_len = 0;
63348 + gr_learn_attached = 0;
63349 + mutex_unlock(&gr_learn_user_mutex);
63350 + }
63351 +
63352 + return 0;
63353 +}
63354 +
63355 +const struct file_operations grsec_fops = {
63356 + .read = read_learn,
63357 + .write = write_grsec_handler,
63358 + .open = open_learn,
63359 + .release = close_learn,
63360 + .poll = poll_learn,
63361 +};
63362 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63363 new file mode 100644
63364 index 0000000..39645c9
63365 --- /dev/null
63366 +++ b/grsecurity/gracl_res.c
63367 @@ -0,0 +1,68 @@
63368 +#include <linux/kernel.h>
63369 +#include <linux/sched.h>
63370 +#include <linux/gracl.h>
63371 +#include <linux/grinternal.h>
63372 +
63373 +static const char *restab_log[] = {
63374 + [RLIMIT_CPU] = "RLIMIT_CPU",
63375 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63376 + [RLIMIT_DATA] = "RLIMIT_DATA",
63377 + [RLIMIT_STACK] = "RLIMIT_STACK",
63378 + [RLIMIT_CORE] = "RLIMIT_CORE",
63379 + [RLIMIT_RSS] = "RLIMIT_RSS",
63380 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63381 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63382 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63383 + [RLIMIT_AS] = "RLIMIT_AS",
63384 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63385 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63386 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63387 + [RLIMIT_NICE] = "RLIMIT_NICE",
63388 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63389 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63390 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63391 +};
63392 +
63393 +void
63394 +gr_log_resource(const struct task_struct *task,
63395 + const int res, const unsigned long wanted, const int gt)
63396 +{
63397 + const struct cred *cred;
63398 + unsigned long rlim;
63399 +
63400 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63401 + return;
63402 +
63403 + // not yet supported resource
63404 + if (unlikely(!restab_log[res]))
63405 + return;
63406 +
63407 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63408 + rlim = task_rlimit_max(task, res);
63409 + else
63410 + rlim = task_rlimit(task, res);
63411 +
63412 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63413 + return;
63414 +
63415 + rcu_read_lock();
63416 + cred = __task_cred(task);
63417 +
63418 + if (res == RLIMIT_NPROC &&
63419 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63420 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63421 + goto out_rcu_unlock;
63422 + else if (res == RLIMIT_MEMLOCK &&
63423 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63424 + goto out_rcu_unlock;
63425 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63426 + goto out_rcu_unlock;
63427 + rcu_read_unlock();
63428 +
63429 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63430 +
63431 + return;
63432 +out_rcu_unlock:
63433 + rcu_read_unlock();
63434 + return;
63435 +}
63436 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63437 new file mode 100644
63438 index 0000000..cb1e5ab
63439 --- /dev/null
63440 +++ b/grsecurity/gracl_segv.c
63441 @@ -0,0 +1,303 @@
63442 +#include <linux/kernel.h>
63443 +#include <linux/mm.h>
63444 +#include <asm/uaccess.h>
63445 +#include <asm/errno.h>
63446 +#include <asm/mman.h>
63447 +#include <net/sock.h>
63448 +#include <linux/file.h>
63449 +#include <linux/fs.h>
63450 +#include <linux/net.h>
63451 +#include <linux/in.h>
63452 +#include <linux/slab.h>
63453 +#include <linux/types.h>
63454 +#include <linux/sched.h>
63455 +#include <linux/timer.h>
63456 +#include <linux/gracl.h>
63457 +#include <linux/grsecurity.h>
63458 +#include <linux/grinternal.h>
63459 +
63460 +static struct crash_uid *uid_set;
63461 +static unsigned short uid_used;
63462 +static DEFINE_SPINLOCK(gr_uid_lock);
63463 +extern rwlock_t gr_inode_lock;
63464 +extern struct acl_subject_label *
63465 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63466 + struct acl_role_label *role);
63467 +
63468 +#ifdef CONFIG_BTRFS_FS
63469 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
63470 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
63471 +#endif
63472 +
63473 +static inline dev_t __get_dev(const struct dentry *dentry)
63474 +{
63475 +#ifdef CONFIG_BTRFS_FS
63476 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
63477 + return get_btrfs_dev_from_inode(dentry->d_inode);
63478 + else
63479 +#endif
63480 + return dentry->d_inode->i_sb->s_dev;
63481 +}
63482 +
63483 +int
63484 +gr_init_uidset(void)
63485 +{
63486 + uid_set =
63487 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63488 + uid_used = 0;
63489 +
63490 + return uid_set ? 1 : 0;
63491 +}
63492 +
63493 +void
63494 +gr_free_uidset(void)
63495 +{
63496 + if (uid_set)
63497 + kfree(uid_set);
63498 +
63499 + return;
63500 +}
63501 +
63502 +int
63503 +gr_find_uid(const uid_t uid)
63504 +{
63505 + struct crash_uid *tmp = uid_set;
63506 + uid_t buid;
63507 + int low = 0, high = uid_used - 1, mid;
63508 +
63509 + while (high >= low) {
63510 + mid = (low + high) >> 1;
63511 + buid = tmp[mid].uid;
63512 + if (buid == uid)
63513 + return mid;
63514 + if (buid > uid)
63515 + high = mid - 1;
63516 + if (buid < uid)
63517 + low = mid + 1;
63518 + }
63519 +
63520 + return -1;
63521 +}
63522 +
63523 +static __inline__ void
63524 +gr_insertsort(void)
63525 +{
63526 + unsigned short i, j;
63527 + struct crash_uid index;
63528 +
63529 + for (i = 1; i < uid_used; i++) {
63530 + index = uid_set[i];
63531 + j = i;
63532 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63533 + uid_set[j] = uid_set[j - 1];
63534 + j--;
63535 + }
63536 + uid_set[j] = index;
63537 + }
63538 +
63539 + return;
63540 +}
63541 +
63542 +static __inline__ void
63543 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63544 +{
63545 + int loc;
63546 + uid_t uid = GR_GLOBAL_UID(kuid);
63547 +
63548 + if (uid_used == GR_UIDTABLE_MAX)
63549 + return;
63550 +
63551 + loc = gr_find_uid(uid);
63552 +
63553 + if (loc >= 0) {
63554 + uid_set[loc].expires = expires;
63555 + return;
63556 + }
63557 +
63558 + uid_set[uid_used].uid = uid;
63559 + uid_set[uid_used].expires = expires;
63560 + uid_used++;
63561 +
63562 + gr_insertsort();
63563 +
63564 + return;
63565 +}
63566 +
63567 +void
63568 +gr_remove_uid(const unsigned short loc)
63569 +{
63570 + unsigned short i;
63571 +
63572 + for (i = loc + 1; i < uid_used; i++)
63573 + uid_set[i - 1] = uid_set[i];
63574 +
63575 + uid_used--;
63576 +
63577 + return;
63578 +}
63579 +
63580 +int
63581 +gr_check_crash_uid(const kuid_t kuid)
63582 +{
63583 + int loc;
63584 + int ret = 0;
63585 + uid_t uid;
63586 +
63587 + if (unlikely(!gr_acl_is_enabled()))
63588 + return 0;
63589 +
63590 + uid = GR_GLOBAL_UID(kuid);
63591 +
63592 + spin_lock(&gr_uid_lock);
63593 + loc = gr_find_uid(uid);
63594 +
63595 + if (loc < 0)
63596 + goto out_unlock;
63597 +
63598 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63599 + gr_remove_uid(loc);
63600 + else
63601 + ret = 1;
63602 +
63603 +out_unlock:
63604 + spin_unlock(&gr_uid_lock);
63605 + return ret;
63606 +}
63607 +
63608 +static __inline__ int
63609 +proc_is_setxid(const struct cred *cred)
63610 +{
63611 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63612 + !uid_eq(cred->uid, cred->fsuid))
63613 + return 1;
63614 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63615 + !gid_eq(cred->gid, cred->fsgid))
63616 + return 1;
63617 +
63618 + return 0;
63619 +}
63620 +
63621 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63622 +
63623 +void
63624 +gr_handle_crash(struct task_struct *task, const int sig)
63625 +{
63626 + struct acl_subject_label *curr;
63627 + struct task_struct *tsk, *tsk2;
63628 + const struct cred *cred;
63629 + const struct cred *cred2;
63630 +
63631 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63632 + return;
63633 +
63634 + if (unlikely(!gr_acl_is_enabled()))
63635 + return;
63636 +
63637 + curr = task->acl;
63638 +
63639 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63640 + return;
63641 +
63642 + if (time_before_eq(curr->expires, get_seconds())) {
63643 + curr->expires = 0;
63644 + curr->crashes = 0;
63645 + }
63646 +
63647 + curr->crashes++;
63648 +
63649 + if (!curr->expires)
63650 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63651 +
63652 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63653 + time_after(curr->expires, get_seconds())) {
63654 + rcu_read_lock();
63655 + cred = __task_cred(task);
63656 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63657 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63658 + spin_lock(&gr_uid_lock);
63659 + gr_insert_uid(cred->uid, curr->expires);
63660 + spin_unlock(&gr_uid_lock);
63661 + curr->expires = 0;
63662 + curr->crashes = 0;
63663 + read_lock(&tasklist_lock);
63664 + do_each_thread(tsk2, tsk) {
63665 + cred2 = __task_cred(tsk);
63666 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63667 + gr_fake_force_sig(SIGKILL, tsk);
63668 + } while_each_thread(tsk2, tsk);
63669 + read_unlock(&tasklist_lock);
63670 + } else {
63671 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63672 + read_lock(&tasklist_lock);
63673 + read_lock(&grsec_exec_file_lock);
63674 + do_each_thread(tsk2, tsk) {
63675 + if (likely(tsk != task)) {
63676 + // if this thread has the same subject as the one that triggered
63677 + // RES_CRASH and it's the same binary, kill it
63678 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63679 + gr_fake_force_sig(SIGKILL, tsk);
63680 + }
63681 + } while_each_thread(tsk2, tsk);
63682 + read_unlock(&grsec_exec_file_lock);
63683 + read_unlock(&tasklist_lock);
63684 + }
63685 + rcu_read_unlock();
63686 + }
63687 +
63688 + return;
63689 +}
63690 +
63691 +int
63692 +gr_check_crash_exec(const struct file *filp)
63693 +{
63694 + struct acl_subject_label *curr;
63695 +
63696 + if (unlikely(!gr_acl_is_enabled()))
63697 + return 0;
63698 +
63699 + read_lock(&gr_inode_lock);
63700 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63701 + __get_dev(filp->f_path.dentry),
63702 + current->role);
63703 + read_unlock(&gr_inode_lock);
63704 +
63705 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63706 + (!curr->crashes && !curr->expires))
63707 + return 0;
63708 +
63709 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63710 + time_after(curr->expires, get_seconds()))
63711 + return 1;
63712 + else if (time_before_eq(curr->expires, get_seconds())) {
63713 + curr->crashes = 0;
63714 + curr->expires = 0;
63715 + }
63716 +
63717 + return 0;
63718 +}
63719 +
63720 +void
63721 +gr_handle_alertkill(struct task_struct *task)
63722 +{
63723 + struct acl_subject_label *curracl;
63724 + __u32 curr_ip;
63725 + struct task_struct *p, *p2;
63726 +
63727 + if (unlikely(!gr_acl_is_enabled()))
63728 + return;
63729 +
63730 + curracl = task->acl;
63731 + curr_ip = task->signal->curr_ip;
63732 +
63733 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63734 + read_lock(&tasklist_lock);
63735 + do_each_thread(p2, p) {
63736 + if (p->signal->curr_ip == curr_ip)
63737 + gr_fake_force_sig(SIGKILL, p);
63738 + } while_each_thread(p2, p);
63739 + read_unlock(&tasklist_lock);
63740 + } else if (curracl->mode & GR_KILLPROC)
63741 + gr_fake_force_sig(SIGKILL, task);
63742 +
63743 + return;
63744 +}
63745 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63746 new file mode 100644
63747 index 0000000..98011b0
63748 --- /dev/null
63749 +++ b/grsecurity/gracl_shm.c
63750 @@ -0,0 +1,40 @@
63751 +#include <linux/kernel.h>
63752 +#include <linux/mm.h>
63753 +#include <linux/sched.h>
63754 +#include <linux/file.h>
63755 +#include <linux/ipc.h>
63756 +#include <linux/gracl.h>
63757 +#include <linux/grsecurity.h>
63758 +#include <linux/grinternal.h>
63759 +
63760 +int
63761 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63762 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63763 +{
63764 + struct task_struct *task;
63765 +
63766 + if (!gr_acl_is_enabled())
63767 + return 1;
63768 +
63769 + rcu_read_lock();
63770 + read_lock(&tasklist_lock);
63771 +
63772 + task = find_task_by_vpid(shm_cprid);
63773 +
63774 + if (unlikely(!task))
63775 + task = find_task_by_vpid(shm_lapid);
63776 +
63777 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63778 + (task_pid_nr(task) == shm_lapid)) &&
63779 + (task->acl->mode & GR_PROTSHM) &&
63780 + (task->acl != current->acl))) {
63781 + read_unlock(&tasklist_lock);
63782 + rcu_read_unlock();
63783 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63784 + return 0;
63785 + }
63786 + read_unlock(&tasklist_lock);
63787 + rcu_read_unlock();
63788 +
63789 + return 1;
63790 +}
63791 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63792 new file mode 100644
63793 index 0000000..bc0be01
63794 --- /dev/null
63795 +++ b/grsecurity/grsec_chdir.c
63796 @@ -0,0 +1,19 @@
63797 +#include <linux/kernel.h>
63798 +#include <linux/sched.h>
63799 +#include <linux/fs.h>
63800 +#include <linux/file.h>
63801 +#include <linux/grsecurity.h>
63802 +#include <linux/grinternal.h>
63803 +
63804 +void
63805 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63806 +{
63807 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63808 + if ((grsec_enable_chdir && grsec_enable_group &&
63809 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63810 + !grsec_enable_group)) {
63811 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63812 + }
63813 +#endif
63814 + return;
63815 +}
63816 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63817 new file mode 100644
63818 index 0000000..6d2de57
63819 --- /dev/null
63820 +++ b/grsecurity/grsec_chroot.c
63821 @@ -0,0 +1,357 @@
63822 +#include <linux/kernel.h>
63823 +#include <linux/module.h>
63824 +#include <linux/sched.h>
63825 +#include <linux/file.h>
63826 +#include <linux/fs.h>
63827 +#include <linux/mount.h>
63828 +#include <linux/types.h>
63829 +#include "../fs/mount.h"
63830 +#include <linux/grsecurity.h>
63831 +#include <linux/grinternal.h>
63832 +
63833 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
63834 +{
63835 +#ifdef CONFIG_GRKERNSEC
63836 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
63837 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root)
63838 + task->gr_is_chrooted = 1;
63839 + else
63840 + task->gr_is_chrooted = 0;
63841 +
63842 + task->gr_chroot_dentry = path->dentry;
63843 +#endif
63844 + return;
63845 +}
63846 +
63847 +void gr_clear_chroot_entries(struct task_struct *task)
63848 +{
63849 +#ifdef CONFIG_GRKERNSEC
63850 + task->gr_is_chrooted = 0;
63851 + task->gr_chroot_dentry = NULL;
63852 +#endif
63853 + return;
63854 +}
63855 +
63856 +int
63857 +gr_handle_chroot_unix(const pid_t pid)
63858 +{
63859 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63860 + struct task_struct *p;
63861 +
63862 + if (unlikely(!grsec_enable_chroot_unix))
63863 + return 1;
63864 +
63865 + if (likely(!proc_is_chrooted(current)))
63866 + return 1;
63867 +
63868 + rcu_read_lock();
63869 + read_lock(&tasklist_lock);
63870 + p = find_task_by_vpid_unrestricted(pid);
63871 + if (unlikely(p && !have_same_root(current, p))) {
63872 + read_unlock(&tasklist_lock);
63873 + rcu_read_unlock();
63874 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63875 + return 0;
63876 + }
63877 + read_unlock(&tasklist_lock);
63878 + rcu_read_unlock();
63879 +#endif
63880 + return 1;
63881 +}
63882 +
63883 +int
63884 +gr_handle_chroot_nice(void)
63885 +{
63886 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63887 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63888 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63889 + return -EPERM;
63890 + }
63891 +#endif
63892 + return 0;
63893 +}
63894 +
63895 +int
63896 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
63897 +{
63898 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63899 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
63900 + && proc_is_chrooted(current)) {
63901 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
63902 + return -EACCES;
63903 + }
63904 +#endif
63905 + return 0;
63906 +}
63907 +
63908 +int
63909 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
63910 +{
63911 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63912 + struct task_struct *p;
63913 + int ret = 0;
63914 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
63915 + return ret;
63916 +
63917 + read_lock(&tasklist_lock);
63918 + do_each_pid_task(pid, type, p) {
63919 + if (!have_same_root(current, p)) {
63920 + ret = 1;
63921 + goto out;
63922 + }
63923 + } while_each_pid_task(pid, type, p);
63924 +out:
63925 + read_unlock(&tasklist_lock);
63926 + return ret;
63927 +#endif
63928 + return 0;
63929 +}
63930 +
63931 +int
63932 +gr_pid_is_chrooted(struct task_struct *p)
63933 +{
63934 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63935 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
63936 + return 0;
63937 +
63938 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
63939 + !have_same_root(current, p)) {
63940 + return 1;
63941 + }
63942 +#endif
63943 + return 0;
63944 +}
63945 +
63946 +EXPORT_SYMBOL(gr_pid_is_chrooted);
63947 +
63948 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
63949 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
63950 +{
63951 + struct path path, currentroot;
63952 + int ret = 0;
63953 +
63954 + path.dentry = (struct dentry *)u_dentry;
63955 + path.mnt = (struct vfsmount *)u_mnt;
63956 + get_fs_root(current->fs, &currentroot);
63957 + if (path_is_under(&path, &currentroot))
63958 + ret = 1;
63959 + path_put(&currentroot);
63960 +
63961 + return ret;
63962 +}
63963 +#endif
63964 +
63965 +int
63966 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
63967 +{
63968 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
63969 + if (!grsec_enable_chroot_fchdir)
63970 + return 1;
63971 +
63972 + if (!proc_is_chrooted(current))
63973 + return 1;
63974 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
63975 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
63976 + return 0;
63977 + }
63978 +#endif
63979 + return 1;
63980 +}
63981 +
63982 +int
63983 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63984 + const time_t shm_createtime)
63985 +{
63986 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
63987 + struct task_struct *p;
63988 + time_t starttime;
63989 +
63990 + if (unlikely(!grsec_enable_chroot_shmat))
63991 + return 1;
63992 +
63993 + if (likely(!proc_is_chrooted(current)))
63994 + return 1;
63995 +
63996 + rcu_read_lock();
63997 + read_lock(&tasklist_lock);
63998 +
63999 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64000 + starttime = p->start_time.tv_sec;
64001 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64002 + if (have_same_root(current, p)) {
64003 + goto allow;
64004 + } else {
64005 + read_unlock(&tasklist_lock);
64006 + rcu_read_unlock();
64007 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64008 + return 0;
64009 + }
64010 + }
64011 + /* creator exited, pid reuse, fall through to next check */
64012 + }
64013 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64014 + if (unlikely(!have_same_root(current, p))) {
64015 + read_unlock(&tasklist_lock);
64016 + rcu_read_unlock();
64017 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64018 + return 0;
64019 + }
64020 + }
64021 +
64022 +allow:
64023 + read_unlock(&tasklist_lock);
64024 + rcu_read_unlock();
64025 +#endif
64026 + return 1;
64027 +}
64028 +
64029 +void
64030 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64031 +{
64032 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64033 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64034 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64035 +#endif
64036 + return;
64037 +}
64038 +
64039 +int
64040 +gr_handle_chroot_mknod(const struct dentry *dentry,
64041 + const struct vfsmount *mnt, const int mode)
64042 +{
64043 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64044 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64045 + proc_is_chrooted(current)) {
64046 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64047 + return -EPERM;
64048 + }
64049 +#endif
64050 + return 0;
64051 +}
64052 +
64053 +int
64054 +gr_handle_chroot_mount(const struct dentry *dentry,
64055 + const struct vfsmount *mnt, const char *dev_name)
64056 +{
64057 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64058 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64059 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64060 + return -EPERM;
64061 + }
64062 +#endif
64063 + return 0;
64064 +}
64065 +
64066 +int
64067 +gr_handle_chroot_pivot(void)
64068 +{
64069 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64070 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64071 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64072 + return -EPERM;
64073 + }
64074 +#endif
64075 + return 0;
64076 +}
64077 +
64078 +int
64079 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64080 +{
64081 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64082 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64083 + !gr_is_outside_chroot(dentry, mnt)) {
64084 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64085 + return -EPERM;
64086 + }
64087 +#endif
64088 + return 0;
64089 +}
64090 +
64091 +extern const char *captab_log[];
64092 +extern int captab_log_entries;
64093 +
64094 +int
64095 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64096 +{
64097 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64098 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64099 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64100 + if (cap_raised(chroot_caps, cap)) {
64101 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64102 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64103 + }
64104 + return 0;
64105 + }
64106 + }
64107 +#endif
64108 + return 1;
64109 +}
64110 +
64111 +int
64112 +gr_chroot_is_capable(const int cap)
64113 +{
64114 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64115 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64116 +#endif
64117 + return 1;
64118 +}
64119 +
64120 +int
64121 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64122 +{
64123 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64124 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64125 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64126 + if (cap_raised(chroot_caps, cap)) {
64127 + return 0;
64128 + }
64129 + }
64130 +#endif
64131 + return 1;
64132 +}
64133 +
64134 +int
64135 +gr_chroot_is_capable_nolog(const int cap)
64136 +{
64137 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64138 + return gr_task_chroot_is_capable_nolog(current, cap);
64139 +#endif
64140 + return 1;
64141 +}
64142 +
64143 +int
64144 +gr_handle_chroot_sysctl(const int op)
64145 +{
64146 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64147 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64148 + proc_is_chrooted(current))
64149 + return -EACCES;
64150 +#endif
64151 + return 0;
64152 +}
64153 +
64154 +void
64155 +gr_handle_chroot_chdir(struct path *path)
64156 +{
64157 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64158 + if (grsec_enable_chroot_chdir)
64159 + set_fs_pwd(current->fs, path);
64160 +#endif
64161 + return;
64162 +}
64163 +
64164 +int
64165 +gr_handle_chroot_chmod(const struct dentry *dentry,
64166 + const struct vfsmount *mnt, const int mode)
64167 +{
64168 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64169 + /* allow chmod +s on directories, but not files */
64170 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64171 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64172 + proc_is_chrooted(current)) {
64173 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64174 + return -EPERM;
64175 + }
64176 +#endif
64177 + return 0;
64178 +}
64179 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64180 new file mode 100644
64181 index 0000000..207d409
64182 --- /dev/null
64183 +++ b/grsecurity/grsec_disabled.c
64184 @@ -0,0 +1,434 @@
64185 +#include <linux/kernel.h>
64186 +#include <linux/module.h>
64187 +#include <linux/sched.h>
64188 +#include <linux/file.h>
64189 +#include <linux/fs.h>
64190 +#include <linux/kdev_t.h>
64191 +#include <linux/net.h>
64192 +#include <linux/in.h>
64193 +#include <linux/ip.h>
64194 +#include <linux/skbuff.h>
64195 +#include <linux/sysctl.h>
64196 +
64197 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64198 +void
64199 +pax_set_initial_flags(struct linux_binprm *bprm)
64200 +{
64201 + return;
64202 +}
64203 +#endif
64204 +
64205 +#ifdef CONFIG_SYSCTL
64206 +__u32
64207 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64208 +{
64209 + return 0;
64210 +}
64211 +#endif
64212 +
64213 +#ifdef CONFIG_TASKSTATS
64214 +int gr_is_taskstats_denied(int pid)
64215 +{
64216 + return 0;
64217 +}
64218 +#endif
64219 +
64220 +int
64221 +gr_acl_is_enabled(void)
64222 +{
64223 + return 0;
64224 +}
64225 +
64226 +void
64227 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64228 +{
64229 + return;
64230 +}
64231 +
64232 +int
64233 +gr_handle_rawio(const struct inode *inode)
64234 +{
64235 + return 0;
64236 +}
64237 +
64238 +void
64239 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64240 +{
64241 + return;
64242 +}
64243 +
64244 +int
64245 +gr_handle_ptrace(struct task_struct *task, const long request)
64246 +{
64247 + return 0;
64248 +}
64249 +
64250 +int
64251 +gr_handle_proc_ptrace(struct task_struct *task)
64252 +{
64253 + return 0;
64254 +}
64255 +
64256 +int
64257 +gr_set_acls(const int type)
64258 +{
64259 + return 0;
64260 +}
64261 +
64262 +int
64263 +gr_check_hidden_task(const struct task_struct *tsk)
64264 +{
64265 + return 0;
64266 +}
64267 +
64268 +int
64269 +gr_check_protected_task(const struct task_struct *task)
64270 +{
64271 + return 0;
64272 +}
64273 +
64274 +int
64275 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64276 +{
64277 + return 0;
64278 +}
64279 +
64280 +void
64281 +gr_copy_label(struct task_struct *tsk)
64282 +{
64283 + return;
64284 +}
64285 +
64286 +void
64287 +gr_set_pax_flags(struct task_struct *task)
64288 +{
64289 + return;
64290 +}
64291 +
64292 +int
64293 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64294 + const int unsafe_share)
64295 +{
64296 + return 0;
64297 +}
64298 +
64299 +void
64300 +gr_handle_delete(const ino_t ino, const dev_t dev)
64301 +{
64302 + return;
64303 +}
64304 +
64305 +void
64306 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64307 +{
64308 + return;
64309 +}
64310 +
64311 +void
64312 +gr_handle_crash(struct task_struct *task, const int sig)
64313 +{
64314 + return;
64315 +}
64316 +
64317 +int
64318 +gr_check_crash_exec(const struct file *filp)
64319 +{
64320 + return 0;
64321 +}
64322 +
64323 +int
64324 +gr_check_crash_uid(const kuid_t uid)
64325 +{
64326 + return 0;
64327 +}
64328 +
64329 +void
64330 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64331 + struct dentry *old_dentry,
64332 + struct dentry *new_dentry,
64333 + struct vfsmount *mnt, const __u8 replace)
64334 +{
64335 + return;
64336 +}
64337 +
64338 +int
64339 +gr_search_socket(const int family, const int type, const int protocol)
64340 +{
64341 + return 1;
64342 +}
64343 +
64344 +int
64345 +gr_search_connectbind(const int mode, const struct socket *sock,
64346 + const struct sockaddr_in *addr)
64347 +{
64348 + return 0;
64349 +}
64350 +
64351 +void
64352 +gr_handle_alertkill(struct task_struct *task)
64353 +{
64354 + return;
64355 +}
64356 +
64357 +__u32
64358 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64359 +{
64360 + return 1;
64361 +}
64362 +
64363 +__u32
64364 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64365 + const struct vfsmount * mnt)
64366 +{
64367 + return 1;
64368 +}
64369 +
64370 +__u32
64371 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64372 + int acc_mode)
64373 +{
64374 + return 1;
64375 +}
64376 +
64377 +__u32
64378 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64379 +{
64380 + return 1;
64381 +}
64382 +
64383 +__u32
64384 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64385 +{
64386 + return 1;
64387 +}
64388 +
64389 +int
64390 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64391 + unsigned int *vm_flags)
64392 +{
64393 + return 1;
64394 +}
64395 +
64396 +__u32
64397 +gr_acl_handle_truncate(const struct dentry * dentry,
64398 + const struct vfsmount * mnt)
64399 +{
64400 + return 1;
64401 +}
64402 +
64403 +__u32
64404 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64405 +{
64406 + return 1;
64407 +}
64408 +
64409 +__u32
64410 +gr_acl_handle_access(const struct dentry * dentry,
64411 + const struct vfsmount * mnt, const int fmode)
64412 +{
64413 + return 1;
64414 +}
64415 +
64416 +__u32
64417 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64418 + umode_t *mode)
64419 +{
64420 + return 1;
64421 +}
64422 +
64423 +__u32
64424 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64425 +{
64426 + return 1;
64427 +}
64428 +
64429 +__u32
64430 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64431 +{
64432 + return 1;
64433 +}
64434 +
64435 +void
64436 +grsecurity_init(void)
64437 +{
64438 + return;
64439 +}
64440 +
64441 +umode_t gr_acl_umask(void)
64442 +{
64443 + return 0;
64444 +}
64445 +
64446 +__u32
64447 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64448 + const struct dentry * parent_dentry,
64449 + const struct vfsmount * parent_mnt,
64450 + const int mode)
64451 +{
64452 + return 1;
64453 +}
64454 +
64455 +__u32
64456 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64457 + const struct dentry * parent_dentry,
64458 + const struct vfsmount * parent_mnt)
64459 +{
64460 + return 1;
64461 +}
64462 +
64463 +__u32
64464 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64465 + const struct dentry * parent_dentry,
64466 + const struct vfsmount * parent_mnt, const struct filename *from)
64467 +{
64468 + return 1;
64469 +}
64470 +
64471 +__u32
64472 +gr_acl_handle_link(const struct dentry * new_dentry,
64473 + const struct dentry * parent_dentry,
64474 + const struct vfsmount * parent_mnt,
64475 + const struct dentry * old_dentry,
64476 + const struct vfsmount * old_mnt, const struct filename *to)
64477 +{
64478 + return 1;
64479 +}
64480 +
64481 +int
64482 +gr_acl_handle_rename(const struct dentry *new_dentry,
64483 + const struct dentry *parent_dentry,
64484 + const struct vfsmount *parent_mnt,
64485 + const struct dentry *old_dentry,
64486 + const struct inode *old_parent_inode,
64487 + const struct vfsmount *old_mnt, const struct filename *newname)
64488 +{
64489 + return 0;
64490 +}
64491 +
64492 +int
64493 +gr_acl_handle_filldir(const struct file *file, const char *name,
64494 + const int namelen, const ino_t ino)
64495 +{
64496 + return 1;
64497 +}
64498 +
64499 +int
64500 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64501 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64502 +{
64503 + return 1;
64504 +}
64505 +
64506 +int
64507 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64508 +{
64509 + return 0;
64510 +}
64511 +
64512 +int
64513 +gr_search_accept(const struct socket *sock)
64514 +{
64515 + return 0;
64516 +}
64517 +
64518 +int
64519 +gr_search_listen(const struct socket *sock)
64520 +{
64521 + return 0;
64522 +}
64523 +
64524 +int
64525 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64526 +{
64527 + return 0;
64528 +}
64529 +
64530 +__u32
64531 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64532 +{
64533 + return 1;
64534 +}
64535 +
64536 +__u32
64537 +gr_acl_handle_creat(const struct dentry * dentry,
64538 + const struct dentry * p_dentry,
64539 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64540 + const int imode)
64541 +{
64542 + return 1;
64543 +}
64544 +
64545 +void
64546 +gr_acl_handle_exit(void)
64547 +{
64548 + return;
64549 +}
64550 +
64551 +int
64552 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64553 +{
64554 + return 1;
64555 +}
64556 +
64557 +void
64558 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64559 +{
64560 + return;
64561 +}
64562 +
64563 +int
64564 +gr_acl_handle_procpidmem(const struct task_struct *task)
64565 +{
64566 + return 0;
64567 +}
64568 +
64569 +int
64570 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64571 +{
64572 + return 0;
64573 +}
64574 +
64575 +int
64576 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64577 +{
64578 + return 0;
64579 +}
64580 +
64581 +void
64582 +gr_set_kernel_label(struct task_struct *task)
64583 +{
64584 + return;
64585 +}
64586 +
64587 +int
64588 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64589 +{
64590 + return 0;
64591 +}
64592 +
64593 +int
64594 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64595 +{
64596 + return 0;
64597 +}
64598 +
64599 +int gr_acl_enable_at_secure(void)
64600 +{
64601 + return 0;
64602 +}
64603 +
64604 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64605 +{
64606 + return dentry->d_inode->i_sb->s_dev;
64607 +}
64608 +
64609 +void gr_put_exec_file(struct task_struct *task)
64610 +{
64611 + return;
64612 +}
64613 +
64614 +EXPORT_SYMBOL(gr_set_kernel_label);
64615 +#ifdef CONFIG_SECURITY
64616 +EXPORT_SYMBOL(gr_check_user_change);
64617 +EXPORT_SYMBOL(gr_check_group_change);
64618 +#endif
64619 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64620 new file mode 100644
64621 index 0000000..387032b
64622 --- /dev/null
64623 +++ b/grsecurity/grsec_exec.c
64624 @@ -0,0 +1,187 @@
64625 +#include <linux/kernel.h>
64626 +#include <linux/sched.h>
64627 +#include <linux/file.h>
64628 +#include <linux/binfmts.h>
64629 +#include <linux/fs.h>
64630 +#include <linux/types.h>
64631 +#include <linux/grdefs.h>
64632 +#include <linux/grsecurity.h>
64633 +#include <linux/grinternal.h>
64634 +#include <linux/capability.h>
64635 +#include <linux/module.h>
64636 +#include <linux/compat.h>
64637 +
64638 +#include <asm/uaccess.h>
64639 +
64640 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64641 +static char gr_exec_arg_buf[132];
64642 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64643 +#endif
64644 +
64645 +struct user_arg_ptr {
64646 +#ifdef CONFIG_COMPAT
64647 + bool is_compat;
64648 +#endif
64649 + union {
64650 + const char __user *const __user *native;
64651 +#ifdef CONFIG_COMPAT
64652 + const compat_uptr_t __user *compat;
64653 +#endif
64654 + } ptr;
64655 +};
64656 +
64657 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64658 +
64659 +void
64660 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64661 +{
64662 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64663 + char *grarg = gr_exec_arg_buf;
64664 + unsigned int i, x, execlen = 0;
64665 + char c;
64666 +
64667 + if (!((grsec_enable_execlog && grsec_enable_group &&
64668 + in_group_p(grsec_audit_gid))
64669 + || (grsec_enable_execlog && !grsec_enable_group)))
64670 + return;
64671 +
64672 + mutex_lock(&gr_exec_arg_mutex);
64673 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64674 +
64675 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64676 + const char __user *p;
64677 + unsigned int len;
64678 +
64679 + p = get_user_arg_ptr(argv, i);
64680 + if (IS_ERR(p))
64681 + goto log;
64682 +
64683 + len = strnlen_user(p, 128 - execlen);
64684 + if (len > 128 - execlen)
64685 + len = 128 - execlen;
64686 + else if (len > 0)
64687 + len--;
64688 + if (copy_from_user(grarg + execlen, p, len))
64689 + goto log;
64690 +
64691 + /* rewrite unprintable characters */
64692 + for (x = 0; x < len; x++) {
64693 + c = *(grarg + execlen + x);
64694 + if (c < 32 || c > 126)
64695 + *(grarg + execlen + x) = ' ';
64696 + }
64697 +
64698 + execlen += len;
64699 + *(grarg + execlen) = ' ';
64700 + *(grarg + execlen + 1) = '\0';
64701 + execlen++;
64702 + }
64703 +
64704 + log:
64705 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64706 + bprm->file->f_path.mnt, grarg);
64707 + mutex_unlock(&gr_exec_arg_mutex);
64708 +#endif
64709 + return;
64710 +}
64711 +
64712 +#ifdef CONFIG_GRKERNSEC
64713 +extern int gr_acl_is_capable(const int cap);
64714 +extern int gr_acl_is_capable_nolog(const int cap);
64715 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64716 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64717 +extern int gr_chroot_is_capable(const int cap);
64718 +extern int gr_chroot_is_capable_nolog(const int cap);
64719 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64720 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64721 +#endif
64722 +
64723 +const char *captab_log[] = {
64724 + "CAP_CHOWN",
64725 + "CAP_DAC_OVERRIDE",
64726 + "CAP_DAC_READ_SEARCH",
64727 + "CAP_FOWNER",
64728 + "CAP_FSETID",
64729 + "CAP_KILL",
64730 + "CAP_SETGID",
64731 + "CAP_SETUID",
64732 + "CAP_SETPCAP",
64733 + "CAP_LINUX_IMMUTABLE",
64734 + "CAP_NET_BIND_SERVICE",
64735 + "CAP_NET_BROADCAST",
64736 + "CAP_NET_ADMIN",
64737 + "CAP_NET_RAW",
64738 + "CAP_IPC_LOCK",
64739 + "CAP_IPC_OWNER",
64740 + "CAP_SYS_MODULE",
64741 + "CAP_SYS_RAWIO",
64742 + "CAP_SYS_CHROOT",
64743 + "CAP_SYS_PTRACE",
64744 + "CAP_SYS_PACCT",
64745 + "CAP_SYS_ADMIN",
64746 + "CAP_SYS_BOOT",
64747 + "CAP_SYS_NICE",
64748 + "CAP_SYS_RESOURCE",
64749 + "CAP_SYS_TIME",
64750 + "CAP_SYS_TTY_CONFIG",
64751 + "CAP_MKNOD",
64752 + "CAP_LEASE",
64753 + "CAP_AUDIT_WRITE",
64754 + "CAP_AUDIT_CONTROL",
64755 + "CAP_SETFCAP",
64756 + "CAP_MAC_OVERRIDE",
64757 + "CAP_MAC_ADMIN",
64758 + "CAP_SYSLOG",
64759 + "CAP_WAKE_ALARM"
64760 +};
64761 +
64762 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64763 +
64764 +int gr_is_capable(const int cap)
64765 +{
64766 +#ifdef CONFIG_GRKERNSEC
64767 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64768 + return 1;
64769 + return 0;
64770 +#else
64771 + return 1;
64772 +#endif
64773 +}
64774 +
64775 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64776 +{
64777 +#ifdef CONFIG_GRKERNSEC
64778 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64779 + return 1;
64780 + return 0;
64781 +#else
64782 + return 1;
64783 +#endif
64784 +}
64785 +
64786 +int gr_is_capable_nolog(const int cap)
64787 +{
64788 +#ifdef CONFIG_GRKERNSEC
64789 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64790 + return 1;
64791 + return 0;
64792 +#else
64793 + return 1;
64794 +#endif
64795 +}
64796 +
64797 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64798 +{
64799 +#ifdef CONFIG_GRKERNSEC
64800 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64801 + return 1;
64802 + return 0;
64803 +#else
64804 + return 1;
64805 +#endif
64806 +}
64807 +
64808 +EXPORT_SYMBOL(gr_is_capable);
64809 +EXPORT_SYMBOL(gr_is_capable_nolog);
64810 +EXPORT_SYMBOL(gr_task_is_capable);
64811 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64812 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64813 new file mode 100644
64814 index 0000000..06cc6ea
64815 --- /dev/null
64816 +++ b/grsecurity/grsec_fifo.c
64817 @@ -0,0 +1,24 @@
64818 +#include <linux/kernel.h>
64819 +#include <linux/sched.h>
64820 +#include <linux/fs.h>
64821 +#include <linux/file.h>
64822 +#include <linux/grinternal.h>
64823 +
64824 +int
64825 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
64826 + const struct dentry *dir, const int flag, const int acc_mode)
64827 +{
64828 +#ifdef CONFIG_GRKERNSEC_FIFO
64829 + const struct cred *cred = current_cred();
64830 +
64831 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64832 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64833 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64834 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64835 + if (!inode_permission(dentry->d_inode, acc_mode))
64836 + 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));
64837 + return -EACCES;
64838 + }
64839 +#endif
64840 + return 0;
64841 +}
64842 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64843 new file mode 100644
64844 index 0000000..8ca18bf
64845 --- /dev/null
64846 +++ b/grsecurity/grsec_fork.c
64847 @@ -0,0 +1,23 @@
64848 +#include <linux/kernel.h>
64849 +#include <linux/sched.h>
64850 +#include <linux/grsecurity.h>
64851 +#include <linux/grinternal.h>
64852 +#include <linux/errno.h>
64853 +
64854 +void
64855 +gr_log_forkfail(const int retval)
64856 +{
64857 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64858 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64859 + switch (retval) {
64860 + case -EAGAIN:
64861 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64862 + break;
64863 + case -ENOMEM:
64864 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64865 + break;
64866 + }
64867 + }
64868 +#endif
64869 + return;
64870 +}
64871 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64872 new file mode 100644
64873 index 0000000..a862e9f
64874 --- /dev/null
64875 +++ b/grsecurity/grsec_init.c
64876 @@ -0,0 +1,283 @@
64877 +#include <linux/kernel.h>
64878 +#include <linux/sched.h>
64879 +#include <linux/mm.h>
64880 +#include <linux/gracl.h>
64881 +#include <linux/slab.h>
64882 +#include <linux/vmalloc.h>
64883 +#include <linux/percpu.h>
64884 +#include <linux/module.h>
64885 +
64886 +int grsec_enable_ptrace_readexec;
64887 +int grsec_enable_setxid;
64888 +int grsec_enable_symlinkown;
64889 +kgid_t grsec_symlinkown_gid;
64890 +int grsec_enable_brute;
64891 +int grsec_enable_link;
64892 +int grsec_enable_dmesg;
64893 +int grsec_enable_harden_ptrace;
64894 +int grsec_enable_fifo;
64895 +int grsec_enable_execlog;
64896 +int grsec_enable_signal;
64897 +int grsec_enable_forkfail;
64898 +int grsec_enable_audit_ptrace;
64899 +int grsec_enable_time;
64900 +int grsec_enable_audit_textrel;
64901 +int grsec_enable_group;
64902 +kgid_t grsec_audit_gid;
64903 +int grsec_enable_chdir;
64904 +int grsec_enable_mount;
64905 +int grsec_enable_rofs;
64906 +int grsec_enable_chroot_findtask;
64907 +int grsec_enable_chroot_mount;
64908 +int grsec_enable_chroot_shmat;
64909 +int grsec_enable_chroot_fchdir;
64910 +int grsec_enable_chroot_double;
64911 +int grsec_enable_chroot_pivot;
64912 +int grsec_enable_chroot_chdir;
64913 +int grsec_enable_chroot_chmod;
64914 +int grsec_enable_chroot_mknod;
64915 +int grsec_enable_chroot_nice;
64916 +int grsec_enable_chroot_execlog;
64917 +int grsec_enable_chroot_caps;
64918 +int grsec_enable_chroot_sysctl;
64919 +int grsec_enable_chroot_unix;
64920 +int grsec_enable_tpe;
64921 +kgid_t grsec_tpe_gid;
64922 +int grsec_enable_blackhole;
64923 +#ifdef CONFIG_IPV6_MODULE
64924 +EXPORT_SYMBOL(grsec_enable_blackhole);
64925 +#endif
64926 +int grsec_lastack_retries;
64927 +int grsec_enable_tpe_all;
64928 +int grsec_enable_tpe_invert;
64929 +int grsec_enable_socket_all;
64930 +kgid_t grsec_socket_all_gid;
64931 +int grsec_enable_socket_client;
64932 +kgid_t grsec_socket_client_gid;
64933 +int grsec_enable_socket_server;
64934 +kgid_t grsec_socket_server_gid;
64935 +int grsec_resource_logging;
64936 +int grsec_disable_privio;
64937 +int grsec_enable_log_rwxmaps;
64938 +int grsec_lock;
64939 +
64940 +DEFINE_SPINLOCK(grsec_alert_lock);
64941 +unsigned long grsec_alert_wtime = 0;
64942 +unsigned long grsec_alert_fyet = 0;
64943 +
64944 +DEFINE_SPINLOCK(grsec_audit_lock);
64945 +
64946 +DEFINE_RWLOCK(grsec_exec_file_lock);
64947 +
64948 +char *gr_shared_page[4];
64949 +
64950 +char *gr_alert_log_fmt;
64951 +char *gr_audit_log_fmt;
64952 +char *gr_alert_log_buf;
64953 +char *gr_audit_log_buf;
64954 +
64955 +extern struct gr_arg *gr_usermode;
64956 +extern unsigned char *gr_system_salt;
64957 +extern unsigned char *gr_system_sum;
64958 +
64959 +void __init
64960 +grsecurity_init(void)
64961 +{
64962 + int j;
64963 + /* create the per-cpu shared pages */
64964 +
64965 +#ifdef CONFIG_X86
64966 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
64967 +#endif
64968 +
64969 + for (j = 0; j < 4; j++) {
64970 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
64971 + if (gr_shared_page[j] == NULL) {
64972 + panic("Unable to allocate grsecurity shared page");
64973 + return;
64974 + }
64975 + }
64976 +
64977 + /* allocate log buffers */
64978 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
64979 + if (!gr_alert_log_fmt) {
64980 + panic("Unable to allocate grsecurity alert log format buffer");
64981 + return;
64982 + }
64983 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
64984 + if (!gr_audit_log_fmt) {
64985 + panic("Unable to allocate grsecurity audit log format buffer");
64986 + return;
64987 + }
64988 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64989 + if (!gr_alert_log_buf) {
64990 + panic("Unable to allocate grsecurity alert log buffer");
64991 + return;
64992 + }
64993 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
64994 + if (!gr_audit_log_buf) {
64995 + panic("Unable to allocate grsecurity audit log buffer");
64996 + return;
64997 + }
64998 +
64999 + /* allocate memory for authentication structure */
65000 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65001 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65002 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65003 +
65004 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65005 + panic("Unable to allocate grsecurity authentication structure");
65006 + return;
65007 + }
65008 +
65009 +
65010 +#ifdef CONFIG_GRKERNSEC_IO
65011 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65012 + grsec_disable_privio = 1;
65013 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65014 + grsec_disable_privio = 1;
65015 +#else
65016 + grsec_disable_privio = 0;
65017 +#endif
65018 +#endif
65019 +
65020 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65021 + /* for backward compatibility, tpe_invert always defaults to on if
65022 + enabled in the kernel
65023 + */
65024 + grsec_enable_tpe_invert = 1;
65025 +#endif
65026 +
65027 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65028 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65029 + grsec_lock = 1;
65030 +#endif
65031 +
65032 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65033 + grsec_enable_audit_textrel = 1;
65034 +#endif
65035 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65036 + grsec_enable_log_rwxmaps = 1;
65037 +#endif
65038 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65039 + grsec_enable_group = 1;
65040 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65041 +#endif
65042 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65043 + grsec_enable_ptrace_readexec = 1;
65044 +#endif
65045 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65046 + grsec_enable_chdir = 1;
65047 +#endif
65048 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65049 + grsec_enable_harden_ptrace = 1;
65050 +#endif
65051 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65052 + grsec_enable_mount = 1;
65053 +#endif
65054 +#ifdef CONFIG_GRKERNSEC_LINK
65055 + grsec_enable_link = 1;
65056 +#endif
65057 +#ifdef CONFIG_GRKERNSEC_BRUTE
65058 + grsec_enable_brute = 1;
65059 +#endif
65060 +#ifdef CONFIG_GRKERNSEC_DMESG
65061 + grsec_enable_dmesg = 1;
65062 +#endif
65063 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65064 + grsec_enable_blackhole = 1;
65065 + grsec_lastack_retries = 4;
65066 +#endif
65067 +#ifdef CONFIG_GRKERNSEC_FIFO
65068 + grsec_enable_fifo = 1;
65069 +#endif
65070 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65071 + grsec_enable_execlog = 1;
65072 +#endif
65073 +#ifdef CONFIG_GRKERNSEC_SETXID
65074 + grsec_enable_setxid = 1;
65075 +#endif
65076 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65077 + grsec_enable_signal = 1;
65078 +#endif
65079 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65080 + grsec_enable_forkfail = 1;
65081 +#endif
65082 +#ifdef CONFIG_GRKERNSEC_TIME
65083 + grsec_enable_time = 1;
65084 +#endif
65085 +#ifdef CONFIG_GRKERNSEC_RESLOG
65086 + grsec_resource_logging = 1;
65087 +#endif
65088 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65089 + grsec_enable_chroot_findtask = 1;
65090 +#endif
65091 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65092 + grsec_enable_chroot_unix = 1;
65093 +#endif
65094 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65095 + grsec_enable_chroot_mount = 1;
65096 +#endif
65097 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65098 + grsec_enable_chroot_fchdir = 1;
65099 +#endif
65100 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65101 + grsec_enable_chroot_shmat = 1;
65102 +#endif
65103 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65104 + grsec_enable_audit_ptrace = 1;
65105 +#endif
65106 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65107 + grsec_enable_chroot_double = 1;
65108 +#endif
65109 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65110 + grsec_enable_chroot_pivot = 1;
65111 +#endif
65112 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65113 + grsec_enable_chroot_chdir = 1;
65114 +#endif
65115 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65116 + grsec_enable_chroot_chmod = 1;
65117 +#endif
65118 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65119 + grsec_enable_chroot_mknod = 1;
65120 +#endif
65121 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65122 + grsec_enable_chroot_nice = 1;
65123 +#endif
65124 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65125 + grsec_enable_chroot_execlog = 1;
65126 +#endif
65127 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65128 + grsec_enable_chroot_caps = 1;
65129 +#endif
65130 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65131 + grsec_enable_chroot_sysctl = 1;
65132 +#endif
65133 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65134 + grsec_enable_symlinkown = 1;
65135 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65136 +#endif
65137 +#ifdef CONFIG_GRKERNSEC_TPE
65138 + grsec_enable_tpe = 1;
65139 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65140 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65141 + grsec_enable_tpe_all = 1;
65142 +#endif
65143 +#endif
65144 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65145 + grsec_enable_socket_all = 1;
65146 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65147 +#endif
65148 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65149 + grsec_enable_socket_client = 1;
65150 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65151 +#endif
65152 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65153 + grsec_enable_socket_server = 1;
65154 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65155 +#endif
65156 +#endif
65157 +
65158 + return;
65159 +}
65160 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65161 new file mode 100644
65162 index 0000000..5e05e20
65163 --- /dev/null
65164 +++ b/grsecurity/grsec_link.c
65165 @@ -0,0 +1,58 @@
65166 +#include <linux/kernel.h>
65167 +#include <linux/sched.h>
65168 +#include <linux/fs.h>
65169 +#include <linux/file.h>
65170 +#include <linux/grinternal.h>
65171 +
65172 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65173 +{
65174 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65175 + const struct inode *link_inode = link->dentry->d_inode;
65176 +
65177 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65178 + /* ignore root-owned links, e.g. /proc/self */
65179 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65180 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65181 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65182 + return 1;
65183 + }
65184 +#endif
65185 + return 0;
65186 +}
65187 +
65188 +int
65189 +gr_handle_follow_link(const struct inode *parent,
65190 + const struct inode *inode,
65191 + const struct dentry *dentry, const struct vfsmount *mnt)
65192 +{
65193 +#ifdef CONFIG_GRKERNSEC_LINK
65194 + const struct cred *cred = current_cred();
65195 +
65196 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65197 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65198 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65199 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65200 + return -EACCES;
65201 + }
65202 +#endif
65203 + return 0;
65204 +}
65205 +
65206 +int
65207 +gr_handle_hardlink(const struct dentry *dentry,
65208 + const struct vfsmount *mnt,
65209 + struct inode *inode, const int mode, const struct filename *to)
65210 +{
65211 +#ifdef CONFIG_GRKERNSEC_LINK
65212 + const struct cred *cred = current_cred();
65213 +
65214 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65215 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65216 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65217 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65218 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65219 + return -EPERM;
65220 + }
65221 +#endif
65222 + return 0;
65223 +}
65224 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65225 new file mode 100644
65226 index 0000000..7c06085
65227 --- /dev/null
65228 +++ b/grsecurity/grsec_log.c
65229 @@ -0,0 +1,326 @@
65230 +#include <linux/kernel.h>
65231 +#include <linux/sched.h>
65232 +#include <linux/file.h>
65233 +#include <linux/tty.h>
65234 +#include <linux/fs.h>
65235 +#include <linux/grinternal.h>
65236 +
65237 +#ifdef CONFIG_TREE_PREEMPT_RCU
65238 +#define DISABLE_PREEMPT() preempt_disable()
65239 +#define ENABLE_PREEMPT() preempt_enable()
65240 +#else
65241 +#define DISABLE_PREEMPT()
65242 +#define ENABLE_PREEMPT()
65243 +#endif
65244 +
65245 +#define BEGIN_LOCKS(x) \
65246 + DISABLE_PREEMPT(); \
65247 + rcu_read_lock(); \
65248 + read_lock(&tasklist_lock); \
65249 + read_lock(&grsec_exec_file_lock); \
65250 + if (x != GR_DO_AUDIT) \
65251 + spin_lock(&grsec_alert_lock); \
65252 + else \
65253 + spin_lock(&grsec_audit_lock)
65254 +
65255 +#define END_LOCKS(x) \
65256 + if (x != GR_DO_AUDIT) \
65257 + spin_unlock(&grsec_alert_lock); \
65258 + else \
65259 + spin_unlock(&grsec_audit_lock); \
65260 + read_unlock(&grsec_exec_file_lock); \
65261 + read_unlock(&tasklist_lock); \
65262 + rcu_read_unlock(); \
65263 + ENABLE_PREEMPT(); \
65264 + if (x == GR_DONT_AUDIT) \
65265 + gr_handle_alertkill(current)
65266 +
65267 +enum {
65268 + FLOODING,
65269 + NO_FLOODING
65270 +};
65271 +
65272 +extern char *gr_alert_log_fmt;
65273 +extern char *gr_audit_log_fmt;
65274 +extern char *gr_alert_log_buf;
65275 +extern char *gr_audit_log_buf;
65276 +
65277 +static int gr_log_start(int audit)
65278 +{
65279 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65280 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65281 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65282 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65283 + unsigned long curr_secs = get_seconds();
65284 +
65285 + if (audit == GR_DO_AUDIT)
65286 + goto set_fmt;
65287 +
65288 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65289 + grsec_alert_wtime = curr_secs;
65290 + grsec_alert_fyet = 0;
65291 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65292 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65293 + grsec_alert_fyet++;
65294 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65295 + grsec_alert_wtime = curr_secs;
65296 + grsec_alert_fyet++;
65297 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65298 + return FLOODING;
65299 + }
65300 + else return FLOODING;
65301 +
65302 +set_fmt:
65303 +#endif
65304 + memset(buf, 0, PAGE_SIZE);
65305 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65306 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65307 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65308 + } else if (current->signal->curr_ip) {
65309 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65310 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65311 + } else if (gr_acl_is_enabled()) {
65312 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65313 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65314 + } else {
65315 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65316 + strcpy(buf, fmt);
65317 + }
65318 +
65319 + return NO_FLOODING;
65320 +}
65321 +
65322 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65323 + __attribute__ ((format (printf, 2, 0)));
65324 +
65325 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65326 +{
65327 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65328 + unsigned int len = strlen(buf);
65329 +
65330 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65331 +
65332 + return;
65333 +}
65334 +
65335 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65336 + __attribute__ ((format (printf, 2, 3)));
65337 +
65338 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65339 +{
65340 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65341 + unsigned int len = strlen(buf);
65342 + va_list ap;
65343 +
65344 + va_start(ap, msg);
65345 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65346 + va_end(ap);
65347 +
65348 + return;
65349 +}
65350 +
65351 +static void gr_log_end(int audit, int append_default)
65352 +{
65353 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65354 + if (append_default) {
65355 + struct task_struct *task = current;
65356 + struct task_struct *parent = task->real_parent;
65357 + const struct cred *cred = __task_cred(task);
65358 + const struct cred *pcred = __task_cred(parent);
65359 + unsigned int len = strlen(buf);
65360 +
65361 + 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));
65362 + }
65363 +
65364 + printk("%s\n", buf);
65365 +
65366 + return;
65367 +}
65368 +
65369 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65370 +{
65371 + int logtype;
65372 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65373 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65374 + void *voidptr = NULL;
65375 + int num1 = 0, num2 = 0;
65376 + unsigned long ulong1 = 0, ulong2 = 0;
65377 + struct dentry *dentry = NULL;
65378 + struct vfsmount *mnt = NULL;
65379 + struct file *file = NULL;
65380 + struct task_struct *task = NULL;
65381 + const struct cred *cred, *pcred;
65382 + va_list ap;
65383 +
65384 + BEGIN_LOCKS(audit);
65385 + logtype = gr_log_start(audit);
65386 + if (logtype == FLOODING) {
65387 + END_LOCKS(audit);
65388 + return;
65389 + }
65390 + va_start(ap, argtypes);
65391 + switch (argtypes) {
65392 + case GR_TTYSNIFF:
65393 + task = va_arg(ap, struct task_struct *);
65394 + 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));
65395 + break;
65396 + case GR_SYSCTL_HIDDEN:
65397 + str1 = va_arg(ap, char *);
65398 + gr_log_middle_varargs(audit, msg, result, str1);
65399 + break;
65400 + case GR_RBAC:
65401 + dentry = va_arg(ap, struct dentry *);
65402 + mnt = va_arg(ap, struct vfsmount *);
65403 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65404 + break;
65405 + case GR_RBAC_STR:
65406 + dentry = va_arg(ap, struct dentry *);
65407 + mnt = va_arg(ap, struct vfsmount *);
65408 + str1 = va_arg(ap, char *);
65409 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65410 + break;
65411 + case GR_STR_RBAC:
65412 + str1 = va_arg(ap, char *);
65413 + dentry = va_arg(ap, struct dentry *);
65414 + mnt = va_arg(ap, struct vfsmount *);
65415 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65416 + break;
65417 + case GR_RBAC_MODE2:
65418 + dentry = va_arg(ap, struct dentry *);
65419 + mnt = va_arg(ap, struct vfsmount *);
65420 + str1 = va_arg(ap, char *);
65421 + str2 = va_arg(ap, char *);
65422 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65423 + break;
65424 + case GR_RBAC_MODE3:
65425 + dentry = va_arg(ap, struct dentry *);
65426 + mnt = va_arg(ap, struct vfsmount *);
65427 + str1 = va_arg(ap, char *);
65428 + str2 = va_arg(ap, char *);
65429 + str3 = va_arg(ap, char *);
65430 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65431 + break;
65432 + case GR_FILENAME:
65433 + dentry = va_arg(ap, struct dentry *);
65434 + mnt = va_arg(ap, struct vfsmount *);
65435 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65436 + break;
65437 + case GR_STR_FILENAME:
65438 + str1 = va_arg(ap, char *);
65439 + dentry = va_arg(ap, struct dentry *);
65440 + mnt = va_arg(ap, struct vfsmount *);
65441 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65442 + break;
65443 + case GR_FILENAME_STR:
65444 + dentry = va_arg(ap, struct dentry *);
65445 + mnt = va_arg(ap, struct vfsmount *);
65446 + str1 = va_arg(ap, char *);
65447 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65448 + break;
65449 + case GR_FILENAME_TWO_INT:
65450 + dentry = va_arg(ap, struct dentry *);
65451 + mnt = va_arg(ap, struct vfsmount *);
65452 + num1 = va_arg(ap, int);
65453 + num2 = va_arg(ap, int);
65454 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65455 + break;
65456 + case GR_FILENAME_TWO_INT_STR:
65457 + dentry = va_arg(ap, struct dentry *);
65458 + mnt = va_arg(ap, struct vfsmount *);
65459 + num1 = va_arg(ap, int);
65460 + num2 = va_arg(ap, int);
65461 + str1 = va_arg(ap, char *);
65462 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65463 + break;
65464 + case GR_TEXTREL:
65465 + file = va_arg(ap, struct file *);
65466 + ulong1 = va_arg(ap, unsigned long);
65467 + ulong2 = va_arg(ap, unsigned long);
65468 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65469 + break;
65470 + case GR_PTRACE:
65471 + task = va_arg(ap, struct task_struct *);
65472 + 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));
65473 + break;
65474 + case GR_RESOURCE:
65475 + task = va_arg(ap, struct task_struct *);
65476 + cred = __task_cred(task);
65477 + pcred = __task_cred(task->real_parent);
65478 + ulong1 = va_arg(ap, unsigned long);
65479 + str1 = va_arg(ap, char *);
65480 + ulong2 = va_arg(ap, unsigned long);
65481 + 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));
65482 + break;
65483 + case GR_CAP:
65484 + task = va_arg(ap, struct task_struct *);
65485 + cred = __task_cred(task);
65486 + pcred = __task_cred(task->real_parent);
65487 + str1 = va_arg(ap, char *);
65488 + 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));
65489 + break;
65490 + case GR_SIG:
65491 + str1 = va_arg(ap, char *);
65492 + voidptr = va_arg(ap, void *);
65493 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65494 + break;
65495 + case GR_SIG2:
65496 + task = va_arg(ap, struct task_struct *);
65497 + cred = __task_cred(task);
65498 + pcred = __task_cred(task->real_parent);
65499 + num1 = va_arg(ap, int);
65500 + 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));
65501 + break;
65502 + case GR_CRASH1:
65503 + task = va_arg(ap, struct task_struct *);
65504 + cred = __task_cred(task);
65505 + pcred = __task_cred(task->real_parent);
65506 + ulong1 = va_arg(ap, unsigned long);
65507 + 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);
65508 + break;
65509 + case GR_CRASH2:
65510 + task = va_arg(ap, struct task_struct *);
65511 + cred = __task_cred(task);
65512 + pcred = __task_cred(task->real_parent);
65513 + ulong1 = va_arg(ap, unsigned long);
65514 + 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);
65515 + break;
65516 + case GR_RWXMAP:
65517 + file = va_arg(ap, struct file *);
65518 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65519 + break;
65520 + case GR_PSACCT:
65521 + {
65522 + unsigned int wday, cday;
65523 + __u8 whr, chr;
65524 + __u8 wmin, cmin;
65525 + __u8 wsec, csec;
65526 + char cur_tty[64] = { 0 };
65527 + char parent_tty[64] = { 0 };
65528 +
65529 + task = va_arg(ap, struct task_struct *);
65530 + wday = va_arg(ap, unsigned int);
65531 + cday = va_arg(ap, unsigned int);
65532 + whr = va_arg(ap, int);
65533 + chr = va_arg(ap, int);
65534 + wmin = va_arg(ap, int);
65535 + cmin = va_arg(ap, int);
65536 + wsec = va_arg(ap, int);
65537 + csec = va_arg(ap, int);
65538 + ulong1 = va_arg(ap, unsigned long);
65539 + cred = __task_cred(task);
65540 + pcred = __task_cred(task->real_parent);
65541 +
65542 + 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));
65543 + }
65544 + break;
65545 + default:
65546 + gr_log_middle(audit, msg, ap);
65547 + }
65548 + va_end(ap);
65549 + // these don't need DEFAULTSECARGS printed on the end
65550 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65551 + gr_log_end(audit, 0);
65552 + else
65553 + gr_log_end(audit, 1);
65554 + END_LOCKS(audit);
65555 +}
65556 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65557 new file mode 100644
65558 index 0000000..f536303
65559 --- /dev/null
65560 +++ b/grsecurity/grsec_mem.c
65561 @@ -0,0 +1,40 @@
65562 +#include <linux/kernel.h>
65563 +#include <linux/sched.h>
65564 +#include <linux/mm.h>
65565 +#include <linux/mman.h>
65566 +#include <linux/grinternal.h>
65567 +
65568 +void
65569 +gr_handle_ioperm(void)
65570 +{
65571 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65572 + return;
65573 +}
65574 +
65575 +void
65576 +gr_handle_iopl(void)
65577 +{
65578 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65579 + return;
65580 +}
65581 +
65582 +void
65583 +gr_handle_mem_readwrite(u64 from, u64 to)
65584 +{
65585 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65586 + return;
65587 +}
65588 +
65589 +void
65590 +gr_handle_vm86(void)
65591 +{
65592 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65593 + return;
65594 +}
65595 +
65596 +void
65597 +gr_log_badprocpid(const char *entry)
65598 +{
65599 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65600 + return;
65601 +}
65602 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65603 new file mode 100644
65604 index 0000000..2131422
65605 --- /dev/null
65606 +++ b/grsecurity/grsec_mount.c
65607 @@ -0,0 +1,62 @@
65608 +#include <linux/kernel.h>
65609 +#include <linux/sched.h>
65610 +#include <linux/mount.h>
65611 +#include <linux/grsecurity.h>
65612 +#include <linux/grinternal.h>
65613 +
65614 +void
65615 +gr_log_remount(const char *devname, const int retval)
65616 +{
65617 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65618 + if (grsec_enable_mount && (retval >= 0))
65619 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65620 +#endif
65621 + return;
65622 +}
65623 +
65624 +void
65625 +gr_log_unmount(const char *devname, const int retval)
65626 +{
65627 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65628 + if (grsec_enable_mount && (retval >= 0))
65629 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65630 +#endif
65631 + return;
65632 +}
65633 +
65634 +void
65635 +gr_log_mount(const char *from, const char *to, const int retval)
65636 +{
65637 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65638 + if (grsec_enable_mount && (retval >= 0))
65639 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65640 +#endif
65641 + return;
65642 +}
65643 +
65644 +int
65645 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65646 +{
65647 +#ifdef CONFIG_GRKERNSEC_ROFS
65648 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65649 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65650 + return -EPERM;
65651 + } else
65652 + return 0;
65653 +#endif
65654 + return 0;
65655 +}
65656 +
65657 +int
65658 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65659 +{
65660 +#ifdef CONFIG_GRKERNSEC_ROFS
65661 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65662 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65663 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65664 + return -EPERM;
65665 + } else
65666 + return 0;
65667 +#endif
65668 + return 0;
65669 +}
65670 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65671 new file mode 100644
65672 index 0000000..a3b12a0
65673 --- /dev/null
65674 +++ b/grsecurity/grsec_pax.c
65675 @@ -0,0 +1,36 @@
65676 +#include <linux/kernel.h>
65677 +#include <linux/sched.h>
65678 +#include <linux/mm.h>
65679 +#include <linux/file.h>
65680 +#include <linux/grinternal.h>
65681 +#include <linux/grsecurity.h>
65682 +
65683 +void
65684 +gr_log_textrel(struct vm_area_struct * vma)
65685 +{
65686 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65687 + if (grsec_enable_audit_textrel)
65688 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65689 +#endif
65690 + return;
65691 +}
65692 +
65693 +void
65694 +gr_log_rwxmmap(struct file *file)
65695 +{
65696 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65697 + if (grsec_enable_log_rwxmaps)
65698 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65699 +#endif
65700 + return;
65701 +}
65702 +
65703 +void
65704 +gr_log_rwxmprotect(struct file *file)
65705 +{
65706 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65707 + if (grsec_enable_log_rwxmaps)
65708 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65709 +#endif
65710 + return;
65711 +}
65712 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65713 new file mode 100644
65714 index 0000000..f7f29aa
65715 --- /dev/null
65716 +++ b/grsecurity/grsec_ptrace.c
65717 @@ -0,0 +1,30 @@
65718 +#include <linux/kernel.h>
65719 +#include <linux/sched.h>
65720 +#include <linux/grinternal.h>
65721 +#include <linux/security.h>
65722 +
65723 +void
65724 +gr_audit_ptrace(struct task_struct *task)
65725 +{
65726 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65727 + if (grsec_enable_audit_ptrace)
65728 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65729 +#endif
65730 + return;
65731 +}
65732 +
65733 +int
65734 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65735 +{
65736 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65737 + const struct dentry *dentry = file->f_path.dentry;
65738 + const struct vfsmount *mnt = file->f_path.mnt;
65739 +
65740 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65741 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65742 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65743 + return -EACCES;
65744 + }
65745 +#endif
65746 + return 0;
65747 +}
65748 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65749 new file mode 100644
65750 index 0000000..e09715a
65751 --- /dev/null
65752 +++ b/grsecurity/grsec_sig.c
65753 @@ -0,0 +1,222 @@
65754 +#include <linux/kernel.h>
65755 +#include <linux/sched.h>
65756 +#include <linux/delay.h>
65757 +#include <linux/grsecurity.h>
65758 +#include <linux/grinternal.h>
65759 +#include <linux/hardirq.h>
65760 +
65761 +char *signames[] = {
65762 + [SIGSEGV] = "Segmentation fault",
65763 + [SIGILL] = "Illegal instruction",
65764 + [SIGABRT] = "Abort",
65765 + [SIGBUS] = "Invalid alignment/Bus error"
65766 +};
65767 +
65768 +void
65769 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65770 +{
65771 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65772 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65773 + (sig == SIGABRT) || (sig == SIGBUS))) {
65774 + if (task_pid_nr(t) == task_pid_nr(current)) {
65775 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65776 + } else {
65777 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65778 + }
65779 + }
65780 +#endif
65781 + return;
65782 +}
65783 +
65784 +int
65785 +gr_handle_signal(const struct task_struct *p, const int sig)
65786 +{
65787 +#ifdef CONFIG_GRKERNSEC
65788 + /* ignore the 0 signal for protected task checks */
65789 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65790 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65791 + return -EPERM;
65792 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65793 + return -EPERM;
65794 + }
65795 +#endif
65796 + return 0;
65797 +}
65798 +
65799 +#ifdef CONFIG_GRKERNSEC
65800 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65801 +
65802 +int gr_fake_force_sig(int sig, struct task_struct *t)
65803 +{
65804 + unsigned long int flags;
65805 + int ret, blocked, ignored;
65806 + struct k_sigaction *action;
65807 +
65808 + spin_lock_irqsave(&t->sighand->siglock, flags);
65809 + action = &t->sighand->action[sig-1];
65810 + ignored = action->sa.sa_handler == SIG_IGN;
65811 + blocked = sigismember(&t->blocked, sig);
65812 + if (blocked || ignored) {
65813 + action->sa.sa_handler = SIG_DFL;
65814 + if (blocked) {
65815 + sigdelset(&t->blocked, sig);
65816 + recalc_sigpending_and_wake(t);
65817 + }
65818 + }
65819 + if (action->sa.sa_handler == SIG_DFL)
65820 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
65821 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
65822 +
65823 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
65824 +
65825 + return ret;
65826 +}
65827 +#endif
65828 +
65829 +#ifdef CONFIG_GRKERNSEC_BRUTE
65830 +#define GR_USER_BAN_TIME (15 * 60)
65831 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65832 +
65833 +static int __get_dumpable(unsigned long mm_flags)
65834 +{
65835 + int ret;
65836 +
65837 + ret = mm_flags & MMF_DUMPABLE_MASK;
65838 + return (ret >= 2) ? 2 : ret;
65839 +}
65840 +#endif
65841 +
65842 +void gr_handle_brute_attach(unsigned long mm_flags)
65843 +{
65844 +#ifdef CONFIG_GRKERNSEC_BRUTE
65845 + struct task_struct *p = current;
65846 + kuid_t uid = GLOBAL_ROOT_UID;
65847 + int daemon = 0;
65848 +
65849 + if (!grsec_enable_brute)
65850 + return;
65851 +
65852 + rcu_read_lock();
65853 + read_lock(&tasklist_lock);
65854 + read_lock(&grsec_exec_file_lock);
65855 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65856 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65857 + p->real_parent->brute = 1;
65858 + daemon = 1;
65859 + } else {
65860 + const struct cred *cred = __task_cred(p), *cred2;
65861 + struct task_struct *tsk, *tsk2;
65862 +
65863 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65864 + struct user_struct *user;
65865 +
65866 + uid = cred->uid;
65867 +
65868 + /* this is put upon execution past expiration */
65869 + user = find_user(uid);
65870 + if (user == NULL)
65871 + goto unlock;
65872 + user->banned = 1;
65873 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65874 + if (user->ban_expires == ~0UL)
65875 + user->ban_expires--;
65876 +
65877 + do_each_thread(tsk2, tsk) {
65878 + cred2 = __task_cred(tsk);
65879 + if (tsk != p && uid_eq(cred2->uid, uid))
65880 + gr_fake_force_sig(SIGKILL, tsk);
65881 + } while_each_thread(tsk2, tsk);
65882 + }
65883 + }
65884 +unlock:
65885 + read_unlock(&grsec_exec_file_lock);
65886 + read_unlock(&tasklist_lock);
65887 + rcu_read_unlock();
65888 +
65889 + if (gr_is_global_nonroot(uid))
65890 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65891 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65892 + else if (daemon)
65893 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
65894 +
65895 +#endif
65896 + return;
65897 +}
65898 +
65899 +void gr_handle_brute_check(void)
65900 +{
65901 +#ifdef CONFIG_GRKERNSEC_BRUTE
65902 + struct task_struct *p = current;
65903 +
65904 + if (unlikely(p->brute)) {
65905 + if (!grsec_enable_brute)
65906 + p->brute = 0;
65907 + else if (time_before(get_seconds(), p->brute_expires))
65908 + msleep(30 * 1000);
65909 + }
65910 +#endif
65911 + return;
65912 +}
65913 +
65914 +void gr_handle_kernel_exploit(void)
65915 +{
65916 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
65917 + const struct cred *cred;
65918 + struct task_struct *tsk, *tsk2;
65919 + struct user_struct *user;
65920 + kuid_t uid;
65921 +
65922 + if (in_irq() || in_serving_softirq() || in_nmi())
65923 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
65924 +
65925 + uid = current_uid();
65926 +
65927 + if (gr_is_global_root(uid))
65928 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
65929 + else {
65930 + /* kill all the processes of this user, hold a reference
65931 + to their creds struct, and prevent them from creating
65932 + another process until system reset
65933 + */
65934 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
65935 + GR_GLOBAL_UID(uid));
65936 + /* we intentionally leak this ref */
65937 + user = get_uid(current->cred->user);
65938 + if (user) {
65939 + user->banned = 1;
65940 + user->ban_expires = ~0UL;
65941 + }
65942 +
65943 + read_lock(&tasklist_lock);
65944 + do_each_thread(tsk2, tsk) {
65945 + cred = __task_cred(tsk);
65946 + if (uid_eq(cred->uid, uid))
65947 + gr_fake_force_sig(SIGKILL, tsk);
65948 + } while_each_thread(tsk2, tsk);
65949 + read_unlock(&tasklist_lock);
65950 + }
65951 +#endif
65952 +}
65953 +
65954 +int __gr_process_user_ban(struct user_struct *user)
65955 +{
65956 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65957 + if (unlikely(user->banned)) {
65958 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
65959 + user->banned = 0;
65960 + user->ban_expires = 0;
65961 + free_uid(user);
65962 + } else
65963 + return -EPERM;
65964 + }
65965 +#endif
65966 + return 0;
65967 +}
65968 +
65969 +int gr_process_user_ban(void)
65970 +{
65971 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
65972 + return __gr_process_user_ban(current->cred->user);
65973 +#endif
65974 + return 0;
65975 +}
65976 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
65977 new file mode 100644
65978 index 0000000..4030d57
65979 --- /dev/null
65980 +++ b/grsecurity/grsec_sock.c
65981 @@ -0,0 +1,244 @@
65982 +#include <linux/kernel.h>
65983 +#include <linux/module.h>
65984 +#include <linux/sched.h>
65985 +#include <linux/file.h>
65986 +#include <linux/net.h>
65987 +#include <linux/in.h>
65988 +#include <linux/ip.h>
65989 +#include <net/sock.h>
65990 +#include <net/inet_sock.h>
65991 +#include <linux/grsecurity.h>
65992 +#include <linux/grinternal.h>
65993 +#include <linux/gracl.h>
65994 +
65995 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
65996 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
65997 +
65998 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
65999 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66000 +
66001 +#ifdef CONFIG_UNIX_MODULE
66002 +EXPORT_SYMBOL(gr_acl_handle_unix);
66003 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66004 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66005 +EXPORT_SYMBOL(gr_handle_create);
66006 +#endif
66007 +
66008 +#ifdef CONFIG_GRKERNSEC
66009 +#define gr_conn_table_size 32749
66010 +struct conn_table_entry {
66011 + struct conn_table_entry *next;
66012 + struct signal_struct *sig;
66013 +};
66014 +
66015 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66016 +DEFINE_SPINLOCK(gr_conn_table_lock);
66017 +
66018 +extern const char * gr_socktype_to_name(unsigned char type);
66019 +extern const char * gr_proto_to_name(unsigned char proto);
66020 +extern const char * gr_sockfamily_to_name(unsigned char family);
66021 +
66022 +static __inline__ int
66023 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66024 +{
66025 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66026 +}
66027 +
66028 +static __inline__ int
66029 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66030 + __u16 sport, __u16 dport)
66031 +{
66032 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66033 + sig->gr_sport == sport && sig->gr_dport == dport))
66034 + return 1;
66035 + else
66036 + return 0;
66037 +}
66038 +
66039 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66040 +{
66041 + struct conn_table_entry **match;
66042 + unsigned int index;
66043 +
66044 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66045 + sig->gr_sport, sig->gr_dport,
66046 + gr_conn_table_size);
66047 +
66048 + newent->sig = sig;
66049 +
66050 + match = &gr_conn_table[index];
66051 + newent->next = *match;
66052 + *match = newent;
66053 +
66054 + return;
66055 +}
66056 +
66057 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66058 +{
66059 + struct conn_table_entry *match, *last = NULL;
66060 + unsigned int index;
66061 +
66062 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66063 + sig->gr_sport, sig->gr_dport,
66064 + gr_conn_table_size);
66065 +
66066 + match = gr_conn_table[index];
66067 + while (match && !conn_match(match->sig,
66068 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66069 + sig->gr_dport)) {
66070 + last = match;
66071 + match = match->next;
66072 + }
66073 +
66074 + if (match) {
66075 + if (last)
66076 + last->next = match->next;
66077 + else
66078 + gr_conn_table[index] = NULL;
66079 + kfree(match);
66080 + }
66081 +
66082 + return;
66083 +}
66084 +
66085 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66086 + __u16 sport, __u16 dport)
66087 +{
66088 + struct conn_table_entry *match;
66089 + unsigned int index;
66090 +
66091 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
66092 +
66093 + match = gr_conn_table[index];
66094 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
66095 + match = match->next;
66096 +
66097 + if (match)
66098 + return match->sig;
66099 + else
66100 + return NULL;
66101 +}
66102 +
66103 +#endif
66104 +
66105 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
66106 +{
66107 +#ifdef CONFIG_GRKERNSEC
66108 + struct signal_struct *sig = task->signal;
66109 + struct conn_table_entry *newent;
66110 +
66111 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
66112 + if (newent == NULL)
66113 + return;
66114 + /* no bh lock needed since we are called with bh disabled */
66115 + spin_lock(&gr_conn_table_lock);
66116 + gr_del_task_from_ip_table_nolock(sig);
66117 + sig->gr_saddr = inet->inet_rcv_saddr;
66118 + sig->gr_daddr = inet->inet_daddr;
66119 + sig->gr_sport = inet->inet_sport;
66120 + sig->gr_dport = inet->inet_dport;
66121 + gr_add_to_task_ip_table_nolock(sig, newent);
66122 + spin_unlock(&gr_conn_table_lock);
66123 +#endif
66124 + return;
66125 +}
66126 +
66127 +void gr_del_task_from_ip_table(struct task_struct *task)
66128 +{
66129 +#ifdef CONFIG_GRKERNSEC
66130 + spin_lock_bh(&gr_conn_table_lock);
66131 + gr_del_task_from_ip_table_nolock(task->signal);
66132 + spin_unlock_bh(&gr_conn_table_lock);
66133 +#endif
66134 + return;
66135 +}
66136 +
66137 +void
66138 +gr_attach_curr_ip(const struct sock *sk)
66139 +{
66140 +#ifdef CONFIG_GRKERNSEC
66141 + struct signal_struct *p, *set;
66142 + const struct inet_sock *inet = inet_sk(sk);
66143 +
66144 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66145 + return;
66146 +
66147 + set = current->signal;
66148 +
66149 + spin_lock_bh(&gr_conn_table_lock);
66150 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66151 + inet->inet_dport, inet->inet_sport);
66152 + if (unlikely(p != NULL)) {
66153 + set->curr_ip = p->curr_ip;
66154 + set->used_accept = 1;
66155 + gr_del_task_from_ip_table_nolock(p);
66156 + spin_unlock_bh(&gr_conn_table_lock);
66157 + return;
66158 + }
66159 + spin_unlock_bh(&gr_conn_table_lock);
66160 +
66161 + set->curr_ip = inet->inet_daddr;
66162 + set->used_accept = 1;
66163 +#endif
66164 + return;
66165 +}
66166 +
66167 +int
66168 +gr_handle_sock_all(const int family, const int type, const int protocol)
66169 +{
66170 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66171 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66172 + (family != AF_UNIX)) {
66173 + if (family == AF_INET)
66174 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66175 + else
66176 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66177 + return -EACCES;
66178 + }
66179 +#endif
66180 + return 0;
66181 +}
66182 +
66183 +int
66184 +gr_handle_sock_server(const struct sockaddr *sck)
66185 +{
66186 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66187 + if (grsec_enable_socket_server &&
66188 + in_group_p(grsec_socket_server_gid) &&
66189 + sck && (sck->sa_family != AF_UNIX) &&
66190 + (sck->sa_family != AF_LOCAL)) {
66191 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66192 + return -EACCES;
66193 + }
66194 +#endif
66195 + return 0;
66196 +}
66197 +
66198 +int
66199 +gr_handle_sock_server_other(const struct sock *sck)
66200 +{
66201 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66202 + if (grsec_enable_socket_server &&
66203 + in_group_p(grsec_socket_server_gid) &&
66204 + sck && (sck->sk_family != AF_UNIX) &&
66205 + (sck->sk_family != AF_LOCAL)) {
66206 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66207 + return -EACCES;
66208 + }
66209 +#endif
66210 + return 0;
66211 +}
66212 +
66213 +int
66214 +gr_handle_sock_client(const struct sockaddr *sck)
66215 +{
66216 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66217 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66218 + sck && (sck->sa_family != AF_UNIX) &&
66219 + (sck->sa_family != AF_LOCAL)) {
66220 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66221 + return -EACCES;
66222 + }
66223 +#endif
66224 + return 0;
66225 +}
66226 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66227 new file mode 100644
66228 index 0000000..f55ef0f
66229 --- /dev/null
66230 +++ b/grsecurity/grsec_sysctl.c
66231 @@ -0,0 +1,469 @@
66232 +#include <linux/kernel.h>
66233 +#include <linux/sched.h>
66234 +#include <linux/sysctl.h>
66235 +#include <linux/grsecurity.h>
66236 +#include <linux/grinternal.h>
66237 +
66238 +int
66239 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66240 +{
66241 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66242 + if (dirname == NULL || name == NULL)
66243 + return 0;
66244 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66245 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66246 + return -EACCES;
66247 + }
66248 +#endif
66249 + return 0;
66250 +}
66251 +
66252 +#ifdef CONFIG_GRKERNSEC_ROFS
66253 +static int __maybe_unused one = 1;
66254 +#endif
66255 +
66256 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66257 +struct ctl_table grsecurity_table[] = {
66258 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66259 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66260 +#ifdef CONFIG_GRKERNSEC_IO
66261 + {
66262 + .procname = "disable_priv_io",
66263 + .data = &grsec_disable_privio,
66264 + .maxlen = sizeof(int),
66265 + .mode = 0600,
66266 + .proc_handler = &proc_dointvec,
66267 + },
66268 +#endif
66269 +#endif
66270 +#ifdef CONFIG_GRKERNSEC_LINK
66271 + {
66272 + .procname = "linking_restrictions",
66273 + .data = &grsec_enable_link,
66274 + .maxlen = sizeof(int),
66275 + .mode = 0600,
66276 + .proc_handler = &proc_dointvec,
66277 + },
66278 +#endif
66279 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66280 + {
66281 + .procname = "enforce_symlinksifowner",
66282 + .data = &grsec_enable_symlinkown,
66283 + .maxlen = sizeof(int),
66284 + .mode = 0600,
66285 + .proc_handler = &proc_dointvec,
66286 + },
66287 + {
66288 + .procname = "symlinkown_gid",
66289 + .data = &grsec_symlinkown_gid,
66290 + .maxlen = sizeof(int),
66291 + .mode = 0600,
66292 + .proc_handler = &proc_dointvec,
66293 + },
66294 +#endif
66295 +#ifdef CONFIG_GRKERNSEC_BRUTE
66296 + {
66297 + .procname = "deter_bruteforce",
66298 + .data = &grsec_enable_brute,
66299 + .maxlen = sizeof(int),
66300 + .mode = 0600,
66301 + .proc_handler = &proc_dointvec,
66302 + },
66303 +#endif
66304 +#ifdef CONFIG_GRKERNSEC_FIFO
66305 + {
66306 + .procname = "fifo_restrictions",
66307 + .data = &grsec_enable_fifo,
66308 + .maxlen = sizeof(int),
66309 + .mode = 0600,
66310 + .proc_handler = &proc_dointvec,
66311 + },
66312 +#endif
66313 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66314 + {
66315 + .procname = "ptrace_readexec",
66316 + .data = &grsec_enable_ptrace_readexec,
66317 + .maxlen = sizeof(int),
66318 + .mode = 0600,
66319 + .proc_handler = &proc_dointvec,
66320 + },
66321 +#endif
66322 +#ifdef CONFIG_GRKERNSEC_SETXID
66323 + {
66324 + .procname = "consistent_setxid",
66325 + .data = &grsec_enable_setxid,
66326 + .maxlen = sizeof(int),
66327 + .mode = 0600,
66328 + .proc_handler = &proc_dointvec,
66329 + },
66330 +#endif
66331 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
66332 + {
66333 + .procname = "ip_blackhole",
66334 + .data = &grsec_enable_blackhole,
66335 + .maxlen = sizeof(int),
66336 + .mode = 0600,
66337 + .proc_handler = &proc_dointvec,
66338 + },
66339 + {
66340 + .procname = "lastack_retries",
66341 + .data = &grsec_lastack_retries,
66342 + .maxlen = sizeof(int),
66343 + .mode = 0600,
66344 + .proc_handler = &proc_dointvec,
66345 + },
66346 +#endif
66347 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66348 + {
66349 + .procname = "exec_logging",
66350 + .data = &grsec_enable_execlog,
66351 + .maxlen = sizeof(int),
66352 + .mode = 0600,
66353 + .proc_handler = &proc_dointvec,
66354 + },
66355 +#endif
66356 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66357 + {
66358 + .procname = "rwxmap_logging",
66359 + .data = &grsec_enable_log_rwxmaps,
66360 + .maxlen = sizeof(int),
66361 + .mode = 0600,
66362 + .proc_handler = &proc_dointvec,
66363 + },
66364 +#endif
66365 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66366 + {
66367 + .procname = "signal_logging",
66368 + .data = &grsec_enable_signal,
66369 + .maxlen = sizeof(int),
66370 + .mode = 0600,
66371 + .proc_handler = &proc_dointvec,
66372 + },
66373 +#endif
66374 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66375 + {
66376 + .procname = "forkfail_logging",
66377 + .data = &grsec_enable_forkfail,
66378 + .maxlen = sizeof(int),
66379 + .mode = 0600,
66380 + .proc_handler = &proc_dointvec,
66381 + },
66382 +#endif
66383 +#ifdef CONFIG_GRKERNSEC_TIME
66384 + {
66385 + .procname = "timechange_logging",
66386 + .data = &grsec_enable_time,
66387 + .maxlen = sizeof(int),
66388 + .mode = 0600,
66389 + .proc_handler = &proc_dointvec,
66390 + },
66391 +#endif
66392 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66393 + {
66394 + .procname = "chroot_deny_shmat",
66395 + .data = &grsec_enable_chroot_shmat,
66396 + .maxlen = sizeof(int),
66397 + .mode = 0600,
66398 + .proc_handler = &proc_dointvec,
66399 + },
66400 +#endif
66401 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66402 + {
66403 + .procname = "chroot_deny_unix",
66404 + .data = &grsec_enable_chroot_unix,
66405 + .maxlen = sizeof(int),
66406 + .mode = 0600,
66407 + .proc_handler = &proc_dointvec,
66408 + },
66409 +#endif
66410 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66411 + {
66412 + .procname = "chroot_deny_mount",
66413 + .data = &grsec_enable_chroot_mount,
66414 + .maxlen = sizeof(int),
66415 + .mode = 0600,
66416 + .proc_handler = &proc_dointvec,
66417 + },
66418 +#endif
66419 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66420 + {
66421 + .procname = "chroot_deny_fchdir",
66422 + .data = &grsec_enable_chroot_fchdir,
66423 + .maxlen = sizeof(int),
66424 + .mode = 0600,
66425 + .proc_handler = &proc_dointvec,
66426 + },
66427 +#endif
66428 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66429 + {
66430 + .procname = "chroot_deny_chroot",
66431 + .data = &grsec_enable_chroot_double,
66432 + .maxlen = sizeof(int),
66433 + .mode = 0600,
66434 + .proc_handler = &proc_dointvec,
66435 + },
66436 +#endif
66437 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66438 + {
66439 + .procname = "chroot_deny_pivot",
66440 + .data = &grsec_enable_chroot_pivot,
66441 + .maxlen = sizeof(int),
66442 + .mode = 0600,
66443 + .proc_handler = &proc_dointvec,
66444 + },
66445 +#endif
66446 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66447 + {
66448 + .procname = "chroot_enforce_chdir",
66449 + .data = &grsec_enable_chroot_chdir,
66450 + .maxlen = sizeof(int),
66451 + .mode = 0600,
66452 + .proc_handler = &proc_dointvec,
66453 + },
66454 +#endif
66455 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66456 + {
66457 + .procname = "chroot_deny_chmod",
66458 + .data = &grsec_enable_chroot_chmod,
66459 + .maxlen = sizeof(int),
66460 + .mode = 0600,
66461 + .proc_handler = &proc_dointvec,
66462 + },
66463 +#endif
66464 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66465 + {
66466 + .procname = "chroot_deny_mknod",
66467 + .data = &grsec_enable_chroot_mknod,
66468 + .maxlen = sizeof(int),
66469 + .mode = 0600,
66470 + .proc_handler = &proc_dointvec,
66471 + },
66472 +#endif
66473 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66474 + {
66475 + .procname = "chroot_restrict_nice",
66476 + .data = &grsec_enable_chroot_nice,
66477 + .maxlen = sizeof(int),
66478 + .mode = 0600,
66479 + .proc_handler = &proc_dointvec,
66480 + },
66481 +#endif
66482 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66483 + {
66484 + .procname = "chroot_execlog",
66485 + .data = &grsec_enable_chroot_execlog,
66486 + .maxlen = sizeof(int),
66487 + .mode = 0600,
66488 + .proc_handler = &proc_dointvec,
66489 + },
66490 +#endif
66491 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66492 + {
66493 + .procname = "chroot_caps",
66494 + .data = &grsec_enable_chroot_caps,
66495 + .maxlen = sizeof(int),
66496 + .mode = 0600,
66497 + .proc_handler = &proc_dointvec,
66498 + },
66499 +#endif
66500 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66501 + {
66502 + .procname = "chroot_deny_sysctl",
66503 + .data = &grsec_enable_chroot_sysctl,
66504 + .maxlen = sizeof(int),
66505 + .mode = 0600,
66506 + .proc_handler = &proc_dointvec,
66507 + },
66508 +#endif
66509 +#ifdef CONFIG_GRKERNSEC_TPE
66510 + {
66511 + .procname = "tpe",
66512 + .data = &grsec_enable_tpe,
66513 + .maxlen = sizeof(int),
66514 + .mode = 0600,
66515 + .proc_handler = &proc_dointvec,
66516 + },
66517 + {
66518 + .procname = "tpe_gid",
66519 + .data = &grsec_tpe_gid,
66520 + .maxlen = sizeof(int),
66521 + .mode = 0600,
66522 + .proc_handler = &proc_dointvec,
66523 + },
66524 +#endif
66525 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66526 + {
66527 + .procname = "tpe_invert",
66528 + .data = &grsec_enable_tpe_invert,
66529 + .maxlen = sizeof(int),
66530 + .mode = 0600,
66531 + .proc_handler = &proc_dointvec,
66532 + },
66533 +#endif
66534 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66535 + {
66536 + .procname = "tpe_restrict_all",
66537 + .data = &grsec_enable_tpe_all,
66538 + .maxlen = sizeof(int),
66539 + .mode = 0600,
66540 + .proc_handler = &proc_dointvec,
66541 + },
66542 +#endif
66543 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66544 + {
66545 + .procname = "socket_all",
66546 + .data = &grsec_enable_socket_all,
66547 + .maxlen = sizeof(int),
66548 + .mode = 0600,
66549 + .proc_handler = &proc_dointvec,
66550 + },
66551 + {
66552 + .procname = "socket_all_gid",
66553 + .data = &grsec_socket_all_gid,
66554 + .maxlen = sizeof(int),
66555 + .mode = 0600,
66556 + .proc_handler = &proc_dointvec,
66557 + },
66558 +#endif
66559 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66560 + {
66561 + .procname = "socket_client",
66562 + .data = &grsec_enable_socket_client,
66563 + .maxlen = sizeof(int),
66564 + .mode = 0600,
66565 + .proc_handler = &proc_dointvec,
66566 + },
66567 + {
66568 + .procname = "socket_client_gid",
66569 + .data = &grsec_socket_client_gid,
66570 + .maxlen = sizeof(int),
66571 + .mode = 0600,
66572 + .proc_handler = &proc_dointvec,
66573 + },
66574 +#endif
66575 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66576 + {
66577 + .procname = "socket_server",
66578 + .data = &grsec_enable_socket_server,
66579 + .maxlen = sizeof(int),
66580 + .mode = 0600,
66581 + .proc_handler = &proc_dointvec,
66582 + },
66583 + {
66584 + .procname = "socket_server_gid",
66585 + .data = &grsec_socket_server_gid,
66586 + .maxlen = sizeof(int),
66587 + .mode = 0600,
66588 + .proc_handler = &proc_dointvec,
66589 + },
66590 +#endif
66591 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66592 + {
66593 + .procname = "audit_group",
66594 + .data = &grsec_enable_group,
66595 + .maxlen = sizeof(int),
66596 + .mode = 0600,
66597 + .proc_handler = &proc_dointvec,
66598 + },
66599 + {
66600 + .procname = "audit_gid",
66601 + .data = &grsec_audit_gid,
66602 + .maxlen = sizeof(int),
66603 + .mode = 0600,
66604 + .proc_handler = &proc_dointvec,
66605 + },
66606 +#endif
66607 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66608 + {
66609 + .procname = "audit_chdir",
66610 + .data = &grsec_enable_chdir,
66611 + .maxlen = sizeof(int),
66612 + .mode = 0600,
66613 + .proc_handler = &proc_dointvec,
66614 + },
66615 +#endif
66616 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66617 + {
66618 + .procname = "audit_mount",
66619 + .data = &grsec_enable_mount,
66620 + .maxlen = sizeof(int),
66621 + .mode = 0600,
66622 + .proc_handler = &proc_dointvec,
66623 + },
66624 +#endif
66625 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66626 + {
66627 + .procname = "audit_textrel",
66628 + .data = &grsec_enable_audit_textrel,
66629 + .maxlen = sizeof(int),
66630 + .mode = 0600,
66631 + .proc_handler = &proc_dointvec,
66632 + },
66633 +#endif
66634 +#ifdef CONFIG_GRKERNSEC_DMESG
66635 + {
66636 + .procname = "dmesg",
66637 + .data = &grsec_enable_dmesg,
66638 + .maxlen = sizeof(int),
66639 + .mode = 0600,
66640 + .proc_handler = &proc_dointvec,
66641 + },
66642 +#endif
66643 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66644 + {
66645 + .procname = "chroot_findtask",
66646 + .data = &grsec_enable_chroot_findtask,
66647 + .maxlen = sizeof(int),
66648 + .mode = 0600,
66649 + .proc_handler = &proc_dointvec,
66650 + },
66651 +#endif
66652 +#ifdef CONFIG_GRKERNSEC_RESLOG
66653 + {
66654 + .procname = "resource_logging",
66655 + .data = &grsec_resource_logging,
66656 + .maxlen = sizeof(int),
66657 + .mode = 0600,
66658 + .proc_handler = &proc_dointvec,
66659 + },
66660 +#endif
66661 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66662 + {
66663 + .procname = "audit_ptrace",
66664 + .data = &grsec_enable_audit_ptrace,
66665 + .maxlen = sizeof(int),
66666 + .mode = 0600,
66667 + .proc_handler = &proc_dointvec,
66668 + },
66669 +#endif
66670 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66671 + {
66672 + .procname = "harden_ptrace",
66673 + .data = &grsec_enable_harden_ptrace,
66674 + .maxlen = sizeof(int),
66675 + .mode = 0600,
66676 + .proc_handler = &proc_dointvec,
66677 + },
66678 +#endif
66679 + {
66680 + .procname = "grsec_lock",
66681 + .data = &grsec_lock,
66682 + .maxlen = sizeof(int),
66683 + .mode = 0600,
66684 + .proc_handler = &proc_dointvec,
66685 + },
66686 +#endif
66687 +#ifdef CONFIG_GRKERNSEC_ROFS
66688 + {
66689 + .procname = "romount_protect",
66690 + .data = &grsec_enable_rofs,
66691 + .maxlen = sizeof(int),
66692 + .mode = 0600,
66693 + .proc_handler = &proc_dointvec_minmax,
66694 + .extra1 = &one,
66695 + .extra2 = &one,
66696 + },
66697 +#endif
66698 + { }
66699 +};
66700 +#endif
66701 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66702 new file mode 100644
66703 index 0000000..0dc13c3
66704 --- /dev/null
66705 +++ b/grsecurity/grsec_time.c
66706 @@ -0,0 +1,16 @@
66707 +#include <linux/kernel.h>
66708 +#include <linux/sched.h>
66709 +#include <linux/grinternal.h>
66710 +#include <linux/module.h>
66711 +
66712 +void
66713 +gr_log_timechange(void)
66714 +{
66715 +#ifdef CONFIG_GRKERNSEC_TIME
66716 + if (grsec_enable_time)
66717 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66718 +#endif
66719 + return;
66720 +}
66721 +
66722 +EXPORT_SYMBOL(gr_log_timechange);
66723 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66724 new file mode 100644
66725 index 0000000..ee57dcf
66726 --- /dev/null
66727 +++ b/grsecurity/grsec_tpe.c
66728 @@ -0,0 +1,73 @@
66729 +#include <linux/kernel.h>
66730 +#include <linux/sched.h>
66731 +#include <linux/file.h>
66732 +#include <linux/fs.h>
66733 +#include <linux/grinternal.h>
66734 +
66735 +extern int gr_acl_tpe_check(void);
66736 +
66737 +int
66738 +gr_tpe_allow(const struct file *file)
66739 +{
66740 +#ifdef CONFIG_GRKERNSEC
66741 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66742 + const struct cred *cred = current_cred();
66743 + char *msg = NULL;
66744 + char *msg2 = NULL;
66745 +
66746 + // never restrict root
66747 + if (gr_is_global_root(cred->uid))
66748 + return 1;
66749 +
66750 + if (grsec_enable_tpe) {
66751 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66752 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66753 + msg = "not being in trusted group";
66754 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66755 + msg = "being in untrusted group";
66756 +#else
66757 + if (in_group_p(grsec_tpe_gid))
66758 + msg = "being in untrusted group";
66759 +#endif
66760 + }
66761 + if (!msg && gr_acl_tpe_check())
66762 + msg = "being in untrusted role";
66763 +
66764 + // not in any affected group/role
66765 + if (!msg)
66766 + goto next_check;
66767 +
66768 + if (gr_is_global_nonroot(inode->i_uid))
66769 + msg2 = "file in non-root-owned directory";
66770 + else if (inode->i_mode & S_IWOTH)
66771 + msg2 = "file in world-writable directory";
66772 + else if (inode->i_mode & S_IWGRP)
66773 + msg2 = "file in group-writable directory";
66774 +
66775 + if (msg && msg2) {
66776 + char fullmsg[70] = {0};
66777 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66778 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66779 + return 0;
66780 + }
66781 + msg = NULL;
66782 +next_check:
66783 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66784 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66785 + return 1;
66786 +
66787 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66788 + msg = "directory not owned by user";
66789 + else if (inode->i_mode & S_IWOTH)
66790 + msg = "file in world-writable directory";
66791 + else if (inode->i_mode & S_IWGRP)
66792 + msg = "file in group-writable directory";
66793 +
66794 + if (msg) {
66795 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66796 + return 0;
66797 + }
66798 +#endif
66799 +#endif
66800 + return 1;
66801 +}
66802 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66803 new file mode 100644
66804 index 0000000..9f7b1ac
66805 --- /dev/null
66806 +++ b/grsecurity/grsum.c
66807 @@ -0,0 +1,61 @@
66808 +#include <linux/err.h>
66809 +#include <linux/kernel.h>
66810 +#include <linux/sched.h>
66811 +#include <linux/mm.h>
66812 +#include <linux/scatterlist.h>
66813 +#include <linux/crypto.h>
66814 +#include <linux/gracl.h>
66815 +
66816 +
66817 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66818 +#error "crypto and sha256 must be built into the kernel"
66819 +#endif
66820 +
66821 +int
66822 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
66823 +{
66824 + char *p;
66825 + struct crypto_hash *tfm;
66826 + struct hash_desc desc;
66827 + struct scatterlist sg;
66828 + unsigned char temp_sum[GR_SHA_LEN];
66829 + volatile int retval = 0;
66830 + volatile int dummy = 0;
66831 + unsigned int i;
66832 +
66833 + sg_init_table(&sg, 1);
66834 +
66835 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66836 + if (IS_ERR(tfm)) {
66837 + /* should never happen, since sha256 should be built in */
66838 + return 1;
66839 + }
66840 +
66841 + desc.tfm = tfm;
66842 + desc.flags = 0;
66843 +
66844 + crypto_hash_init(&desc);
66845 +
66846 + p = salt;
66847 + sg_set_buf(&sg, p, GR_SALT_LEN);
66848 + crypto_hash_update(&desc, &sg, sg.length);
66849 +
66850 + p = entry->pw;
66851 + sg_set_buf(&sg, p, strlen(p));
66852 +
66853 + crypto_hash_update(&desc, &sg, sg.length);
66854 +
66855 + crypto_hash_final(&desc, temp_sum);
66856 +
66857 + memset(entry->pw, 0, GR_PW_LEN);
66858 +
66859 + for (i = 0; i < GR_SHA_LEN; i++)
66860 + if (sum[i] != temp_sum[i])
66861 + retval = 1;
66862 + else
66863 + dummy = 1; // waste a cycle
66864 +
66865 + crypto_free_hash(tfm);
66866 +
66867 + return retval;
66868 +}
66869 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66870 index 77ff547..181834f 100644
66871 --- a/include/asm-generic/4level-fixup.h
66872 +++ b/include/asm-generic/4level-fixup.h
66873 @@ -13,8 +13,10 @@
66874 #define pmd_alloc(mm, pud, address) \
66875 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66876 NULL: pmd_offset(pud, address))
66877 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66878
66879 #define pud_alloc(mm, pgd, address) (pgd)
66880 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66881 #define pud_offset(pgd, start) (pgd)
66882 #define pud_none(pud) 0
66883 #define pud_bad(pud) 0
66884 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66885 index b7babf0..04ad282 100644
66886 --- a/include/asm-generic/atomic-long.h
66887 +++ b/include/asm-generic/atomic-long.h
66888 @@ -22,6 +22,12 @@
66889
66890 typedef atomic64_t atomic_long_t;
66891
66892 +#ifdef CONFIG_PAX_REFCOUNT
66893 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
66894 +#else
66895 +typedef atomic64_t atomic_long_unchecked_t;
66896 +#endif
66897 +
66898 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
66899
66900 static inline long atomic_long_read(atomic_long_t *l)
66901 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66902 return (long)atomic64_read(v);
66903 }
66904
66905 +#ifdef CONFIG_PAX_REFCOUNT
66906 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66907 +{
66908 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66909 +
66910 + return (long)atomic64_read_unchecked(v);
66911 +}
66912 +#endif
66913 +
66914 static inline void atomic_long_set(atomic_long_t *l, long i)
66915 {
66916 atomic64_t *v = (atomic64_t *)l;
66917 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66918 atomic64_set(v, i);
66919 }
66920
66921 +#ifdef CONFIG_PAX_REFCOUNT
66922 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66923 +{
66924 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66925 +
66926 + atomic64_set_unchecked(v, i);
66927 +}
66928 +#endif
66929 +
66930 static inline void atomic_long_inc(atomic_long_t *l)
66931 {
66932 atomic64_t *v = (atomic64_t *)l;
66933 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
66934 atomic64_inc(v);
66935 }
66936
66937 +#ifdef CONFIG_PAX_REFCOUNT
66938 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
66939 +{
66940 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66941 +
66942 + atomic64_inc_unchecked(v);
66943 +}
66944 +#endif
66945 +
66946 static inline void atomic_long_dec(atomic_long_t *l)
66947 {
66948 atomic64_t *v = (atomic64_t *)l;
66949 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
66950 atomic64_dec(v);
66951 }
66952
66953 +#ifdef CONFIG_PAX_REFCOUNT
66954 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
66955 +{
66956 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66957 +
66958 + atomic64_dec_unchecked(v);
66959 +}
66960 +#endif
66961 +
66962 static inline void atomic_long_add(long i, atomic_long_t *l)
66963 {
66964 atomic64_t *v = (atomic64_t *)l;
66965 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
66966 atomic64_add(i, v);
66967 }
66968
66969 +#ifdef CONFIG_PAX_REFCOUNT
66970 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
66971 +{
66972 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66973 +
66974 + atomic64_add_unchecked(i, v);
66975 +}
66976 +#endif
66977 +
66978 static inline void atomic_long_sub(long i, atomic_long_t *l)
66979 {
66980 atomic64_t *v = (atomic64_t *)l;
66981 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
66982 atomic64_sub(i, v);
66983 }
66984
66985 +#ifdef CONFIG_PAX_REFCOUNT
66986 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
66987 +{
66988 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66989 +
66990 + atomic64_sub_unchecked(i, v);
66991 +}
66992 +#endif
66993 +
66994 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
66995 {
66996 atomic64_t *v = (atomic64_t *)l;
66997 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
66998 return (long)atomic64_add_return(i, v);
66999 }
67000
67001 +#ifdef CONFIG_PAX_REFCOUNT
67002 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67003 +{
67004 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67005 +
67006 + return (long)atomic64_add_return_unchecked(i, v);
67007 +}
67008 +#endif
67009 +
67010 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67011 {
67012 atomic64_t *v = (atomic64_t *)l;
67013 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67014 return (long)atomic64_inc_return(v);
67015 }
67016
67017 +#ifdef CONFIG_PAX_REFCOUNT
67018 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67019 +{
67020 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67021 +
67022 + return (long)atomic64_inc_return_unchecked(v);
67023 +}
67024 +#endif
67025 +
67026 static inline long atomic_long_dec_return(atomic_long_t *l)
67027 {
67028 atomic64_t *v = (atomic64_t *)l;
67029 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67030
67031 typedef atomic_t atomic_long_t;
67032
67033 +#ifdef CONFIG_PAX_REFCOUNT
67034 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67035 +#else
67036 +typedef atomic_t atomic_long_unchecked_t;
67037 +#endif
67038 +
67039 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67040 static inline long atomic_long_read(atomic_long_t *l)
67041 {
67042 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67043 return (long)atomic_read(v);
67044 }
67045
67046 +#ifdef CONFIG_PAX_REFCOUNT
67047 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67048 +{
67049 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67050 +
67051 + return (long)atomic_read_unchecked(v);
67052 +}
67053 +#endif
67054 +
67055 static inline void atomic_long_set(atomic_long_t *l, long i)
67056 {
67057 atomic_t *v = (atomic_t *)l;
67058 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67059 atomic_set(v, i);
67060 }
67061
67062 +#ifdef CONFIG_PAX_REFCOUNT
67063 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67064 +{
67065 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67066 +
67067 + atomic_set_unchecked(v, i);
67068 +}
67069 +#endif
67070 +
67071 static inline void atomic_long_inc(atomic_long_t *l)
67072 {
67073 atomic_t *v = (atomic_t *)l;
67074 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67075 atomic_inc(v);
67076 }
67077
67078 +#ifdef CONFIG_PAX_REFCOUNT
67079 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67080 +{
67081 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67082 +
67083 + atomic_inc_unchecked(v);
67084 +}
67085 +#endif
67086 +
67087 static inline void atomic_long_dec(atomic_long_t *l)
67088 {
67089 atomic_t *v = (atomic_t *)l;
67090 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67091 atomic_dec(v);
67092 }
67093
67094 +#ifdef CONFIG_PAX_REFCOUNT
67095 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67096 +{
67097 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67098 +
67099 + atomic_dec_unchecked(v);
67100 +}
67101 +#endif
67102 +
67103 static inline void atomic_long_add(long i, atomic_long_t *l)
67104 {
67105 atomic_t *v = (atomic_t *)l;
67106 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67107 atomic_add(i, v);
67108 }
67109
67110 +#ifdef CONFIG_PAX_REFCOUNT
67111 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67112 +{
67113 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67114 +
67115 + atomic_add_unchecked(i, v);
67116 +}
67117 +#endif
67118 +
67119 static inline void atomic_long_sub(long i, atomic_long_t *l)
67120 {
67121 atomic_t *v = (atomic_t *)l;
67122 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67123 atomic_sub(i, v);
67124 }
67125
67126 +#ifdef CONFIG_PAX_REFCOUNT
67127 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67128 +{
67129 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67130 +
67131 + atomic_sub_unchecked(i, v);
67132 +}
67133 +#endif
67134 +
67135 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67136 {
67137 atomic_t *v = (atomic_t *)l;
67138 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67139 return (long)atomic_add_return(i, v);
67140 }
67141
67142 +#ifdef CONFIG_PAX_REFCOUNT
67143 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67144 +{
67145 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67146 +
67147 + return (long)atomic_add_return_unchecked(i, v);
67148 +}
67149 +
67150 +#endif
67151 +
67152 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67153 {
67154 atomic_t *v = (atomic_t *)l;
67155 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67156 return (long)atomic_inc_return(v);
67157 }
67158
67159 +#ifdef CONFIG_PAX_REFCOUNT
67160 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67161 +{
67162 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67163 +
67164 + return (long)atomic_inc_return_unchecked(v);
67165 +}
67166 +#endif
67167 +
67168 static inline long atomic_long_dec_return(atomic_long_t *l)
67169 {
67170 atomic_t *v = (atomic_t *)l;
67171 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67172
67173 #endif /* BITS_PER_LONG == 64 */
67174
67175 +#ifdef CONFIG_PAX_REFCOUNT
67176 +static inline void pax_refcount_needs_these_functions(void)
67177 +{
67178 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67179 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67180 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67181 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67182 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67183 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67184 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67185 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67186 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67187 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67188 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67189 +#ifdef CONFIG_X86
67190 + atomic_clear_mask_unchecked(0, NULL);
67191 + atomic_set_mask_unchecked(0, NULL);
67192 +#endif
67193 +
67194 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67195 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67196 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67197 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67198 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67199 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67200 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67201 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67202 +}
67203 +#else
67204 +#define atomic_read_unchecked(v) atomic_read(v)
67205 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67206 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67207 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67208 +#define atomic_inc_unchecked(v) atomic_inc(v)
67209 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67210 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67211 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67212 +#define atomic_dec_unchecked(v) atomic_dec(v)
67213 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67214 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67215 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67216 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67217 +
67218 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67219 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67220 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67221 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67222 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67223 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67224 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67225 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67226 +#endif
67227 +
67228 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67229 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67230 index 1ced641..c896ee8 100644
67231 --- a/include/asm-generic/atomic.h
67232 +++ b/include/asm-generic/atomic.h
67233 @@ -159,7 +159,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67234 * Atomically clears the bits set in @mask from @v
67235 */
67236 #ifndef atomic_clear_mask
67237 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67238 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67239 {
67240 unsigned long flags;
67241
67242 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67243 index b18ce4f..2ee2843 100644
67244 --- a/include/asm-generic/atomic64.h
67245 +++ b/include/asm-generic/atomic64.h
67246 @@ -16,6 +16,8 @@ typedef struct {
67247 long long counter;
67248 } atomic64_t;
67249
67250 +typedef atomic64_t atomic64_unchecked_t;
67251 +
67252 #define ATOMIC64_INIT(i) { (i) }
67253
67254 extern long long atomic64_read(const atomic64_t *v);
67255 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67256 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67257 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67258
67259 +#define atomic64_read_unchecked(v) atomic64_read(v)
67260 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67261 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67262 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67263 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67264 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67265 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67266 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67267 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67268 +
67269 #endif /* _ASM_GENERIC_ATOMIC64_H */
67270 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67271 index 1bfcfe5..e04c5c9 100644
67272 --- a/include/asm-generic/cache.h
67273 +++ b/include/asm-generic/cache.h
67274 @@ -6,7 +6,7 @@
67275 * cache lines need to provide their own cache.h.
67276 */
67277
67278 -#define L1_CACHE_SHIFT 5
67279 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67280 +#define L1_CACHE_SHIFT 5UL
67281 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67282
67283 #endif /* __ASM_GENERIC_CACHE_H */
67284 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67285 index 0d68a1e..b74a761 100644
67286 --- a/include/asm-generic/emergency-restart.h
67287 +++ b/include/asm-generic/emergency-restart.h
67288 @@ -1,7 +1,7 @@
67289 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67290 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67291
67292 -static inline void machine_emergency_restart(void)
67293 +static inline __noreturn void machine_emergency_restart(void)
67294 {
67295 machine_restart(NULL);
67296 }
67297 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67298 index 90f99c7..00ce236 100644
67299 --- a/include/asm-generic/kmap_types.h
67300 +++ b/include/asm-generic/kmap_types.h
67301 @@ -2,9 +2,9 @@
67302 #define _ASM_GENERIC_KMAP_TYPES_H
67303
67304 #ifdef __WITH_KM_FENCE
67305 -# define KM_TYPE_NR 41
67306 +# define KM_TYPE_NR 42
67307 #else
67308 -# define KM_TYPE_NR 20
67309 +# define KM_TYPE_NR 21
67310 #endif
67311
67312 #endif
67313 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67314 index 9ceb03b..62b0b8f 100644
67315 --- a/include/asm-generic/local.h
67316 +++ b/include/asm-generic/local.h
67317 @@ -23,24 +23,37 @@ typedef struct
67318 atomic_long_t a;
67319 } local_t;
67320
67321 +typedef struct {
67322 + atomic_long_unchecked_t a;
67323 +} local_unchecked_t;
67324 +
67325 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
67326
67327 #define local_read(l) atomic_long_read(&(l)->a)
67328 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
67329 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
67330 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
67331 #define local_inc(l) atomic_long_inc(&(l)->a)
67332 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
67333 #define local_dec(l) atomic_long_dec(&(l)->a)
67334 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
67335 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
67336 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
67337 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67338 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67339
67340 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67341 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67342 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67343 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67344 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67345 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67346 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67347 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67348 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67349
67350 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67351 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67352 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67353 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67354 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67355 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67356 index 725612b..9cc513a 100644
67357 --- a/include/asm-generic/pgtable-nopmd.h
67358 +++ b/include/asm-generic/pgtable-nopmd.h
67359 @@ -1,14 +1,19 @@
67360 #ifndef _PGTABLE_NOPMD_H
67361 #define _PGTABLE_NOPMD_H
67362
67363 -#ifndef __ASSEMBLY__
67364 -
67365 #include <asm-generic/pgtable-nopud.h>
67366
67367 -struct mm_struct;
67368 -
67369 #define __PAGETABLE_PMD_FOLDED
67370
67371 +#define PMD_SHIFT PUD_SHIFT
67372 +#define PTRS_PER_PMD 1
67373 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67374 +#define PMD_MASK (~(PMD_SIZE-1))
67375 +
67376 +#ifndef __ASSEMBLY__
67377 +
67378 +struct mm_struct;
67379 +
67380 /*
67381 * Having the pmd type consist of a pud gets the size right, and allows
67382 * us to conceptually access the pud entry that this pmd is folded into
67383 @@ -16,11 +21,6 @@ struct mm_struct;
67384 */
67385 typedef struct { pud_t pud; } pmd_t;
67386
67387 -#define PMD_SHIFT PUD_SHIFT
67388 -#define PTRS_PER_PMD 1
67389 -#define PMD_SIZE (1UL << PMD_SHIFT)
67390 -#define PMD_MASK (~(PMD_SIZE-1))
67391 -
67392 /*
67393 * The "pud_xxx()" functions here are trivial for a folded two-level
67394 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67395 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67396 index 810431d..0ec4804f 100644
67397 --- a/include/asm-generic/pgtable-nopud.h
67398 +++ b/include/asm-generic/pgtable-nopud.h
67399 @@ -1,10 +1,15 @@
67400 #ifndef _PGTABLE_NOPUD_H
67401 #define _PGTABLE_NOPUD_H
67402
67403 -#ifndef __ASSEMBLY__
67404 -
67405 #define __PAGETABLE_PUD_FOLDED
67406
67407 +#define PUD_SHIFT PGDIR_SHIFT
67408 +#define PTRS_PER_PUD 1
67409 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67410 +#define PUD_MASK (~(PUD_SIZE-1))
67411 +
67412 +#ifndef __ASSEMBLY__
67413 +
67414 /*
67415 * Having the pud type consist of a pgd gets the size right, and allows
67416 * us to conceptually access the pgd entry that this pud is folded into
67417 @@ -12,11 +17,6 @@
67418 */
67419 typedef struct { pgd_t pgd; } pud_t;
67420
67421 -#define PUD_SHIFT PGDIR_SHIFT
67422 -#define PTRS_PER_PUD 1
67423 -#define PUD_SIZE (1UL << PUD_SHIFT)
67424 -#define PUD_MASK (~(PUD_SIZE-1))
67425 -
67426 /*
67427 * The "pgd_xxx()" functions here are trivial for a folded two-level
67428 * setup: the pud is never bad, and a pud always exists (as it's folded
67429 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67430 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67431
67432 #define pgd_populate(mm, pgd, pud) do { } while (0)
67433 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67434 /*
67435 * (puds are folded into pgds so this doesn't get actually called,
67436 * but the define is needed for a generic inline function.)
67437 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67438 index 5cf680a..4b74d62 100644
67439 --- a/include/asm-generic/pgtable.h
67440 +++ b/include/asm-generic/pgtable.h
67441 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67442 }
67443 #endif /* CONFIG_NUMA_BALANCING */
67444
67445 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67446 +static inline unsigned long pax_open_kernel(void) { return 0; }
67447 +#endif
67448 +
67449 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67450 +static inline unsigned long pax_close_kernel(void) { return 0; }
67451 +#endif
67452 +
67453 #endif /* CONFIG_MMU */
67454
67455 #endif /* !__ASSEMBLY__ */
67456 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67457 index d1ea7ce..b1ebf2a 100644
67458 --- a/include/asm-generic/vmlinux.lds.h
67459 +++ b/include/asm-generic/vmlinux.lds.h
67460 @@ -218,6 +218,7 @@
67461 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67462 VMLINUX_SYMBOL(__start_rodata) = .; \
67463 *(.rodata) *(.rodata.*) \
67464 + *(.data..read_only) \
67465 *(__vermagic) /* Kernel version magic */ \
67466 . = ALIGN(8); \
67467 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67468 @@ -725,17 +726,18 @@
67469 * section in the linker script will go there too. @phdr should have
67470 * a leading colon.
67471 *
67472 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67473 + * Note that this macros defines per_cpu_load as an absolute symbol.
67474 * If there is no need to put the percpu section at a predetermined
67475 * address, use PERCPU_SECTION.
67476 */
67477 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67478 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67479 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67480 + per_cpu_load = .; \
67481 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67482 - LOAD_OFFSET) { \
67483 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67484 PERCPU_INPUT(cacheline) \
67485 } phdr \
67486 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67487 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67488
67489 /**
67490 * PERCPU_SECTION - define output section for percpu area, simple version
67491 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67492 index 418d270..bfd2794 100644
67493 --- a/include/crypto/algapi.h
67494 +++ b/include/crypto/algapi.h
67495 @@ -34,7 +34,7 @@ struct crypto_type {
67496 unsigned int maskclear;
67497 unsigned int maskset;
67498 unsigned int tfmsize;
67499 -};
67500 +} __do_const;
67501
67502 struct crypto_instance {
67503 struct crypto_alg alg;
67504 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67505 index fad21c9..ab858bc 100644
67506 --- a/include/drm/drmP.h
67507 +++ b/include/drm/drmP.h
67508 @@ -72,6 +72,7 @@
67509 #include <linux/workqueue.h>
67510 #include <linux/poll.h>
67511 #include <asm/pgalloc.h>
67512 +#include <asm/local.h>
67513 #include <drm/drm.h>
67514 #include <drm/drm_sarea.h>
67515
67516 @@ -293,10 +294,12 @@ do { \
67517 * \param cmd command.
67518 * \param arg argument.
67519 */
67520 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67521 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67522 + struct drm_file *file_priv);
67523 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67524 struct drm_file *file_priv);
67525
67526 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67527 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67528 unsigned long arg);
67529
67530 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67531 @@ -311,9 +314,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67532 struct drm_ioctl_desc {
67533 unsigned int cmd;
67534 int flags;
67535 - drm_ioctl_t *func;
67536 + drm_ioctl_t func;
67537 unsigned int cmd_drv;
67538 -};
67539 +} __do_const;
67540
67541 /**
67542 * Creates a driver or general drm_ioctl_desc array entry for the given
67543 @@ -995,7 +998,7 @@ struct drm_info_list {
67544 int (*show)(struct seq_file*, void*); /** show callback */
67545 u32 driver_features; /**< Required driver features for this entry */
67546 void *data;
67547 -};
67548 +} __do_const;
67549
67550 /**
67551 * debugfs node structure. This structure represents a debugfs file.
67552 @@ -1068,7 +1071,7 @@ struct drm_device {
67553
67554 /** \name Usage Counters */
67555 /*@{ */
67556 - int open_count; /**< Outstanding files open */
67557 + local_t open_count; /**< Outstanding files open */
67558 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67559 atomic_t vma_count; /**< Outstanding vma areas open */
67560 int buf_use; /**< Buffers in use -- cannot alloc */
67561 @@ -1079,7 +1082,7 @@ struct drm_device {
67562 /*@{ */
67563 unsigned long counters;
67564 enum drm_stat_type types[15];
67565 - atomic_t counts[15];
67566 + atomic_unchecked_t counts[15];
67567 /*@} */
67568
67569 struct list_head filelist;
67570 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67571 index f43d556..94d9343 100644
67572 --- a/include/drm/drm_crtc_helper.h
67573 +++ b/include/drm/drm_crtc_helper.h
67574 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67575 struct drm_connector *connector);
67576 /* disable encoder when not in use - more explicit than dpms off */
67577 void (*disable)(struct drm_encoder *encoder);
67578 -};
67579 +} __no_const;
67580
67581 /**
67582 * drm_connector_helper_funcs - helper operations for connectors
67583 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67584 index 72dcbe8..8db58d7 100644
67585 --- a/include/drm/ttm/ttm_memory.h
67586 +++ b/include/drm/ttm/ttm_memory.h
67587 @@ -48,7 +48,7 @@
67588
67589 struct ttm_mem_shrink {
67590 int (*do_shrink) (struct ttm_mem_shrink *);
67591 -};
67592 +} __no_const;
67593
67594 /**
67595 * struct ttm_mem_global - Global memory accounting structure.
67596 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67597 index 4b840e8..155d235 100644
67598 --- a/include/keys/asymmetric-subtype.h
67599 +++ b/include/keys/asymmetric-subtype.h
67600 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67601 /* Verify the signature on a key of this subtype (optional) */
67602 int (*verify_signature)(const struct key *key,
67603 const struct public_key_signature *sig);
67604 -};
67605 +} __do_const;
67606
67607 /**
67608 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67609 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67610 index c1da539..1dcec55 100644
67611 --- a/include/linux/atmdev.h
67612 +++ b/include/linux/atmdev.h
67613 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67614 #endif
67615
67616 struct k_atm_aal_stats {
67617 -#define __HANDLE_ITEM(i) atomic_t i
67618 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67619 __AAL_STAT_ITEMS
67620 #undef __HANDLE_ITEM
67621 };
67622 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67623 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67624 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67625 struct module *owner;
67626 -};
67627 +} __do_const ;
67628
67629 struct atmphy_ops {
67630 int (*start)(struct atm_dev *dev);
67631 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67632 index 0530b98..96a8ac0 100644
67633 --- a/include/linux/binfmts.h
67634 +++ b/include/linux/binfmts.h
67635 @@ -73,8 +73,9 @@ struct linux_binfmt {
67636 int (*load_binary)(struct linux_binprm *);
67637 int (*load_shlib)(struct file *);
67638 int (*core_dump)(struct coredump_params *cprm);
67639 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67640 unsigned long min_coredump; /* minimal dump size */
67641 -};
67642 +} __do_const;
67643
67644 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67645
67646 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67647 index f94bc83..62b9cfe 100644
67648 --- a/include/linux/blkdev.h
67649 +++ b/include/linux/blkdev.h
67650 @@ -1498,7 +1498,7 @@ struct block_device_operations {
67651 /* this callback is with swap_lock and sometimes page table lock held */
67652 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67653 struct module *owner;
67654 -};
67655 +} __do_const;
67656
67657 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67658 unsigned long);
67659 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67660 index 7c2e030..b72475d 100644
67661 --- a/include/linux/blktrace_api.h
67662 +++ b/include/linux/blktrace_api.h
67663 @@ -23,7 +23,7 @@ struct blk_trace {
67664 struct dentry *dir;
67665 struct dentry *dropped_file;
67666 struct dentry *msg_file;
67667 - atomic_t dropped;
67668 + atomic_unchecked_t dropped;
67669 };
67670
67671 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67672 diff --git a/include/linux/cache.h b/include/linux/cache.h
67673 index 4c57065..4307975 100644
67674 --- a/include/linux/cache.h
67675 +++ b/include/linux/cache.h
67676 @@ -16,6 +16,10 @@
67677 #define __read_mostly
67678 #endif
67679
67680 +#ifndef __read_only
67681 +#define __read_only __read_mostly
67682 +#endif
67683 +
67684 #ifndef ____cacheline_aligned
67685 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67686 #endif
67687 diff --git a/include/linux/capability.h b/include/linux/capability.h
67688 index 98503b7..cc36d18 100644
67689 --- a/include/linux/capability.h
67690 +++ b/include/linux/capability.h
67691 @@ -211,8 +211,13 @@ extern bool capable(int cap);
67692 extern bool ns_capable(struct user_namespace *ns, int cap);
67693 extern bool nsown_capable(int cap);
67694 extern bool inode_capable(const struct inode *inode, int cap);
67695 +extern bool capable_nolog(int cap);
67696 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67697 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67698
67699 /* audit system wants to get cap info from files as well */
67700 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67701
67702 +extern int is_privileged_binary(const struct dentry *dentry);
67703 +
67704 #endif /* !_LINUX_CAPABILITY_H */
67705 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67706 index 8609d57..86e4d79 100644
67707 --- a/include/linux/cdrom.h
67708 +++ b/include/linux/cdrom.h
67709 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67710
67711 /* driver specifications */
67712 const int capability; /* capability flags */
67713 - int n_minors; /* number of active minor devices */
67714 /* handle uniform packets for scsi type devices (scsi,atapi) */
67715 int (*generic_packet) (struct cdrom_device_info *,
67716 struct packet_command *);
67717 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67718 index 42e55de..1cd0e66 100644
67719 --- a/include/linux/cleancache.h
67720 +++ b/include/linux/cleancache.h
67721 @@ -31,7 +31,7 @@ struct cleancache_ops {
67722 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67723 void (*invalidate_inode)(int, struct cleancache_filekey);
67724 void (*invalidate_fs)(int);
67725 -};
67726 +} __no_const;
67727
67728 extern struct cleancache_ops
67729 cleancache_register_ops(struct cleancache_ops *ops);
67730 diff --git a/include/linux/compat.h b/include/linux/compat.h
67731 index dec7e2d..45db13f 100644
67732 --- a/include/linux/compat.h
67733 +++ b/include/linux/compat.h
67734 @@ -311,14 +311,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67735 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67736 int version, void __user *uptr);
67737 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67738 - void __user *uptr);
67739 + void __user *uptr) __intentional_overflow(0);
67740 #else
67741 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67742 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67743 compat_ssize_t msgsz, int msgflg);
67744 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67745 compat_ssize_t msgsz, long msgtyp, int msgflg);
67746 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67747 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67748 #endif
67749 long compat_sys_msgctl(int first, int second, void __user *uptr);
67750 long compat_sys_shmctl(int first, int second, void __user *uptr);
67751 @@ -414,7 +414,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67752 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67753 compat_ulong_t addr, compat_ulong_t data);
67754 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67755 - compat_long_t addr, compat_long_t data);
67756 + compat_ulong_t addr, compat_ulong_t data);
67757
67758 /*
67759 * epoll (fs/eventpoll.c) compat bits follow ...
67760 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67761 index 662fd1b..e801992 100644
67762 --- a/include/linux/compiler-gcc4.h
67763 +++ b/include/linux/compiler-gcc4.h
67764 @@ -34,6 +34,21 @@
67765 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
67766
67767 #if __GNUC_MINOR__ >= 5
67768 +
67769 +#ifdef CONSTIFY_PLUGIN
67770 +#define __no_const __attribute__((no_const))
67771 +#define __do_const __attribute__((do_const))
67772 +#endif
67773 +
67774 +#ifdef SIZE_OVERFLOW_PLUGIN
67775 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67776 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67777 +#endif
67778 +
67779 +#ifdef LATENT_ENTROPY_PLUGIN
67780 +#define __latent_entropy __attribute__((latent_entropy))
67781 +#endif
67782 +
67783 /*
67784 * Mark a position in code as unreachable. This can be used to
67785 * suppress control flow warnings after asm blocks that transfer
67786 @@ -49,6 +64,11 @@
67787 #define __noclone __attribute__((__noclone__))
67788
67789 #endif
67790 +
67791 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67792 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67793 +#define __bos0(ptr) __bos((ptr), 0)
67794 +#define __bos1(ptr) __bos((ptr), 1)
67795 #endif
67796
67797 #if __GNUC_MINOR__ >= 6
67798 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67799 index dd852b7..1ad5fba 100644
67800 --- a/include/linux/compiler.h
67801 +++ b/include/linux/compiler.h
67802 @@ -5,11 +5,14 @@
67803
67804 #ifdef __CHECKER__
67805 # define __user __attribute__((noderef, address_space(1)))
67806 +# define __force_user __force __user
67807 # define __kernel __attribute__((address_space(0)))
67808 +# define __force_kernel __force __kernel
67809 # define __safe __attribute__((safe))
67810 # define __force __attribute__((force))
67811 # define __nocast __attribute__((nocast))
67812 # define __iomem __attribute__((noderef, address_space(2)))
67813 +# define __force_iomem __force __iomem
67814 # define __must_hold(x) __attribute__((context(x,1,1)))
67815 # define __acquires(x) __attribute__((context(x,0,1)))
67816 # define __releases(x) __attribute__((context(x,1,0)))
67817 @@ -17,20 +20,37 @@
67818 # define __release(x) __context__(x,-1)
67819 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
67820 # define __percpu __attribute__((noderef, address_space(3)))
67821 +# define __force_percpu __force __percpu
67822 #ifdef CONFIG_SPARSE_RCU_POINTER
67823 # define __rcu __attribute__((noderef, address_space(4)))
67824 +# define __force_rcu __force __rcu
67825 #else
67826 # define __rcu
67827 +# define __force_rcu
67828 #endif
67829 extern void __chk_user_ptr(const volatile void __user *);
67830 extern void __chk_io_ptr(const volatile void __iomem *);
67831 #else
67832 -# define __user
67833 -# define __kernel
67834 +# ifdef CHECKER_PLUGIN
67835 +//# define __user
67836 +//# define __force_user
67837 +//# define __kernel
67838 +//# define __force_kernel
67839 +# else
67840 +# ifdef STRUCTLEAK_PLUGIN
67841 +# define __user __attribute__((user))
67842 +# else
67843 +# define __user
67844 +# endif
67845 +# define __force_user
67846 +# define __kernel
67847 +# define __force_kernel
67848 +# endif
67849 # define __safe
67850 # define __force
67851 # define __nocast
67852 # define __iomem
67853 +# define __force_iomem
67854 # define __chk_user_ptr(x) (void)0
67855 # define __chk_io_ptr(x) (void)0
67856 # define __builtin_warning(x, y...) (1)
67857 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67858 # define __release(x) (void)0
67859 # define __cond_lock(x,c) (c)
67860 # define __percpu
67861 +# define __force_percpu
67862 # define __rcu
67863 +# define __force_rcu
67864 #endif
67865
67866 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67867 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67868 # define __attribute_const__ /* unimplemented */
67869 #endif
67870
67871 +#ifndef __no_const
67872 +# define __no_const
67873 +#endif
67874 +
67875 +#ifndef __do_const
67876 +# define __do_const
67877 +#endif
67878 +
67879 +#ifndef __size_overflow
67880 +# define __size_overflow(...)
67881 +#endif
67882 +
67883 +#ifndef __intentional_overflow
67884 +# define __intentional_overflow(...)
67885 +#endif
67886 +
67887 +#ifndef __latent_entropy
67888 +# define __latent_entropy
67889 +#endif
67890 +
67891 /*
67892 * Tell gcc if a function is cold. The compiler will assume any path
67893 * directly leading to the call is unlikely.
67894 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67895 #define __cold
67896 #endif
67897
67898 +#ifndef __alloc_size
67899 +#define __alloc_size(...)
67900 +#endif
67901 +
67902 +#ifndef __bos
67903 +#define __bos(ptr, arg)
67904 +#endif
67905 +
67906 +#ifndef __bos0
67907 +#define __bos0(ptr)
67908 +#endif
67909 +
67910 +#ifndef __bos1
67911 +#define __bos1(ptr)
67912 +#endif
67913 +
67914 /* Simple shorthand for a section definition */
67915 #ifndef __section
67916 # define __section(S) __attribute__ ((__section__(#S)))
67917 @@ -323,6 +381,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67918 * use is to mediate communication between process-level code and irq/NMI
67919 * handlers, all running on the same CPU.
67920 */
67921 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
67922 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
67923 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
67924
67925 #endif /* __LINUX_COMPILER_H */
67926 diff --git a/include/linux/completion.h b/include/linux/completion.h
67927 index 51494e6..0fd1b61 100644
67928 --- a/include/linux/completion.h
67929 +++ b/include/linux/completion.h
67930 @@ -78,13 +78,13 @@ static inline void init_completion(struct completion *x)
67931
67932 extern void wait_for_completion(struct completion *);
67933 extern int wait_for_completion_interruptible(struct completion *x);
67934 -extern int wait_for_completion_killable(struct completion *x);
67935 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
67936 extern unsigned long wait_for_completion_timeout(struct completion *x,
67937 unsigned long timeout);
67938 extern long wait_for_completion_interruptible_timeout(
67939 - struct completion *x, unsigned long timeout);
67940 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67941 extern long wait_for_completion_killable_timeout(
67942 - struct completion *x, unsigned long timeout);
67943 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
67944 extern bool try_wait_for_completion(struct completion *x);
67945 extern bool completion_done(struct completion *x);
67946
67947 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
67948 index 34025df..d94bbbc 100644
67949 --- a/include/linux/configfs.h
67950 +++ b/include/linux/configfs.h
67951 @@ -125,7 +125,7 @@ struct configfs_attribute {
67952 const char *ca_name;
67953 struct module *ca_owner;
67954 umode_t ca_mode;
67955 -};
67956 +} __do_const;
67957
67958 /*
67959 * Users often need to create attribute structures for their configurable
67960 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
67961 index ce7a074..01ab8ac 100644
67962 --- a/include/linux/cpu.h
67963 +++ b/include/linux/cpu.h
67964 @@ -115,7 +115,7 @@ enum {
67965 /* Need to know about CPUs going up/down? */
67966 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
67967 #define cpu_notifier(fn, pri) { \
67968 - static struct notifier_block fn##_nb __cpuinitdata = \
67969 + static struct notifier_block fn##_nb = \
67970 { .notifier_call = fn, .priority = pri }; \
67971 register_cpu_notifier(&fn##_nb); \
67972 }
67973 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
67974 index a55b88e..fba90c5 100644
67975 --- a/include/linux/cpufreq.h
67976 +++ b/include/linux/cpufreq.h
67977 @@ -240,7 +240,7 @@ struct cpufreq_driver {
67978 int (*suspend) (struct cpufreq_policy *policy);
67979 int (*resume) (struct cpufreq_policy *policy);
67980 struct freq_attr **attr;
67981 -};
67982 +} __do_const;
67983
67984 /* flags */
67985
67986 @@ -299,6 +299,7 @@ struct global_attr {
67987 ssize_t (*store)(struct kobject *a, struct attribute *b,
67988 const char *c, size_t count);
67989 };
67990 +typedef struct global_attr __no_const global_attr_no_const;
67991
67992 #define define_one_global_ro(_name) \
67993 static struct global_attr _name = \
67994 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
67995 index 24cd1037..20a63aae 100644
67996 --- a/include/linux/cpuidle.h
67997 +++ b/include/linux/cpuidle.h
67998 @@ -54,7 +54,8 @@ struct cpuidle_state {
67999 int index);
68000
68001 int (*enter_dead) (struct cpuidle_device *dev, int index);
68002 -};
68003 +} __do_const;
68004 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68005
68006 /* Idle State Flags */
68007 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68008 @@ -216,7 +217,7 @@ struct cpuidle_governor {
68009 void (*reflect) (struct cpuidle_device *dev, int index);
68010
68011 struct module *owner;
68012 -};
68013 +} __do_const;
68014
68015 #ifdef CONFIG_CPU_IDLE
68016
68017 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68018 index 0325602..5e9feff 100644
68019 --- a/include/linux/cpumask.h
68020 +++ b/include/linux/cpumask.h
68021 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68022 }
68023
68024 /* Valid inputs for n are -1 and 0. */
68025 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68026 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68027 {
68028 return n+1;
68029 }
68030
68031 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68032 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68033 {
68034 return n+1;
68035 }
68036
68037 -static inline unsigned int cpumask_next_and(int n,
68038 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68039 const struct cpumask *srcp,
68040 const struct cpumask *andp)
68041 {
68042 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68043 *
68044 * Returns >= nr_cpu_ids if no further cpus set.
68045 */
68046 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68047 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68048 {
68049 /* -1 is a legal arg here. */
68050 if (n != -1)
68051 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68052 *
68053 * Returns >= nr_cpu_ids if no further cpus unset.
68054 */
68055 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68056 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68057 {
68058 /* -1 is a legal arg here. */
68059 if (n != -1)
68060 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68061 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68062 }
68063
68064 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68065 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68066 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68067
68068 /**
68069 diff --git a/include/linux/cred.h b/include/linux/cred.h
68070 index 04421e8..6bce4ef 100644
68071 --- a/include/linux/cred.h
68072 +++ b/include/linux/cred.h
68073 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68074 static inline void validate_process_creds(void)
68075 {
68076 }
68077 +static inline void validate_task_creds(struct task_struct *task)
68078 +{
68079 +}
68080 #endif
68081
68082 /**
68083 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68084 index b92eadf..b4ecdc1 100644
68085 --- a/include/linux/crypto.h
68086 +++ b/include/linux/crypto.h
68087 @@ -373,7 +373,7 @@ struct cipher_tfm {
68088 const u8 *key, unsigned int keylen);
68089 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68090 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68091 -};
68092 +} __no_const;
68093
68094 struct hash_tfm {
68095 int (*init)(struct hash_desc *desc);
68096 @@ -394,13 +394,13 @@ struct compress_tfm {
68097 int (*cot_decompress)(struct crypto_tfm *tfm,
68098 const u8 *src, unsigned int slen,
68099 u8 *dst, unsigned int *dlen);
68100 -};
68101 +} __no_const;
68102
68103 struct rng_tfm {
68104 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
68105 unsigned int dlen);
68106 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
68107 -};
68108 +} __no_const;
68109
68110 #define crt_ablkcipher crt_u.ablkcipher
68111 #define crt_aead crt_u.aead
68112 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
68113 index 8acfe31..6ffccd63 100644
68114 --- a/include/linux/ctype.h
68115 +++ b/include/linux/ctype.h
68116 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
68117 * Fast implementation of tolower() for internal usage. Do not use in your
68118 * code.
68119 */
68120 -static inline char _tolower(const char c)
68121 +static inline unsigned char _tolower(const unsigned char c)
68122 {
68123 return c | 0x20;
68124 }
68125 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
68126 index 7925bf0..d5143d2 100644
68127 --- a/include/linux/decompress/mm.h
68128 +++ b/include/linux/decompress/mm.h
68129 @@ -77,7 +77,7 @@ static void free(void *where)
68130 * warnings when not needed (indeed large_malloc / large_free are not
68131 * needed by inflate */
68132
68133 -#define malloc(a) kmalloc(a, GFP_KERNEL)
68134 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68135 #define free(a) kfree(a)
68136
68137 #define large_malloc(a) vmalloc(a)
68138 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68139 index e83ef39..33e0eb3 100644
68140 --- a/include/linux/devfreq.h
68141 +++ b/include/linux/devfreq.h
68142 @@ -114,7 +114,7 @@ struct devfreq_governor {
68143 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68144 int (*event_handler)(struct devfreq *devfreq,
68145 unsigned int event, void *data);
68146 -};
68147 +} __do_const;
68148
68149 /**
68150 * struct devfreq - Device devfreq structure
68151 diff --git a/include/linux/device.h b/include/linux/device.h
68152 index 43dcda9..7a1fb65 100644
68153 --- a/include/linux/device.h
68154 +++ b/include/linux/device.h
68155 @@ -294,7 +294,7 @@ struct subsys_interface {
68156 struct list_head node;
68157 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68158 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68159 -};
68160 +} __do_const;
68161
68162 int subsys_interface_register(struct subsys_interface *sif);
68163 void subsys_interface_unregister(struct subsys_interface *sif);
68164 @@ -474,7 +474,7 @@ struct device_type {
68165 void (*release)(struct device *dev);
68166
68167 const struct dev_pm_ops *pm;
68168 -};
68169 +} __do_const;
68170
68171 /* interface for exporting device attributes */
68172 struct device_attribute {
68173 @@ -484,11 +484,12 @@ struct device_attribute {
68174 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68175 const char *buf, size_t count);
68176 };
68177 +typedef struct device_attribute __no_const device_attribute_no_const;
68178
68179 struct dev_ext_attribute {
68180 struct device_attribute attr;
68181 void *var;
68182 -};
68183 +} __do_const;
68184
68185 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68186 char *buf);
68187 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68188 index 94af418..b1ca7a2 100644
68189 --- a/include/linux/dma-mapping.h
68190 +++ b/include/linux/dma-mapping.h
68191 @@ -54,7 +54,7 @@ struct dma_map_ops {
68192 u64 (*get_required_mask)(struct device *dev);
68193 #endif
68194 int is_phys;
68195 -};
68196 +} __do_const;
68197
68198 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68199
68200 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68201 index d3201e4..8281e63 100644
68202 --- a/include/linux/dmaengine.h
68203 +++ b/include/linux/dmaengine.h
68204 @@ -1018,9 +1018,9 @@ struct dma_pinned_list {
68205 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68206 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68207
68208 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68209 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68210 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68211 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68212 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68213 struct dma_pinned_list *pinned_list, struct page *page,
68214 unsigned int offset, size_t len);
68215
68216 diff --git a/include/linux/efi.h b/include/linux/efi.h
68217 index 7a9498a..155713d 100644
68218 --- a/include/linux/efi.h
68219 +++ b/include/linux/efi.h
68220 @@ -733,6 +733,7 @@ struct efivar_operations {
68221 efi_set_variable_t *set_variable;
68222 efi_query_variable_info_t *query_variable_info;
68223 };
68224 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68225
68226 struct efivars {
68227 /*
68228 diff --git a/include/linux/elf.h b/include/linux/elf.h
68229 index 8c9048e..16a4665 100644
68230 --- a/include/linux/elf.h
68231 +++ b/include/linux/elf.h
68232 @@ -20,6 +20,7 @@ extern Elf32_Dyn _DYNAMIC [];
68233 #define elf_note elf32_note
68234 #define elf_addr_t Elf32_Off
68235 #define Elf_Half Elf32_Half
68236 +#define elf_dyn Elf32_Dyn
68237
68238 #else
68239
68240 @@ -30,6 +31,7 @@ extern Elf64_Dyn _DYNAMIC [];
68241 #define elf_note elf64_note
68242 #define elf_addr_t Elf64_Off
68243 #define Elf_Half Elf64_Half
68244 +#define elf_dyn Elf64_Dyn
68245
68246 #endif
68247
68248 diff --git a/include/linux/err.h b/include/linux/err.h
68249 index f2edce2..cc2082c 100644
68250 --- a/include/linux/err.h
68251 +++ b/include/linux/err.h
68252 @@ -19,12 +19,12 @@
68253
68254 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68255
68256 -static inline void * __must_check ERR_PTR(long error)
68257 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68258 {
68259 return (void *) error;
68260 }
68261
68262 -static inline long __must_check PTR_ERR(const void *ptr)
68263 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68264 {
68265 return (long) ptr;
68266 }
68267 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68268 index fcb51c8..bdafcf6 100644
68269 --- a/include/linux/extcon.h
68270 +++ b/include/linux/extcon.h
68271 @@ -134,7 +134,7 @@ struct extcon_dev {
68272 /* /sys/class/extcon/.../mutually_exclusive/... */
68273 struct attribute_group attr_g_muex;
68274 struct attribute **attrs_muex;
68275 - struct device_attribute *d_attrs_muex;
68276 + device_attribute_no_const *d_attrs_muex;
68277 };
68278
68279 /**
68280 diff --git a/include/linux/fb.h b/include/linux/fb.h
68281 index c7a9571..02eeffe 100644
68282 --- a/include/linux/fb.h
68283 +++ b/include/linux/fb.h
68284 @@ -302,7 +302,7 @@ struct fb_ops {
68285 /* called at KDB enter and leave time to prepare the console */
68286 int (*fb_debug_enter)(struct fb_info *info);
68287 int (*fb_debug_leave)(struct fb_info *info);
68288 -};
68289 +} __do_const;
68290
68291 #ifdef CONFIG_FB_TILEBLITTING
68292 #define FB_TILE_CURSOR_NONE 0
68293 diff --git a/include/linux/filter.h b/include/linux/filter.h
68294 index c45eabc..baa0be5 100644
68295 --- a/include/linux/filter.h
68296 +++ b/include/linux/filter.h
68297 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68298
68299 struct sk_buff;
68300 struct sock;
68301 +struct bpf_jit_work;
68302
68303 struct sk_filter
68304 {
68305 @@ -27,6 +28,9 @@ struct sk_filter
68306 unsigned int len; /* Number of filter blocks */
68307 unsigned int (*bpf_func)(const struct sk_buff *skb,
68308 const struct sock_filter *filter);
68309 +#ifdef CONFIG_BPF_JIT
68310 + struct bpf_jit_work *work;
68311 +#endif
68312 struct rcu_head rcu;
68313 struct sock_filter insns[0];
68314 };
68315 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68316 index 3044254..9767f41 100644
68317 --- a/include/linux/frontswap.h
68318 +++ b/include/linux/frontswap.h
68319 @@ -11,7 +11,7 @@ struct frontswap_ops {
68320 int (*load)(unsigned, pgoff_t, struct page *);
68321 void (*invalidate_page)(unsigned, pgoff_t);
68322 void (*invalidate_area)(unsigned);
68323 -};
68324 +} __no_const;
68325
68326 extern bool frontswap_enabled;
68327 extern struct frontswap_ops
68328 diff --git a/include/linux/fs.h b/include/linux/fs.h
68329 index 7617ee0..b575199 100644
68330 --- a/include/linux/fs.h
68331 +++ b/include/linux/fs.h
68332 @@ -1541,7 +1541,8 @@ struct file_operations {
68333 long (*fallocate)(struct file *file, int mode, loff_t offset,
68334 loff_t len);
68335 int (*show_fdinfo)(struct seq_file *m, struct file *f);
68336 -};
68337 +} __do_const;
68338 +typedef struct file_operations __no_const file_operations_no_const;
68339
68340 struct inode_operations {
68341 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68342 @@ -2665,4 +2666,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68343 inode->i_flags |= S_NOSEC;
68344 }
68345
68346 +static inline bool is_sidechannel_device(const struct inode *inode)
68347 +{
68348 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68349 + umode_t mode = inode->i_mode;
68350 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68351 +#else
68352 + return false;
68353 +#endif
68354 +}
68355 +
68356 #endif /* _LINUX_FS_H */
68357 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68358 index 324f931..f292b65 100644
68359 --- a/include/linux/fs_struct.h
68360 +++ b/include/linux/fs_struct.h
68361 @@ -6,7 +6,7 @@
68362 #include <linux/seqlock.h>
68363
68364 struct fs_struct {
68365 - int users;
68366 + atomic_t users;
68367 spinlock_t lock;
68368 seqcount_t seq;
68369 int umask;
68370 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68371 index 5dfa0aa..6acf322 100644
68372 --- a/include/linux/fscache-cache.h
68373 +++ b/include/linux/fscache-cache.h
68374 @@ -112,7 +112,7 @@ struct fscache_operation {
68375 fscache_operation_release_t release;
68376 };
68377
68378 -extern atomic_t fscache_op_debug_id;
68379 +extern atomic_unchecked_t fscache_op_debug_id;
68380 extern void fscache_op_work_func(struct work_struct *work);
68381
68382 extern void fscache_enqueue_operation(struct fscache_operation *);
68383 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68384 INIT_WORK(&op->work, fscache_op_work_func);
68385 atomic_set(&op->usage, 1);
68386 op->state = FSCACHE_OP_ST_INITIALISED;
68387 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68388 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68389 op->processor = processor;
68390 op->release = release;
68391 INIT_LIST_HEAD(&op->pend_link);
68392 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68393 index 7a08623..4c07b0f 100644
68394 --- a/include/linux/fscache.h
68395 +++ b/include/linux/fscache.h
68396 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68397 * - this is mandatory for any object that may have data
68398 */
68399 void (*now_uncached)(void *cookie_netfs_data);
68400 -};
68401 +} __do_const;
68402
68403 /*
68404 * fscache cached network filesystem type
68405 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68406 index 0fbfb46..508eb0d 100644
68407 --- a/include/linux/fsnotify.h
68408 +++ b/include/linux/fsnotify.h
68409 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68410 struct inode *inode = path->dentry->d_inode;
68411 __u32 mask = FS_ACCESS;
68412
68413 + if (is_sidechannel_device(inode))
68414 + return;
68415 +
68416 if (S_ISDIR(inode->i_mode))
68417 mask |= FS_ISDIR;
68418
68419 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68420 struct inode *inode = path->dentry->d_inode;
68421 __u32 mask = FS_MODIFY;
68422
68423 + if (is_sidechannel_device(inode))
68424 + return;
68425 +
68426 if (S_ISDIR(inode->i_mode))
68427 mask |= FS_ISDIR;
68428
68429 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68430 */
68431 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68432 {
68433 - return kstrdup(name, GFP_KERNEL);
68434 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68435 }
68436
68437 /*
68438 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68439 index a3d4895..ddd2a50 100644
68440 --- a/include/linux/ftrace_event.h
68441 +++ b/include/linux/ftrace_event.h
68442 @@ -272,7 +272,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68443 extern int trace_add_event_call(struct ftrace_event_call *call);
68444 extern void trace_remove_event_call(struct ftrace_event_call *call);
68445
68446 -#define is_signed_type(type) (((type)(-1)) < 0)
68447 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68448
68449 int trace_set_clr_event(const char *system, const char *event, int set);
68450
68451 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68452 index 79b8bba..86b539e 100644
68453 --- a/include/linux/genhd.h
68454 +++ b/include/linux/genhd.h
68455 @@ -194,7 +194,7 @@ struct gendisk {
68456 struct kobject *slave_dir;
68457
68458 struct timer_rand_state *random;
68459 - atomic_t sync_io; /* RAID */
68460 + atomic_unchecked_t sync_io; /* RAID */
68461 struct disk_events *ev;
68462 #ifdef CONFIG_BLK_DEV_INTEGRITY
68463 struct blk_integrity *integrity;
68464 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68465 index 023bc34..b02b46a 100644
68466 --- a/include/linux/genl_magic_func.h
68467 +++ b/include/linux/genl_magic_func.h
68468 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68469 },
68470
68471 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68472 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68473 +static struct genl_ops ZZZ_genl_ops[] = {
68474 #include GENL_MAGIC_INCLUDE_FILE
68475 };
68476
68477 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68478 index 0f615eb..5c3832f 100644
68479 --- a/include/linux/gfp.h
68480 +++ b/include/linux/gfp.h
68481 @@ -35,6 +35,13 @@ struct vm_area_struct;
68482 #define ___GFP_NO_KSWAPD 0x400000u
68483 #define ___GFP_OTHER_NODE 0x800000u
68484 #define ___GFP_WRITE 0x1000000u
68485 +
68486 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68487 +#define ___GFP_USERCOPY 0x2000000u
68488 +#else
68489 +#define ___GFP_USERCOPY 0
68490 +#endif
68491 +
68492 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68493
68494 /*
68495 @@ -92,6 +99,7 @@ struct vm_area_struct;
68496 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68497 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68498 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68499 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68500
68501 /*
68502 * This may seem redundant, but it's a way of annotating false positives vs.
68503 @@ -99,7 +107,7 @@ struct vm_area_struct;
68504 */
68505 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68506
68507 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68508 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68509 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68510
68511 /* This equals 0, but use constants in case they ever change */
68512 @@ -153,6 +161,8 @@ struct vm_area_struct;
68513 /* 4GB DMA on some platforms */
68514 #define GFP_DMA32 __GFP_DMA32
68515
68516 +#define GFP_USERCOPY __GFP_USERCOPY
68517 +
68518 /* Convert GFP flags to their corresponding migrate type */
68519 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68520 {
68521 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68522 new file mode 100644
68523 index 0000000..ebe6d72
68524 --- /dev/null
68525 +++ b/include/linux/gracl.h
68526 @@ -0,0 +1,319 @@
68527 +#ifndef GR_ACL_H
68528 +#define GR_ACL_H
68529 +
68530 +#include <linux/grdefs.h>
68531 +#include <linux/resource.h>
68532 +#include <linux/capability.h>
68533 +#include <linux/dcache.h>
68534 +#include <asm/resource.h>
68535 +
68536 +/* Major status information */
68537 +
68538 +#define GR_VERSION "grsecurity 2.9.1"
68539 +#define GRSECURITY_VERSION 0x2901
68540 +
68541 +enum {
68542 + GR_SHUTDOWN = 0,
68543 + GR_ENABLE = 1,
68544 + GR_SPROLE = 2,
68545 + GR_RELOAD = 3,
68546 + GR_SEGVMOD = 4,
68547 + GR_STATUS = 5,
68548 + GR_UNSPROLE = 6,
68549 + GR_PASSSET = 7,
68550 + GR_SPROLEPAM = 8,
68551 +};
68552 +
68553 +/* Password setup definitions
68554 + * kernel/grhash.c */
68555 +enum {
68556 + GR_PW_LEN = 128,
68557 + GR_SALT_LEN = 16,
68558 + GR_SHA_LEN = 32,
68559 +};
68560 +
68561 +enum {
68562 + GR_SPROLE_LEN = 64,
68563 +};
68564 +
68565 +enum {
68566 + GR_NO_GLOB = 0,
68567 + GR_REG_GLOB,
68568 + GR_CREATE_GLOB
68569 +};
68570 +
68571 +#define GR_NLIMITS 32
68572 +
68573 +/* Begin Data Structures */
68574 +
68575 +struct sprole_pw {
68576 + unsigned char *rolename;
68577 + unsigned char salt[GR_SALT_LEN];
68578 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68579 +};
68580 +
68581 +struct name_entry {
68582 + __u32 key;
68583 + ino_t inode;
68584 + dev_t device;
68585 + char *name;
68586 + __u16 len;
68587 + __u8 deleted;
68588 + struct name_entry *prev;
68589 + struct name_entry *next;
68590 +};
68591 +
68592 +struct inodev_entry {
68593 + struct name_entry *nentry;
68594 + struct inodev_entry *prev;
68595 + struct inodev_entry *next;
68596 +};
68597 +
68598 +struct acl_role_db {
68599 + struct acl_role_label **r_hash;
68600 + __u32 r_size;
68601 +};
68602 +
68603 +struct inodev_db {
68604 + struct inodev_entry **i_hash;
68605 + __u32 i_size;
68606 +};
68607 +
68608 +struct name_db {
68609 + struct name_entry **n_hash;
68610 + __u32 n_size;
68611 +};
68612 +
68613 +struct crash_uid {
68614 + uid_t uid;
68615 + unsigned long expires;
68616 +};
68617 +
68618 +struct gr_hash_struct {
68619 + void **table;
68620 + void **nametable;
68621 + void *first;
68622 + __u32 table_size;
68623 + __u32 used_size;
68624 + int type;
68625 +};
68626 +
68627 +/* Userspace Grsecurity ACL data structures */
68628 +
68629 +struct acl_subject_label {
68630 + char *filename;
68631 + ino_t inode;
68632 + dev_t device;
68633 + __u32 mode;
68634 + kernel_cap_t cap_mask;
68635 + kernel_cap_t cap_lower;
68636 + kernel_cap_t cap_invert_audit;
68637 +
68638 + struct rlimit res[GR_NLIMITS];
68639 + __u32 resmask;
68640 +
68641 + __u8 user_trans_type;
68642 + __u8 group_trans_type;
68643 + uid_t *user_transitions;
68644 + gid_t *group_transitions;
68645 + __u16 user_trans_num;
68646 + __u16 group_trans_num;
68647 +
68648 + __u32 sock_families[2];
68649 + __u32 ip_proto[8];
68650 + __u32 ip_type;
68651 + struct acl_ip_label **ips;
68652 + __u32 ip_num;
68653 + __u32 inaddr_any_override;
68654 +
68655 + __u32 crashes;
68656 + unsigned long expires;
68657 +
68658 + struct acl_subject_label *parent_subject;
68659 + struct gr_hash_struct *hash;
68660 + struct acl_subject_label *prev;
68661 + struct acl_subject_label *next;
68662 +
68663 + struct acl_object_label **obj_hash;
68664 + __u32 obj_hash_size;
68665 + __u16 pax_flags;
68666 +};
68667 +
68668 +struct role_allowed_ip {
68669 + __u32 addr;
68670 + __u32 netmask;
68671 +
68672 + struct role_allowed_ip *prev;
68673 + struct role_allowed_ip *next;
68674 +};
68675 +
68676 +struct role_transition {
68677 + char *rolename;
68678 +
68679 + struct role_transition *prev;
68680 + struct role_transition *next;
68681 +};
68682 +
68683 +struct acl_role_label {
68684 + char *rolename;
68685 + uid_t uidgid;
68686 + __u16 roletype;
68687 +
68688 + __u16 auth_attempts;
68689 + unsigned long expires;
68690 +
68691 + struct acl_subject_label *root_label;
68692 + struct gr_hash_struct *hash;
68693 +
68694 + struct acl_role_label *prev;
68695 + struct acl_role_label *next;
68696 +
68697 + struct role_transition *transitions;
68698 + struct role_allowed_ip *allowed_ips;
68699 + uid_t *domain_children;
68700 + __u16 domain_child_num;
68701 +
68702 + umode_t umask;
68703 +
68704 + struct acl_subject_label **subj_hash;
68705 + __u32 subj_hash_size;
68706 +};
68707 +
68708 +struct user_acl_role_db {
68709 + struct acl_role_label **r_table;
68710 + __u32 num_pointers; /* Number of allocations to track */
68711 + __u32 num_roles; /* Number of roles */
68712 + __u32 num_domain_children; /* Number of domain children */
68713 + __u32 num_subjects; /* Number of subjects */
68714 + __u32 num_objects; /* Number of objects */
68715 +};
68716 +
68717 +struct acl_object_label {
68718 + char *filename;
68719 + ino_t inode;
68720 + dev_t device;
68721 + __u32 mode;
68722 +
68723 + struct acl_subject_label *nested;
68724 + struct acl_object_label *globbed;
68725 +
68726 + /* next two structures not used */
68727 +
68728 + struct acl_object_label *prev;
68729 + struct acl_object_label *next;
68730 +};
68731 +
68732 +struct acl_ip_label {
68733 + char *iface;
68734 + __u32 addr;
68735 + __u32 netmask;
68736 + __u16 low, high;
68737 + __u8 mode;
68738 + __u32 type;
68739 + __u32 proto[8];
68740 +
68741 + /* next two structures not used */
68742 +
68743 + struct acl_ip_label *prev;
68744 + struct acl_ip_label *next;
68745 +};
68746 +
68747 +struct gr_arg {
68748 + struct user_acl_role_db role_db;
68749 + unsigned char pw[GR_PW_LEN];
68750 + unsigned char salt[GR_SALT_LEN];
68751 + unsigned char sum[GR_SHA_LEN];
68752 + unsigned char sp_role[GR_SPROLE_LEN];
68753 + struct sprole_pw *sprole_pws;
68754 + dev_t segv_device;
68755 + ino_t segv_inode;
68756 + uid_t segv_uid;
68757 + __u16 num_sprole_pws;
68758 + __u16 mode;
68759 +};
68760 +
68761 +struct gr_arg_wrapper {
68762 + struct gr_arg *arg;
68763 + __u32 version;
68764 + __u32 size;
68765 +};
68766 +
68767 +struct subject_map {
68768 + struct acl_subject_label *user;
68769 + struct acl_subject_label *kernel;
68770 + struct subject_map *prev;
68771 + struct subject_map *next;
68772 +};
68773 +
68774 +struct acl_subj_map_db {
68775 + struct subject_map **s_hash;
68776 + __u32 s_size;
68777 +};
68778 +
68779 +/* End Data Structures Section */
68780 +
68781 +/* Hash functions generated by empirical testing by Brad Spengler
68782 + Makes good use of the low bits of the inode. Generally 0-1 times
68783 + in loop for successful match. 0-3 for unsuccessful match.
68784 + Shift/add algorithm with modulus of table size and an XOR*/
68785 +
68786 +static __inline__ unsigned int
68787 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68788 +{
68789 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68790 +}
68791 +
68792 + static __inline__ unsigned int
68793 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68794 +{
68795 + return ((const unsigned long)userp % sz);
68796 +}
68797 +
68798 +static __inline__ unsigned int
68799 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68800 +{
68801 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68802 +}
68803 +
68804 +static __inline__ unsigned int
68805 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68806 +{
68807 + return full_name_hash((const unsigned char *)name, len) % sz;
68808 +}
68809 +
68810 +#define FOR_EACH_ROLE_START(role) \
68811 + role = role_list; \
68812 + while (role) {
68813 +
68814 +#define FOR_EACH_ROLE_END(role) \
68815 + role = role->prev; \
68816 + }
68817 +
68818 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68819 + subj = NULL; \
68820 + iter = 0; \
68821 + while (iter < role->subj_hash_size) { \
68822 + if (subj == NULL) \
68823 + subj = role->subj_hash[iter]; \
68824 + if (subj == NULL) { \
68825 + iter++; \
68826 + continue; \
68827 + }
68828 +
68829 +#define FOR_EACH_SUBJECT_END(subj,iter) \
68830 + subj = subj->next; \
68831 + if (subj == NULL) \
68832 + iter++; \
68833 + }
68834 +
68835 +
68836 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68837 + subj = role->hash->first; \
68838 + while (subj != NULL) {
68839 +
68840 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68841 + subj = subj->next; \
68842 + }
68843 +
68844 +#endif
68845 +
68846 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68847 new file mode 100644
68848 index 0000000..323ecf2
68849 --- /dev/null
68850 +++ b/include/linux/gralloc.h
68851 @@ -0,0 +1,9 @@
68852 +#ifndef __GRALLOC_H
68853 +#define __GRALLOC_H
68854 +
68855 +void acl_free_all(void);
68856 +int acl_alloc_stack_init(unsigned long size);
68857 +void *acl_alloc(unsigned long len);
68858 +void *acl_alloc_num(unsigned long num, unsigned long len);
68859 +
68860 +#endif
68861 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68862 new file mode 100644
68863 index 0000000..be66033
68864 --- /dev/null
68865 +++ b/include/linux/grdefs.h
68866 @@ -0,0 +1,140 @@
68867 +#ifndef GRDEFS_H
68868 +#define GRDEFS_H
68869 +
68870 +/* Begin grsecurity status declarations */
68871 +
68872 +enum {
68873 + GR_READY = 0x01,
68874 + GR_STATUS_INIT = 0x00 // disabled state
68875 +};
68876 +
68877 +/* Begin ACL declarations */
68878 +
68879 +/* Role flags */
68880 +
68881 +enum {
68882 + GR_ROLE_USER = 0x0001,
68883 + GR_ROLE_GROUP = 0x0002,
68884 + GR_ROLE_DEFAULT = 0x0004,
68885 + GR_ROLE_SPECIAL = 0x0008,
68886 + GR_ROLE_AUTH = 0x0010,
68887 + GR_ROLE_NOPW = 0x0020,
68888 + GR_ROLE_GOD = 0x0040,
68889 + GR_ROLE_LEARN = 0x0080,
68890 + GR_ROLE_TPE = 0x0100,
68891 + GR_ROLE_DOMAIN = 0x0200,
68892 + GR_ROLE_PAM = 0x0400,
68893 + GR_ROLE_PERSIST = 0x0800
68894 +};
68895 +
68896 +/* ACL Subject and Object mode flags */
68897 +enum {
68898 + GR_DELETED = 0x80000000
68899 +};
68900 +
68901 +/* ACL Object-only mode flags */
68902 +enum {
68903 + GR_READ = 0x00000001,
68904 + GR_APPEND = 0x00000002,
68905 + GR_WRITE = 0x00000004,
68906 + GR_EXEC = 0x00000008,
68907 + GR_FIND = 0x00000010,
68908 + GR_INHERIT = 0x00000020,
68909 + GR_SETID = 0x00000040,
68910 + GR_CREATE = 0x00000080,
68911 + GR_DELETE = 0x00000100,
68912 + GR_LINK = 0x00000200,
68913 + GR_AUDIT_READ = 0x00000400,
68914 + GR_AUDIT_APPEND = 0x00000800,
68915 + GR_AUDIT_WRITE = 0x00001000,
68916 + GR_AUDIT_EXEC = 0x00002000,
68917 + GR_AUDIT_FIND = 0x00004000,
68918 + GR_AUDIT_INHERIT= 0x00008000,
68919 + GR_AUDIT_SETID = 0x00010000,
68920 + GR_AUDIT_CREATE = 0x00020000,
68921 + GR_AUDIT_DELETE = 0x00040000,
68922 + GR_AUDIT_LINK = 0x00080000,
68923 + GR_PTRACERD = 0x00100000,
68924 + GR_NOPTRACE = 0x00200000,
68925 + GR_SUPPRESS = 0x00400000,
68926 + GR_NOLEARN = 0x00800000,
68927 + GR_INIT_TRANSFER= 0x01000000
68928 +};
68929 +
68930 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
68931 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
68932 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
68933 +
68934 +/* ACL subject-only mode flags */
68935 +enum {
68936 + GR_KILL = 0x00000001,
68937 + GR_VIEW = 0x00000002,
68938 + GR_PROTECTED = 0x00000004,
68939 + GR_LEARN = 0x00000008,
68940 + GR_OVERRIDE = 0x00000010,
68941 + /* just a placeholder, this mode is only used in userspace */
68942 + GR_DUMMY = 0x00000020,
68943 + GR_PROTSHM = 0x00000040,
68944 + GR_KILLPROC = 0x00000080,
68945 + GR_KILLIPPROC = 0x00000100,
68946 + /* just a placeholder, this mode is only used in userspace */
68947 + GR_NOTROJAN = 0x00000200,
68948 + GR_PROTPROCFD = 0x00000400,
68949 + GR_PROCACCT = 0x00000800,
68950 + GR_RELAXPTRACE = 0x00001000,
68951 + //GR_NESTED = 0x00002000,
68952 + GR_INHERITLEARN = 0x00004000,
68953 + GR_PROCFIND = 0x00008000,
68954 + GR_POVERRIDE = 0x00010000,
68955 + GR_KERNELAUTH = 0x00020000,
68956 + GR_ATSECURE = 0x00040000,
68957 + GR_SHMEXEC = 0x00080000
68958 +};
68959 +
68960 +enum {
68961 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
68962 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
68963 + GR_PAX_ENABLE_MPROTECT = 0x0004,
68964 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
68965 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
68966 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
68967 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
68968 + GR_PAX_DISABLE_MPROTECT = 0x0400,
68969 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
68970 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
68971 +};
68972 +
68973 +enum {
68974 + GR_ID_USER = 0x01,
68975 + GR_ID_GROUP = 0x02,
68976 +};
68977 +
68978 +enum {
68979 + GR_ID_ALLOW = 0x01,
68980 + GR_ID_DENY = 0x02,
68981 +};
68982 +
68983 +#define GR_CRASH_RES 31
68984 +#define GR_UIDTABLE_MAX 500
68985 +
68986 +/* begin resource learning section */
68987 +enum {
68988 + GR_RLIM_CPU_BUMP = 60,
68989 + GR_RLIM_FSIZE_BUMP = 50000,
68990 + GR_RLIM_DATA_BUMP = 10000,
68991 + GR_RLIM_STACK_BUMP = 1000,
68992 + GR_RLIM_CORE_BUMP = 10000,
68993 + GR_RLIM_RSS_BUMP = 500000,
68994 + GR_RLIM_NPROC_BUMP = 1,
68995 + GR_RLIM_NOFILE_BUMP = 5,
68996 + GR_RLIM_MEMLOCK_BUMP = 50000,
68997 + GR_RLIM_AS_BUMP = 500000,
68998 + GR_RLIM_LOCKS_BUMP = 2,
68999 + GR_RLIM_SIGPENDING_BUMP = 5,
69000 + GR_RLIM_MSGQUEUE_BUMP = 10000,
69001 + GR_RLIM_NICE_BUMP = 1,
69002 + GR_RLIM_RTPRIO_BUMP = 1,
69003 + GR_RLIM_RTTIME_BUMP = 1000000
69004 +};
69005 +
69006 +#endif
69007 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
69008 new file mode 100644
69009 index 0000000..9bb6662
69010 --- /dev/null
69011 +++ b/include/linux/grinternal.h
69012 @@ -0,0 +1,215 @@
69013 +#ifndef __GRINTERNAL_H
69014 +#define __GRINTERNAL_H
69015 +
69016 +#ifdef CONFIG_GRKERNSEC
69017 +
69018 +#include <linux/fs.h>
69019 +#include <linux/mnt_namespace.h>
69020 +#include <linux/nsproxy.h>
69021 +#include <linux/gracl.h>
69022 +#include <linux/grdefs.h>
69023 +#include <linux/grmsg.h>
69024 +
69025 +void gr_add_learn_entry(const char *fmt, ...)
69026 + __attribute__ ((format (printf, 1, 2)));
69027 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
69028 + const struct vfsmount *mnt);
69029 +__u32 gr_check_create(const struct dentry *new_dentry,
69030 + const struct dentry *parent,
69031 + const struct vfsmount *mnt, const __u32 mode);
69032 +int gr_check_protected_task(const struct task_struct *task);
69033 +__u32 to_gr_audit(const __u32 reqmode);
69034 +int gr_set_acls(const int type);
69035 +int gr_apply_subject_to_task(struct task_struct *task);
69036 +int gr_acl_is_enabled(void);
69037 +char gr_roletype_to_char(void);
69038 +
69039 +void gr_handle_alertkill(struct task_struct *task);
69040 +char *gr_to_filename(const struct dentry *dentry,
69041 + const struct vfsmount *mnt);
69042 +char *gr_to_filename1(const struct dentry *dentry,
69043 + const struct vfsmount *mnt);
69044 +char *gr_to_filename2(const struct dentry *dentry,
69045 + const struct vfsmount *mnt);
69046 +char *gr_to_filename3(const struct dentry *dentry,
69047 + const struct vfsmount *mnt);
69048 +
69049 +extern int grsec_enable_ptrace_readexec;
69050 +extern int grsec_enable_harden_ptrace;
69051 +extern int grsec_enable_link;
69052 +extern int grsec_enable_fifo;
69053 +extern int grsec_enable_execve;
69054 +extern int grsec_enable_shm;
69055 +extern int grsec_enable_execlog;
69056 +extern int grsec_enable_signal;
69057 +extern int grsec_enable_audit_ptrace;
69058 +extern int grsec_enable_forkfail;
69059 +extern int grsec_enable_time;
69060 +extern int grsec_enable_rofs;
69061 +extern int grsec_enable_chroot_shmat;
69062 +extern int grsec_enable_chroot_mount;
69063 +extern int grsec_enable_chroot_double;
69064 +extern int grsec_enable_chroot_pivot;
69065 +extern int grsec_enable_chroot_chdir;
69066 +extern int grsec_enable_chroot_chmod;
69067 +extern int grsec_enable_chroot_mknod;
69068 +extern int grsec_enable_chroot_fchdir;
69069 +extern int grsec_enable_chroot_nice;
69070 +extern int grsec_enable_chroot_execlog;
69071 +extern int grsec_enable_chroot_caps;
69072 +extern int grsec_enable_chroot_sysctl;
69073 +extern int grsec_enable_chroot_unix;
69074 +extern int grsec_enable_symlinkown;
69075 +extern kgid_t grsec_symlinkown_gid;
69076 +extern int grsec_enable_tpe;
69077 +extern kgid_t grsec_tpe_gid;
69078 +extern int grsec_enable_tpe_all;
69079 +extern int grsec_enable_tpe_invert;
69080 +extern int grsec_enable_socket_all;
69081 +extern kgid_t grsec_socket_all_gid;
69082 +extern int grsec_enable_socket_client;
69083 +extern kgid_t grsec_socket_client_gid;
69084 +extern int grsec_enable_socket_server;
69085 +extern kgid_t grsec_socket_server_gid;
69086 +extern kgid_t grsec_audit_gid;
69087 +extern int grsec_enable_group;
69088 +extern int grsec_enable_audit_textrel;
69089 +extern int grsec_enable_log_rwxmaps;
69090 +extern int grsec_enable_mount;
69091 +extern int grsec_enable_chdir;
69092 +extern int grsec_resource_logging;
69093 +extern int grsec_enable_blackhole;
69094 +extern int grsec_lastack_retries;
69095 +extern int grsec_enable_brute;
69096 +extern int grsec_lock;
69097 +
69098 +extern spinlock_t grsec_alert_lock;
69099 +extern unsigned long grsec_alert_wtime;
69100 +extern unsigned long grsec_alert_fyet;
69101 +
69102 +extern spinlock_t grsec_audit_lock;
69103 +
69104 +extern rwlock_t grsec_exec_file_lock;
69105 +
69106 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
69107 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
69108 + (tsk)->exec_file->f_vfsmnt) : "/")
69109 +
69110 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
69111 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
69112 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69113 +
69114 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
69115 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
69116 + (tsk)->exec_file->f_vfsmnt) : "/")
69117 +
69118 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
69119 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
69120 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69121 +
69122 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
69123 +
69124 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
69125 +
69126 +#define GR_CHROOT_CAPS {{ \
69127 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
69128 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
69129 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
69130 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
69131 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
69132 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
69133 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
69134 +
69135 +#define security_learn(normal_msg,args...) \
69136 +({ \
69137 + read_lock(&grsec_exec_file_lock); \
69138 + gr_add_learn_entry(normal_msg "\n", ## args); \
69139 + read_unlock(&grsec_exec_file_lock); \
69140 +})
69141 +
69142 +enum {
69143 + GR_DO_AUDIT,
69144 + GR_DONT_AUDIT,
69145 + /* used for non-audit messages that we shouldn't kill the task on */
69146 + GR_DONT_AUDIT_GOOD
69147 +};
69148 +
69149 +enum {
69150 + GR_TTYSNIFF,
69151 + GR_RBAC,
69152 + GR_RBAC_STR,
69153 + GR_STR_RBAC,
69154 + GR_RBAC_MODE2,
69155 + GR_RBAC_MODE3,
69156 + GR_FILENAME,
69157 + GR_SYSCTL_HIDDEN,
69158 + GR_NOARGS,
69159 + GR_ONE_INT,
69160 + GR_ONE_INT_TWO_STR,
69161 + GR_ONE_STR,
69162 + GR_STR_INT,
69163 + GR_TWO_STR_INT,
69164 + GR_TWO_INT,
69165 + GR_TWO_U64,
69166 + GR_THREE_INT,
69167 + GR_FIVE_INT_TWO_STR,
69168 + GR_TWO_STR,
69169 + GR_THREE_STR,
69170 + GR_FOUR_STR,
69171 + GR_STR_FILENAME,
69172 + GR_FILENAME_STR,
69173 + GR_FILENAME_TWO_INT,
69174 + GR_FILENAME_TWO_INT_STR,
69175 + GR_TEXTREL,
69176 + GR_PTRACE,
69177 + GR_RESOURCE,
69178 + GR_CAP,
69179 + GR_SIG,
69180 + GR_SIG2,
69181 + GR_CRASH1,
69182 + GR_CRASH2,
69183 + GR_PSACCT,
69184 + GR_RWXMAP
69185 +};
69186 +
69187 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69188 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69189 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69190 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69191 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69192 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69193 +#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)
69194 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69195 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69196 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69197 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69198 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69199 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69200 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69201 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69202 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69203 +#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)
69204 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69205 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69206 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69207 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69208 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69209 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69210 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69211 +#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)
69212 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69213 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69214 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69215 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69216 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69217 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69218 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69219 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69220 +#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)
69221 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69222 +
69223 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69224 +
69225 +#endif
69226 +
69227 +#endif
69228 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69229 new file mode 100644
69230 index 0000000..2bd4c8d
69231 --- /dev/null
69232 +++ b/include/linux/grmsg.h
69233 @@ -0,0 +1,111 @@
69234 +#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"
69235 +#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"
69236 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69237 +#define GR_STOPMOD_MSG "denied modification of module state by "
69238 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69239 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69240 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69241 +#define GR_IOPL_MSG "denied use of iopl() by "
69242 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69243 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69244 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69245 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69246 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69247 +#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"
69248 +#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"
69249 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69250 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69251 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69252 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69253 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69254 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69255 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69256 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69257 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69258 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69259 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69260 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69261 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69262 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69263 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69264 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69265 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69266 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69267 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69268 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69269 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69270 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69271 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69272 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69273 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69274 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69275 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69276 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69277 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69278 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69279 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69280 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69281 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69282 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69283 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69284 +#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"
69285 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69286 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69287 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69288 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69289 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69290 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69291 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69292 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69293 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69294 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69295 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69296 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69297 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69298 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69299 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69300 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69301 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69302 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69303 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69304 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69305 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69306 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69307 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69308 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69309 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69310 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69311 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69312 +#define GR_TIME_MSG "time set by "
69313 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69314 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69315 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69316 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69317 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69318 +#define GR_BIND_MSG "denied bind() by "
69319 +#define GR_CONNECT_MSG "denied connect() by "
69320 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69321 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69322 +#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"
69323 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
69324 +#define GR_CAP_ACL_MSG "use of %s denied for "
69325 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
69326 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
69327 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
69328 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
69329 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
69330 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
69331 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
69332 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
69333 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
69334 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
69335 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
69336 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
69337 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69338 +#define GR_VM86_MSG "denied use of vm86 by "
69339 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69340 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69341 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69342 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69343 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69344 +#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 "
69345 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69346 new file mode 100644
69347 index 0000000..8da63a4
69348 --- /dev/null
69349 +++ b/include/linux/grsecurity.h
69350 @@ -0,0 +1,242 @@
69351 +#ifndef GR_SECURITY_H
69352 +#define GR_SECURITY_H
69353 +#include <linux/fs.h>
69354 +#include <linux/fs_struct.h>
69355 +#include <linux/binfmts.h>
69356 +#include <linux/gracl.h>
69357 +
69358 +/* notify of brain-dead configs */
69359 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69360 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69361 +#endif
69362 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69363 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69364 +#endif
69365 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69366 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69367 +#endif
69368 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69369 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69370 +#endif
69371 +
69372 +void gr_handle_brute_attach(unsigned long mm_flags);
69373 +void gr_handle_brute_check(void);
69374 +void gr_handle_kernel_exploit(void);
69375 +int gr_process_user_ban(void);
69376 +
69377 +char gr_roletype_to_char(void);
69378 +
69379 +int gr_acl_enable_at_secure(void);
69380 +
69381 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69382 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69383 +
69384 +void gr_del_task_from_ip_table(struct task_struct *p);
69385 +
69386 +int gr_pid_is_chrooted(struct task_struct *p);
69387 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69388 +int gr_handle_chroot_nice(void);
69389 +int gr_handle_chroot_sysctl(const int op);
69390 +int gr_handle_chroot_setpriority(struct task_struct *p,
69391 + const int niceval);
69392 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69393 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69394 + const struct vfsmount *mnt);
69395 +void gr_handle_chroot_chdir(struct path *path);
69396 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69397 + const struct vfsmount *mnt, const int mode);
69398 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69399 + const struct vfsmount *mnt, const int mode);
69400 +int gr_handle_chroot_mount(const struct dentry *dentry,
69401 + const struct vfsmount *mnt,
69402 + const char *dev_name);
69403 +int gr_handle_chroot_pivot(void);
69404 +int gr_handle_chroot_unix(const pid_t pid);
69405 +
69406 +int gr_handle_rawio(const struct inode *inode);
69407 +
69408 +void gr_handle_ioperm(void);
69409 +void gr_handle_iopl(void);
69410 +
69411 +umode_t gr_acl_umask(void);
69412 +
69413 +int gr_tpe_allow(const struct file *file);
69414 +
69415 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
69416 +void gr_clear_chroot_entries(struct task_struct *task);
69417 +
69418 +void gr_log_forkfail(const int retval);
69419 +void gr_log_timechange(void);
69420 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69421 +void gr_log_chdir(const struct dentry *dentry,
69422 + const struct vfsmount *mnt);
69423 +void gr_log_chroot_exec(const struct dentry *dentry,
69424 + const struct vfsmount *mnt);
69425 +void gr_log_remount(const char *devname, const int retval);
69426 +void gr_log_unmount(const char *devname, const int retval);
69427 +void gr_log_mount(const char *from, const char *to, const int retval);
69428 +void gr_log_textrel(struct vm_area_struct *vma);
69429 +void gr_log_rwxmmap(struct file *file);
69430 +void gr_log_rwxmprotect(struct file *file);
69431 +
69432 +int gr_handle_follow_link(const struct inode *parent,
69433 + const struct inode *inode,
69434 + const struct dentry *dentry,
69435 + const struct vfsmount *mnt);
69436 +int gr_handle_fifo(const struct dentry *dentry,
69437 + const struct vfsmount *mnt,
69438 + const struct dentry *dir, const int flag,
69439 + const int acc_mode);
69440 +int gr_handle_hardlink(const struct dentry *dentry,
69441 + const struct vfsmount *mnt,
69442 + struct inode *inode,
69443 + const int mode, const struct filename *to);
69444 +
69445 +int gr_is_capable(const int cap);
69446 +int gr_is_capable_nolog(const int cap);
69447 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69448 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69449 +
69450 +void gr_copy_label(struct task_struct *tsk);
69451 +void gr_handle_crash(struct task_struct *task, const int sig);
69452 +int gr_handle_signal(const struct task_struct *p, const int sig);
69453 +int gr_check_crash_uid(const kuid_t uid);
69454 +int gr_check_protected_task(const struct task_struct *task);
69455 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69456 +int gr_acl_handle_mmap(const struct file *file,
69457 + const unsigned long prot);
69458 +int gr_acl_handle_mprotect(const struct file *file,
69459 + const unsigned long prot);
69460 +int gr_check_hidden_task(const struct task_struct *tsk);
69461 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69462 + const struct vfsmount *mnt);
69463 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69464 + const struct vfsmount *mnt);
69465 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69466 + const struct vfsmount *mnt, const int fmode);
69467 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69468 + const struct vfsmount *mnt, umode_t *mode);
69469 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69470 + const struct vfsmount *mnt);
69471 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69472 + const struct vfsmount *mnt);
69473 +int gr_handle_ptrace(struct task_struct *task, const long request);
69474 +int gr_handle_proc_ptrace(struct task_struct *task);
69475 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69476 + const struct vfsmount *mnt);
69477 +int gr_check_crash_exec(const struct file *filp);
69478 +int gr_acl_is_enabled(void);
69479 +void gr_set_kernel_label(struct task_struct *task);
69480 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69481 + const kgid_t gid);
69482 +int gr_set_proc_label(const struct dentry *dentry,
69483 + const struct vfsmount *mnt,
69484 + const int unsafe_flags);
69485 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69486 + const struct vfsmount *mnt);
69487 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69488 + const struct vfsmount *mnt, int acc_mode);
69489 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69490 + const struct dentry *p_dentry,
69491 + const struct vfsmount *p_mnt,
69492 + int open_flags, int acc_mode, const int imode);
69493 +void gr_handle_create(const struct dentry *dentry,
69494 + const struct vfsmount *mnt);
69495 +void gr_handle_proc_create(const struct dentry *dentry,
69496 + const struct inode *inode);
69497 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69498 + const struct dentry *parent_dentry,
69499 + const struct vfsmount *parent_mnt,
69500 + const int mode);
69501 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69502 + const struct dentry *parent_dentry,
69503 + const struct vfsmount *parent_mnt);
69504 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69505 + const struct vfsmount *mnt);
69506 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69507 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69508 + const struct vfsmount *mnt);
69509 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69510 + const struct dentry *parent_dentry,
69511 + const struct vfsmount *parent_mnt,
69512 + const struct filename *from);
69513 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69514 + const struct dentry *parent_dentry,
69515 + const struct vfsmount *parent_mnt,
69516 + const struct dentry *old_dentry,
69517 + const struct vfsmount *old_mnt, const struct filename *to);
69518 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69519 +int gr_acl_handle_rename(struct dentry *new_dentry,
69520 + struct dentry *parent_dentry,
69521 + const struct vfsmount *parent_mnt,
69522 + struct dentry *old_dentry,
69523 + struct inode *old_parent_inode,
69524 + struct vfsmount *old_mnt, const struct filename *newname);
69525 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69526 + struct dentry *old_dentry,
69527 + struct dentry *new_dentry,
69528 + struct vfsmount *mnt, const __u8 replace);
69529 +__u32 gr_check_link(const struct dentry *new_dentry,
69530 + const struct dentry *parent_dentry,
69531 + const struct vfsmount *parent_mnt,
69532 + const struct dentry *old_dentry,
69533 + const struct vfsmount *old_mnt);
69534 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69535 + const unsigned int namelen, const ino_t ino);
69536 +
69537 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69538 + const struct vfsmount *mnt);
69539 +void gr_acl_handle_exit(void);
69540 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69541 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69542 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69543 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69544 +void gr_audit_ptrace(struct task_struct *task);
69545 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69546 +void gr_put_exec_file(struct task_struct *task);
69547 +
69548 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69549 +
69550 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69551 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69552 + const unsigned long wanted, const int gt);
69553 +#else
69554 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69555 + const unsigned long wanted, const int gt)
69556 +{
69557 +}
69558 +#endif
69559 +
69560 +#ifdef CONFIG_GRKERNSEC_RESLOG
69561 +extern void gr_log_resource(const struct task_struct *task, const int res,
69562 + const unsigned long wanted, const int gt);
69563 +#else
69564 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69565 + const unsigned long wanted, const int gt)
69566 +{
69567 +}
69568 +#endif
69569 +
69570 +#ifdef CONFIG_GRKERNSEC
69571 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69572 +void gr_handle_vm86(void);
69573 +void gr_handle_mem_readwrite(u64 from, u64 to);
69574 +
69575 +void gr_log_badprocpid(const char *entry);
69576 +
69577 +extern int grsec_enable_dmesg;
69578 +extern int grsec_disable_privio;
69579 +
69580 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69581 +extern kgid_t grsec_proc_gid;
69582 +#endif
69583 +
69584 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69585 +extern int grsec_enable_chroot_findtask;
69586 +#endif
69587 +#ifdef CONFIG_GRKERNSEC_SETXID
69588 +extern int grsec_enable_setxid;
69589 +#endif
69590 +#endif
69591 +
69592 +#endif
69593 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69594 new file mode 100644
69595 index 0000000..e7ffaaf
69596 --- /dev/null
69597 +++ b/include/linux/grsock.h
69598 @@ -0,0 +1,19 @@
69599 +#ifndef __GRSOCK_H
69600 +#define __GRSOCK_H
69601 +
69602 +extern void gr_attach_curr_ip(const struct sock *sk);
69603 +extern int gr_handle_sock_all(const int family, const int type,
69604 + const int protocol);
69605 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69606 +extern int gr_handle_sock_server_other(const struct sock *sck);
69607 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69608 +extern int gr_search_connect(struct socket * sock,
69609 + struct sockaddr_in * addr);
69610 +extern int gr_search_bind(struct socket * sock,
69611 + struct sockaddr_in * addr);
69612 +extern int gr_search_listen(struct socket * sock);
69613 +extern int gr_search_accept(struct socket * sock);
69614 +extern int gr_search_socket(const int domain, const int type,
69615 + const int protocol);
69616 +
69617 +#endif
69618 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69619 index ef788b5..ac41b7b 100644
69620 --- a/include/linux/highmem.h
69621 +++ b/include/linux/highmem.h
69622 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69623 kunmap_atomic(kaddr);
69624 }
69625
69626 +static inline void sanitize_highpage(struct page *page)
69627 +{
69628 + void *kaddr;
69629 + unsigned long flags;
69630 +
69631 + local_irq_save(flags);
69632 + kaddr = kmap_atomic(page);
69633 + clear_page(kaddr);
69634 + kunmap_atomic(kaddr);
69635 + local_irq_restore(flags);
69636 +}
69637 +
69638 static inline void zero_user_segments(struct page *page,
69639 unsigned start1, unsigned end1,
69640 unsigned start2, unsigned end2)
69641 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69642 index 1c7b89a..7f52502 100644
69643 --- a/include/linux/hwmon-sysfs.h
69644 +++ b/include/linux/hwmon-sysfs.h
69645 @@ -25,7 +25,8 @@
69646 struct sensor_device_attribute{
69647 struct device_attribute dev_attr;
69648 int index;
69649 -};
69650 +} __do_const;
69651 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69652 #define to_sensor_dev_attr(_dev_attr) \
69653 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69654
69655 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69656 struct device_attribute dev_attr;
69657 u8 index;
69658 u8 nr;
69659 -};
69660 +} __do_const;
69661 #define to_sensor_dev_attr_2(_dev_attr) \
69662 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69663
69664 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69665 index d0c4db7..61b3577 100644
69666 --- a/include/linux/i2c.h
69667 +++ b/include/linux/i2c.h
69668 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69669 /* To determine what the adapter supports */
69670 u32 (*functionality) (struct i2c_adapter *);
69671 };
69672 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69673
69674 /*
69675 * i2c_adapter is the structure used to identify a physical i2c bus along
69676 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69677 index d23c3c2..eb63c81 100644
69678 --- a/include/linux/i2o.h
69679 +++ b/include/linux/i2o.h
69680 @@ -565,7 +565,7 @@ struct i2o_controller {
69681 struct i2o_device *exec; /* Executive */
69682 #if BITS_PER_LONG == 64
69683 spinlock_t context_list_lock; /* lock for context_list */
69684 - atomic_t context_list_counter; /* needed for unique contexts */
69685 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69686 struct list_head context_list; /* list of context id's
69687 and pointers */
69688 #endif
69689 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69690 index aff7ad8..3942bbd 100644
69691 --- a/include/linux/if_pppox.h
69692 +++ b/include/linux/if_pppox.h
69693 @@ -76,7 +76,7 @@ struct pppox_proto {
69694 int (*ioctl)(struct socket *sock, unsigned int cmd,
69695 unsigned long arg);
69696 struct module *owner;
69697 -};
69698 +} __do_const;
69699
69700 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69701 extern void unregister_pppox_proto(int proto_num);
69702 diff --git a/include/linux/init.h b/include/linux/init.h
69703 index 10ed4f4..8e8490d 100644
69704 --- a/include/linux/init.h
69705 +++ b/include/linux/init.h
69706 @@ -39,9 +39,36 @@
69707 * Also note, that this data cannot be "const".
69708 */
69709
69710 +#ifdef MODULE
69711 +#define add_init_latent_entropy
69712 +#define add_devinit_latent_entropy
69713 +#define add_cpuinit_latent_entropy
69714 +#define add_meminit_latent_entropy
69715 +#else
69716 +#define add_init_latent_entropy __latent_entropy
69717 +
69718 +#ifdef CONFIG_HOTPLUG
69719 +#define add_devinit_latent_entropy
69720 +#else
69721 +#define add_devinit_latent_entropy __latent_entropy
69722 +#endif
69723 +
69724 +#ifdef CONFIG_HOTPLUG_CPU
69725 +#define add_cpuinit_latent_entropy
69726 +#else
69727 +#define add_cpuinit_latent_entropy __latent_entropy
69728 +#endif
69729 +
69730 +#ifdef CONFIG_MEMORY_HOTPLUG
69731 +#define add_meminit_latent_entropy
69732 +#else
69733 +#define add_meminit_latent_entropy __latent_entropy
69734 +#endif
69735 +#endif
69736 +
69737 /* These are for everybody (although not all archs will actually
69738 discard it in modules) */
69739 -#define __init __section(.init.text) __cold notrace
69740 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69741 #define __initdata __section(.init.data)
69742 #define __initconst __constsection(.init.rodata)
69743 #define __exitdata __section(.exit.data)
69744 @@ -94,7 +121,7 @@
69745 #define __exit __section(.exit.text) __exitused __cold notrace
69746
69747 /* Used for HOTPLUG_CPU */
69748 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69749 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69750 #define __cpuinitdata __section(.cpuinit.data)
69751 #define __cpuinitconst __constsection(.cpuinit.rodata)
69752 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69753 @@ -102,7 +129,7 @@
69754 #define __cpuexitconst __constsection(.cpuexit.rodata)
69755
69756 /* Used for MEMORY_HOTPLUG */
69757 -#define __meminit __section(.meminit.text) __cold notrace
69758 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69759 #define __meminitdata __section(.meminit.data)
69760 #define __meminitconst __constsection(.meminit.rodata)
69761 #define __memexit __section(.memexit.text) __exitused __cold notrace
69762 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69763 index 6d087c5..401cab8 100644
69764 --- a/include/linux/init_task.h
69765 +++ b/include/linux/init_task.h
69766 @@ -143,6 +143,12 @@ extern struct task_group root_task_group;
69767
69768 #define INIT_TASK_COMM "swapper"
69769
69770 +#ifdef CONFIG_X86
69771 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69772 +#else
69773 +#define INIT_TASK_THREAD_INFO
69774 +#endif
69775 +
69776 /*
69777 * INIT_TASK is used to set up the first task table, touch at
69778 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69779 @@ -182,6 +188,7 @@ extern struct task_group root_task_group;
69780 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69781 .comm = INIT_TASK_COMM, \
69782 .thread = INIT_THREAD, \
69783 + INIT_TASK_THREAD_INFO \
69784 .fs = &init_fs, \
69785 .files = &init_files, \
69786 .signal = &init_signals, \
69787 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69788 index 5fa5afe..ac55b25 100644
69789 --- a/include/linux/interrupt.h
69790 +++ b/include/linux/interrupt.h
69791 @@ -430,7 +430,7 @@ enum
69792 /* map softirq index to softirq name. update 'softirq_to_name' in
69793 * kernel/softirq.c when adding a new softirq.
69794 */
69795 -extern char *softirq_to_name[NR_SOFTIRQS];
69796 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69797
69798 /* softirq mask and active fields moved to irq_cpustat_t in
69799 * asm/hardirq.h to get better cache usage. KAO
69800 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69801
69802 struct softirq_action
69803 {
69804 - void (*action)(struct softirq_action *);
69805 -};
69806 + void (*action)(void);
69807 +} __no_const;
69808
69809 asmlinkage void do_softirq(void);
69810 asmlinkage void __do_softirq(void);
69811 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69812 +extern void open_softirq(int nr, void (*action)(void));
69813 extern void softirq_init(void);
69814 extern void __raise_softirq_irqoff(unsigned int nr);
69815
69816 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69817 index f3b99e1..9b73cee 100644
69818 --- a/include/linux/iommu.h
69819 +++ b/include/linux/iommu.h
69820 @@ -101,7 +101,7 @@ struct iommu_ops {
69821 int (*domain_set_attr)(struct iommu_domain *domain,
69822 enum iommu_attr attr, void *data);
69823 unsigned long pgsize_bitmap;
69824 -};
69825 +} __do_const;
69826
69827 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
69828 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
69829 diff --git a/include/linux/irq.h b/include/linux/irq.h
69830 index fdf2c4a..5332486 100644
69831 --- a/include/linux/irq.h
69832 +++ b/include/linux/irq.h
69833 @@ -328,7 +328,8 @@ struct irq_chip {
69834 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69835
69836 unsigned long flags;
69837 -};
69838 +} __do_const;
69839 +typedef struct irq_chip __no_const irq_chip_no_const;
69840
69841 /*
69842 * irq_chip specific flags
69843 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69844 index 6883e19..06992b1 100644
69845 --- a/include/linux/kallsyms.h
69846 +++ b/include/linux/kallsyms.h
69847 @@ -15,7 +15,8 @@
69848
69849 struct module;
69850
69851 -#ifdef CONFIG_KALLSYMS
69852 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69853 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69854 /* Lookup the address for a symbol. Returns 0 if not found. */
69855 unsigned long kallsyms_lookup_name(const char *name);
69856
69857 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69858 /* Stupid that this does nothing, but I didn't create this mess. */
69859 #define __print_symbol(fmt, addr)
69860 #endif /*CONFIG_KALLSYMS*/
69861 +#else /* when included by kallsyms.c, vsnprintf.c, or
69862 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69863 +extern void __print_symbol(const char *fmt, unsigned long address);
69864 +extern int sprint_backtrace(char *buffer, unsigned long address);
69865 +extern int sprint_symbol(char *buffer, unsigned long address);
69866 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69867 +const char *kallsyms_lookup(unsigned long addr,
69868 + unsigned long *symbolsize,
69869 + unsigned long *offset,
69870 + char **modname, char *namebuf);
69871 +#endif
69872
69873 /* This macro allows us to keep printk typechecking */
69874 static __printf(1, 2)
69875 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69876 index 518a53a..5e28358 100644
69877 --- a/include/linux/key-type.h
69878 +++ b/include/linux/key-type.h
69879 @@ -125,7 +125,7 @@ struct key_type {
69880 /* internal fields */
69881 struct list_head link; /* link in types list */
69882 struct lock_class_key lock_class; /* key->sem lock class */
69883 -};
69884 +} __do_const;
69885
69886 extern struct key_type key_type_keyring;
69887
69888 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
69889 index 4dff0c6..1ca9b72 100644
69890 --- a/include/linux/kgdb.h
69891 +++ b/include/linux/kgdb.h
69892 @@ -53,7 +53,7 @@ extern int kgdb_connected;
69893 extern int kgdb_io_module_registered;
69894
69895 extern atomic_t kgdb_setting_breakpoint;
69896 -extern atomic_t kgdb_cpu_doing_single_step;
69897 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
69898
69899 extern struct task_struct *kgdb_usethread;
69900 extern struct task_struct *kgdb_contthread;
69901 @@ -255,7 +255,7 @@ struct kgdb_arch {
69902 void (*correct_hw_break)(void);
69903
69904 void (*enable_nmi)(bool on);
69905 -};
69906 +} __do_const;
69907
69908 /**
69909 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
69910 @@ -280,7 +280,7 @@ struct kgdb_io {
69911 void (*pre_exception) (void);
69912 void (*post_exception) (void);
69913 int is_console;
69914 -};
69915 +} __do_const;
69916
69917 extern struct kgdb_arch arch_kgdb_ops;
69918
69919 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
69920 index 5398d58..5883a34 100644
69921 --- a/include/linux/kmod.h
69922 +++ b/include/linux/kmod.h
69923 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
69924 * usually useless though. */
69925 extern __printf(2, 3)
69926 int __request_module(bool wait, const char *name, ...);
69927 +extern __printf(3, 4)
69928 +int ___request_module(bool wait, char *param_name, const char *name, ...);
69929 #define request_module(mod...) __request_module(true, mod)
69930 #define request_module_nowait(mod...) __request_module(false, mod)
69931 #define try_then_request_module(x, mod...) \
69932 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
69933 index 939b112..ed6ed51 100644
69934 --- a/include/linux/kobject.h
69935 +++ b/include/linux/kobject.h
69936 @@ -111,7 +111,7 @@ struct kobj_type {
69937 struct attribute **default_attrs;
69938 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
69939 const void *(*namespace)(struct kobject *kobj);
69940 -};
69941 +} __do_const;
69942
69943 struct kobj_uevent_env {
69944 char *envp[UEVENT_NUM_ENVP];
69945 @@ -134,6 +134,7 @@ struct kobj_attribute {
69946 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
69947 const char *buf, size_t count);
69948 };
69949 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
69950
69951 extern const struct sysfs_ops kobj_sysfs_ops;
69952
69953 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
69954 index f66b065..c2c29b4 100644
69955 --- a/include/linux/kobject_ns.h
69956 +++ b/include/linux/kobject_ns.h
69957 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
69958 const void *(*netlink_ns)(struct sock *sk);
69959 const void *(*initial_ns)(void);
69960 void (*drop_ns)(void *);
69961 -};
69962 +} __do_const;
69963
69964 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
69965 int kobj_ns_type_registered(enum kobj_ns_type type);
69966 diff --git a/include/linux/kref.h b/include/linux/kref.h
69967 index 4972e6e..de4d19b 100644
69968 --- a/include/linux/kref.h
69969 +++ b/include/linux/kref.h
69970 @@ -64,7 +64,7 @@ static inline void kref_get(struct kref *kref)
69971 static inline int kref_sub(struct kref *kref, unsigned int count,
69972 void (*release)(struct kref *kref))
69973 {
69974 - WARN_ON(release == NULL);
69975 + BUG_ON(release == NULL);
69976
69977 if (atomic_sub_and_test((int) count, &kref->refcount)) {
69978 release(kref);
69979 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
69980 index 2c497ab..afe32f5 100644
69981 --- a/include/linux/kvm_host.h
69982 +++ b/include/linux/kvm_host.h
69983 @@ -418,7 +418,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
69984 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
69985 void vcpu_put(struct kvm_vcpu *vcpu);
69986
69987 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69988 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
69989 struct module *module);
69990 void kvm_exit(void);
69991
69992 @@ -574,7 +574,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
69993 struct kvm_guest_debug *dbg);
69994 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
69995
69996 -int kvm_arch_init(void *opaque);
69997 +int kvm_arch_init(const void *opaque);
69998 void kvm_arch_exit(void);
69999
70000 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
70001 diff --git a/include/linux/libata.h b/include/linux/libata.h
70002 index 0621bca..24d6851 100644
70003 --- a/include/linux/libata.h
70004 +++ b/include/linux/libata.h
70005 @@ -916,7 +916,7 @@ struct ata_port_operations {
70006 * fields must be pointers.
70007 */
70008 const struct ata_port_operations *inherits;
70009 -};
70010 +} __do_const;
70011
70012 struct ata_port_info {
70013 unsigned long flags;
70014 diff --git a/include/linux/list.h b/include/linux/list.h
70015 index cc6d2aa..c10ee83 100644
70016 --- a/include/linux/list.h
70017 +++ b/include/linux/list.h
70018 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
70019 extern void list_del(struct list_head *entry);
70020 #endif
70021
70022 +extern void __pax_list_add(struct list_head *new,
70023 + struct list_head *prev,
70024 + struct list_head *next);
70025 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
70026 +{
70027 + __pax_list_add(new, head, head->next);
70028 +}
70029 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
70030 +{
70031 + __pax_list_add(new, head->prev, head);
70032 +}
70033 +extern void pax_list_del(struct list_head *entry);
70034 +
70035 /**
70036 * list_replace - replace old entry by new one
70037 * @old : the element to be replaced
70038 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
70039 INIT_LIST_HEAD(entry);
70040 }
70041
70042 +extern void pax_list_del_init(struct list_head *entry);
70043 +
70044 /**
70045 * list_move - delete from one list and add as another's head
70046 * @list: the entry to move
70047 diff --git a/include/linux/math64.h b/include/linux/math64.h
70048 index b8ba855..0148090 100644
70049 --- a/include/linux/math64.h
70050 +++ b/include/linux/math64.h
70051 @@ -14,7 +14,7 @@
70052 * This is commonly provided by 32bit archs to provide an optimized 64bit
70053 * divide.
70054 */
70055 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70056 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70057 {
70058 *remainder = dividend % divisor;
70059 return dividend / divisor;
70060 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
70061 #define div64_long(x,y) div_s64((x),(y))
70062
70063 #ifndef div_u64_rem
70064 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70065 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70066 {
70067 *remainder = do_div(dividend, divisor);
70068 return dividend;
70069 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
70070 * divide.
70071 */
70072 #ifndef div_u64
70073 -static inline u64 div_u64(u64 dividend, u32 divisor)
70074 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
70075 {
70076 u32 remainder;
70077 return div_u64_rem(dividend, divisor, &remainder);
70078 diff --git a/include/linux/mm.h b/include/linux/mm.h
70079 index 66e2f7c..b916b9a 100644
70080 --- a/include/linux/mm.h
70081 +++ b/include/linux/mm.h
70082 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
70083 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
70084 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
70085 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
70086 +
70087 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
70088 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
70089 +#endif
70090 +
70091 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
70092
70093 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
70094 @@ -200,8 +205,8 @@ struct vm_operations_struct {
70095 /* called by access_process_vm when get_user_pages() fails, typically
70096 * for use by special VMAs that can switch between memory and hardware
70097 */
70098 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
70099 - void *buf, int len, int write);
70100 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
70101 + void *buf, size_t len, int write);
70102 #ifdef CONFIG_NUMA
70103 /*
70104 * set_policy() op must add a reference to any non-NULL @new mempolicy
70105 @@ -231,6 +236,7 @@ struct vm_operations_struct {
70106 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70107 unsigned long size, pgoff_t pgoff);
70108 };
70109 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70110
70111 struct mmu_gather;
70112 struct inode;
70113 @@ -995,8 +1001,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70114 unsigned long *pfn);
70115 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70116 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70117 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70118 - void *buf, int len, int write);
70119 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70120 + void *buf, size_t len, int write);
70121
70122 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70123 loff_t const holebegin, loff_t const holelen)
70124 @@ -1035,10 +1041,10 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70125 }
70126 #endif
70127
70128 -extern int make_pages_present(unsigned long addr, unsigned long end);
70129 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70130 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70131 - void *buf, int len, int write);
70132 +extern ssize_t make_pages_present(unsigned long addr, unsigned long end);
70133 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70134 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70135 + void *buf, size_t len, int write);
70136
70137 int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70138 unsigned long start, int len, unsigned int foll_flags,
70139 @@ -1068,34 +1074,6 @@ int set_page_dirty(struct page *page);
70140 int set_page_dirty_lock(struct page *page);
70141 int clear_page_dirty_for_io(struct page *page);
70142
70143 -/* Is the vma a continuation of the stack vma above it? */
70144 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70145 -{
70146 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70147 -}
70148 -
70149 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70150 - unsigned long addr)
70151 -{
70152 - return (vma->vm_flags & VM_GROWSDOWN) &&
70153 - (vma->vm_start == addr) &&
70154 - !vma_growsdown(vma->vm_prev, addr);
70155 -}
70156 -
70157 -/* Is the vma a continuation of the stack vma below it? */
70158 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70159 -{
70160 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70161 -}
70162 -
70163 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70164 - unsigned long addr)
70165 -{
70166 - return (vma->vm_flags & VM_GROWSUP) &&
70167 - (vma->vm_end == addr) &&
70168 - !vma_growsup(vma->vm_next, addr);
70169 -}
70170 -
70171 extern pid_t
70172 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70173
70174 @@ -1198,6 +1176,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70175 }
70176 #endif
70177
70178 +#ifdef CONFIG_MMU
70179 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70180 +#else
70181 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70182 +{
70183 + return __pgprot(0);
70184 +}
70185 +#endif
70186 +
70187 int vma_wants_writenotify(struct vm_area_struct *vma);
70188
70189 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70190 @@ -1216,8 +1203,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70191 {
70192 return 0;
70193 }
70194 +
70195 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70196 + unsigned long address)
70197 +{
70198 + return 0;
70199 +}
70200 #else
70201 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70202 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70203 #endif
70204
70205 #ifdef __PAGETABLE_PMD_FOLDED
70206 @@ -1226,8 +1220,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70207 {
70208 return 0;
70209 }
70210 +
70211 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70212 + unsigned long address)
70213 +{
70214 + return 0;
70215 +}
70216 #else
70217 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70218 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70219 #endif
70220
70221 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70222 @@ -1245,11 +1246,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70223 NULL: pud_offset(pgd, address);
70224 }
70225
70226 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70227 +{
70228 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70229 + NULL: pud_offset(pgd, address);
70230 +}
70231 +
70232 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70233 {
70234 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70235 NULL: pmd_offset(pud, address);
70236 }
70237 +
70238 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70239 +{
70240 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70241 + NULL: pmd_offset(pud, address);
70242 +}
70243 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70244
70245 #if USE_SPLIT_PTLOCKS
70246 @@ -1479,6 +1492,7 @@ extern unsigned long do_mmap_pgoff(struct file *, unsigned long,
70247 unsigned long, unsigned long,
70248 unsigned long, unsigned long);
70249 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70250 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70251
70252 /* These take the mm semaphore themselves */
70253 extern unsigned long vm_brk(unsigned long, unsigned long);
70254 @@ -1573,6 +1587,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70255 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70256 struct vm_area_struct **pprev);
70257
70258 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70259 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70260 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70261 +
70262 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70263 NULL if none. Assume start_addr < end_addr. */
70264 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70265 @@ -1601,15 +1619,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70266 return vma;
70267 }
70268
70269 -#ifdef CONFIG_MMU
70270 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70271 -#else
70272 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70273 -{
70274 - return __pgprot(0);
70275 -}
70276 -#endif
70277 -
70278 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70279 unsigned long change_prot_numa(struct vm_area_struct *vma,
70280 unsigned long start, unsigned long end);
70281 @@ -1649,6 +1658,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70282 static inline void vm_stat_account(struct mm_struct *mm,
70283 unsigned long flags, struct file *file, long pages)
70284 {
70285 +
70286 +#ifdef CONFIG_PAX_RANDMMAP
70287 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70288 +#endif
70289 +
70290 mm->total_vm += pages;
70291 }
70292 #endif /* CONFIG_PROC_FS */
70293 @@ -1721,7 +1735,7 @@ extern int unpoison_memory(unsigned long pfn);
70294 extern int sysctl_memory_failure_early_kill;
70295 extern int sysctl_memory_failure_recovery;
70296 extern void shake_page(struct page *p, int access);
70297 -extern atomic_long_t mce_bad_pages;
70298 +extern atomic_long_unchecked_t mce_bad_pages;
70299 extern int soft_offline_page(struct page *page, int flags);
70300
70301 extern void dump_page(struct page *page);
70302 @@ -1752,5 +1766,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
70303 static inline bool page_is_guard(struct page *page) { return false; }
70304 #endif /* CONFIG_DEBUG_PAGEALLOC */
70305
70306 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70307 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70308 +#else
70309 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70310 +#endif
70311 +
70312 #endif /* __KERNEL__ */
70313 #endif /* _LINUX_MM_H */
70314 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
70315 index f8f5162..3aaf20f 100644
70316 --- a/include/linux/mm_types.h
70317 +++ b/include/linux/mm_types.h
70318 @@ -288,6 +288,8 @@ struct vm_area_struct {
70319 #ifdef CONFIG_NUMA
70320 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
70321 #endif
70322 +
70323 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
70324 };
70325
70326 struct core_thread {
70327 @@ -436,6 +438,24 @@ struct mm_struct {
70328 int first_nid;
70329 #endif
70330 struct uprobes_state uprobes_state;
70331 +
70332 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70333 + unsigned long pax_flags;
70334 +#endif
70335 +
70336 +#ifdef CONFIG_PAX_DLRESOLVE
70337 + unsigned long call_dl_resolve;
70338 +#endif
70339 +
70340 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70341 + unsigned long call_syscall;
70342 +#endif
70343 +
70344 +#ifdef CONFIG_PAX_ASLR
70345 + unsigned long delta_mmap; /* randomized offset */
70346 + unsigned long delta_stack; /* randomized offset */
70347 +#endif
70348 +
70349 };
70350
70351 /* first nid will either be a valid NID or one of these values */
70352 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70353 index c5d5278..f0b68c8 100644
70354 --- a/include/linux/mmiotrace.h
70355 +++ b/include/linux/mmiotrace.h
70356 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70357 /* Called from ioremap.c */
70358 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70359 void __iomem *addr);
70360 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70361 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70362
70363 /* For anyone to insert markers. Remember trailing newline. */
70364 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70365 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70366 {
70367 }
70368
70369 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70370 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70371 {
70372 }
70373
70374 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70375 index 73b64a3..6562925 100644
70376 --- a/include/linux/mmzone.h
70377 +++ b/include/linux/mmzone.h
70378 @@ -412,7 +412,7 @@ struct zone {
70379 unsigned long flags; /* zone flags, see below */
70380
70381 /* Zone statistics */
70382 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70383 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70384
70385 /*
70386 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70387 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70388 index fed3def..c933f99 100644
70389 --- a/include/linux/mod_devicetable.h
70390 +++ b/include/linux/mod_devicetable.h
70391 @@ -12,7 +12,7 @@
70392 typedef unsigned long kernel_ulong_t;
70393 #endif
70394
70395 -#define PCI_ANY_ID (~0)
70396 +#define PCI_ANY_ID ((__u16)~0)
70397
70398 struct pci_device_id {
70399 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70400 @@ -139,7 +139,7 @@ struct usb_device_id {
70401 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70402 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70403
70404 -#define HID_ANY_ID (~0)
70405 +#define HID_ANY_ID (~0U)
70406 #define HID_BUS_ANY 0xffff
70407 #define HID_GROUP_ANY 0x0000
70408
70409 @@ -498,7 +498,7 @@ struct dmi_system_id {
70410 const char *ident;
70411 struct dmi_strmatch matches[4];
70412 void *driver_data;
70413 -};
70414 +} __do_const;
70415 /*
70416 * struct dmi_device_id appears during expansion of
70417 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70418 diff --git a/include/linux/module.h b/include/linux/module.h
70419 index 1375ee3..ced8177 100644
70420 --- a/include/linux/module.h
70421 +++ b/include/linux/module.h
70422 @@ -17,9 +17,11 @@
70423 #include <linux/moduleparam.h>
70424 #include <linux/tracepoint.h>
70425 #include <linux/export.h>
70426 +#include <linux/fs.h>
70427
70428 #include <linux/percpu.h>
70429 #include <asm/module.h>
70430 +#include <asm/pgtable.h>
70431
70432 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70433 #define MODULE_SIG_STRING "~Module signature appended~\n"
70434 @@ -54,12 +56,13 @@ struct module_attribute {
70435 int (*test)(struct module *);
70436 void (*free)(struct module *);
70437 };
70438 +typedef struct module_attribute __no_const module_attribute_no_const;
70439
70440 struct module_version_attribute {
70441 struct module_attribute mattr;
70442 const char *module_name;
70443 const char *version;
70444 -} __attribute__ ((__aligned__(sizeof(void *))));
70445 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70446
70447 extern ssize_t __modver_version_show(struct module_attribute *,
70448 struct module_kobject *, char *);
70449 @@ -232,7 +235,7 @@ struct module
70450
70451 /* Sysfs stuff. */
70452 struct module_kobject mkobj;
70453 - struct module_attribute *modinfo_attrs;
70454 + module_attribute_no_const *modinfo_attrs;
70455 const char *version;
70456 const char *srcversion;
70457 struct kobject *holders_dir;
70458 @@ -281,19 +284,16 @@ struct module
70459 int (*init)(void);
70460
70461 /* If this is non-NULL, vfree after init() returns */
70462 - void *module_init;
70463 + void *module_init_rx, *module_init_rw;
70464
70465 /* Here is the actual code + data, vfree'd on unload. */
70466 - void *module_core;
70467 + void *module_core_rx, *module_core_rw;
70468
70469 /* Here are the sizes of the init and core sections */
70470 - unsigned int init_size, core_size;
70471 + unsigned int init_size_rw, core_size_rw;
70472
70473 /* The size of the executable code in each section. */
70474 - unsigned int init_text_size, core_text_size;
70475 -
70476 - /* Size of RO sections of the module (text+rodata) */
70477 - unsigned int init_ro_size, core_ro_size;
70478 + unsigned int init_size_rx, core_size_rx;
70479
70480 /* Arch-specific module values */
70481 struct mod_arch_specific arch;
70482 @@ -349,6 +349,10 @@ struct module
70483 #ifdef CONFIG_EVENT_TRACING
70484 struct ftrace_event_call **trace_events;
70485 unsigned int num_trace_events;
70486 + struct file_operations trace_id;
70487 + struct file_operations trace_enable;
70488 + struct file_operations trace_format;
70489 + struct file_operations trace_filter;
70490 #endif
70491 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70492 unsigned int num_ftrace_callsites;
70493 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70494 bool is_module_percpu_address(unsigned long addr);
70495 bool is_module_text_address(unsigned long addr);
70496
70497 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70498 +{
70499 +
70500 +#ifdef CONFIG_PAX_KERNEXEC
70501 + if (ktla_ktva(addr) >= (unsigned long)start &&
70502 + ktla_ktva(addr) < (unsigned long)start + size)
70503 + return 1;
70504 +#endif
70505 +
70506 + return ((void *)addr >= start && (void *)addr < start + size);
70507 +}
70508 +
70509 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
70510 +{
70511 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70512 +}
70513 +
70514 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
70515 +{
70516 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70517 +}
70518 +
70519 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
70520 +{
70521 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70522 +}
70523 +
70524 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
70525 +{
70526 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70527 +}
70528 +
70529 static inline int within_module_core(unsigned long addr, struct module *mod)
70530 {
70531 - return (unsigned long)mod->module_core <= addr &&
70532 - addr < (unsigned long)mod->module_core + mod->core_size;
70533 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70534 }
70535
70536 static inline int within_module_init(unsigned long addr, struct module *mod)
70537 {
70538 - return (unsigned long)mod->module_init <= addr &&
70539 - addr < (unsigned long)mod->module_init + mod->init_size;
70540 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70541 }
70542
70543 /* Search for module by name: must hold module_mutex. */
70544 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70545 index 560ca53..ef621ef 100644
70546 --- a/include/linux/moduleloader.h
70547 +++ b/include/linux/moduleloader.h
70548 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70549 sections. Returns NULL on failure. */
70550 void *module_alloc(unsigned long size);
70551
70552 +#ifdef CONFIG_PAX_KERNEXEC
70553 +void *module_alloc_exec(unsigned long size);
70554 +#else
70555 +#define module_alloc_exec(x) module_alloc(x)
70556 +#endif
70557 +
70558 /* Free memory returned from module_alloc. */
70559 void module_free(struct module *mod, void *module_region);
70560
70561 +#ifdef CONFIG_PAX_KERNEXEC
70562 +void module_free_exec(struct module *mod, void *module_region);
70563 +#else
70564 +#define module_free_exec(x, y) module_free((x), (y))
70565 +#endif
70566 +
70567 /*
70568 * Apply the given relocation to the (simplified) ELF. Return -error
70569 * or 0.
70570 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70571 unsigned int relsec,
70572 struct module *me)
70573 {
70574 +#ifdef CONFIG_MODULES
70575 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70576 +#endif
70577 return -ENOEXEC;
70578 }
70579 #endif
70580 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70581 unsigned int relsec,
70582 struct module *me)
70583 {
70584 +#ifdef CONFIG_MODULES
70585 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70586 +#endif
70587 return -ENOEXEC;
70588 }
70589 #endif
70590 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70591 index 137b419..fe663ec 100644
70592 --- a/include/linux/moduleparam.h
70593 +++ b/include/linux/moduleparam.h
70594 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70595 * @len is usually just sizeof(string).
70596 */
70597 #define module_param_string(name, string, len, perm) \
70598 - static const struct kparam_string __param_string_##name \
70599 + static const struct kparam_string __param_string_##name __used \
70600 = { len, string }; \
70601 __module_param_call(MODULE_PARAM_PREFIX, name, \
70602 &param_ops_string, \
70603 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70604 */
70605 #define module_param_array_named(name, array, type, nump, perm) \
70606 param_check_##type(name, &(array)[0]); \
70607 - static const struct kparam_array __param_arr_##name \
70608 + static const struct kparam_array __param_arr_##name __used \
70609 = { .max = ARRAY_SIZE(array), .num = nump, \
70610 .ops = &param_ops_##type, \
70611 .elemsize = sizeof(array[0]), .elem = array }; \
70612 diff --git a/include/linux/namei.h b/include/linux/namei.h
70613 index 5a5ff57..5ae5070 100644
70614 --- a/include/linux/namei.h
70615 +++ b/include/linux/namei.h
70616 @@ -19,7 +19,7 @@ struct nameidata {
70617 unsigned seq;
70618 int last_type;
70619 unsigned depth;
70620 - char *saved_names[MAX_NESTED_LINKS + 1];
70621 + const char *saved_names[MAX_NESTED_LINKS + 1];
70622 };
70623
70624 /*
70625 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70626
70627 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70628
70629 -static inline void nd_set_link(struct nameidata *nd, char *path)
70630 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70631 {
70632 nd->saved_names[nd->depth] = path;
70633 }
70634
70635 -static inline char *nd_get_link(struct nameidata *nd)
70636 +static inline const char *nd_get_link(const struct nameidata *nd)
70637 {
70638 return nd->saved_names[nd->depth];
70639 }
70640 diff --git a/include/linux/net.h b/include/linux/net.h
70641 index aa16731..514b875 100644
70642 --- a/include/linux/net.h
70643 +++ b/include/linux/net.h
70644 @@ -183,7 +183,7 @@ struct net_proto_family {
70645 int (*create)(struct net *net, struct socket *sock,
70646 int protocol, int kern);
70647 struct module *owner;
70648 -};
70649 +} __do_const;
70650
70651 struct iovec;
70652 struct kvec;
70653 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70654 index 9ef07d0..130a5d9 100644
70655 --- a/include/linux/netdevice.h
70656 +++ b/include/linux/netdevice.h
70657 @@ -1012,6 +1012,7 @@ struct net_device_ops {
70658 u32 pid, u32 seq,
70659 struct net_device *dev);
70660 };
70661 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70662
70663 /*
70664 * The DEVICE structure.
70665 @@ -1078,7 +1079,7 @@ struct net_device {
70666 int iflink;
70667
70668 struct net_device_stats stats;
70669 - atomic_long_t rx_dropped; /* dropped packets by core network
70670 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70671 * Do not use this in drivers.
70672 */
70673
70674 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70675 index ee14284..bc65d63 100644
70676 --- a/include/linux/netfilter.h
70677 +++ b/include/linux/netfilter.h
70678 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70679 #endif
70680 /* Use the module struct to lock set/get code in place */
70681 struct module *owner;
70682 -};
70683 +} __do_const;
70684
70685 /* Function to register/unregister hook points. */
70686 int nf_register_hook(struct nf_hook_ops *reg);
70687 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70688 index 7958e84..ed74d7a 100644
70689 --- a/include/linux/netfilter/ipset/ip_set.h
70690 +++ b/include/linux/netfilter/ipset/ip_set.h
70691 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70692 /* Return true if "b" set is the same as "a"
70693 * according to the create set parameters */
70694 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70695 -};
70696 +} __do_const;
70697
70698 /* The core set type structure */
70699 struct ip_set_type {
70700 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70701 index 4966dde..7d8ce06 100644
70702 --- a/include/linux/netfilter/nfnetlink.h
70703 +++ b/include/linux/netfilter/nfnetlink.h
70704 @@ -16,7 +16,7 @@ struct nfnl_callback {
70705 const struct nlattr * const cda[]);
70706 const struct nla_policy *policy; /* netlink attribute policy */
70707 const u_int16_t attr_count; /* number of nlattr's */
70708 -};
70709 +} __do_const;
70710
70711 struct nfnetlink_subsystem {
70712 const char *name;
70713 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70714 new file mode 100644
70715 index 0000000..33f4af8
70716 --- /dev/null
70717 +++ b/include/linux/netfilter/xt_gradm.h
70718 @@ -0,0 +1,9 @@
70719 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70720 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70721 +
70722 +struct xt_gradm_mtinfo {
70723 + __u16 flags;
70724 + __u16 invflags;
70725 +};
70726 +
70727 +#endif
70728 diff --git a/include/linux/nls.h b/include/linux/nls.h
70729 index 5dc635f..35f5e11 100644
70730 --- a/include/linux/nls.h
70731 +++ b/include/linux/nls.h
70732 @@ -31,7 +31,7 @@ struct nls_table {
70733 const unsigned char *charset2upper;
70734 struct module *owner;
70735 struct nls_table *next;
70736 -};
70737 +} __do_const;
70738
70739 /* this value hold the maximum octet of charset */
70740 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70741 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70742 index d65746e..62e72c2 100644
70743 --- a/include/linux/notifier.h
70744 +++ b/include/linux/notifier.h
70745 @@ -51,7 +51,8 @@ struct notifier_block {
70746 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70747 struct notifier_block __rcu *next;
70748 int priority;
70749 -};
70750 +} __do_const;
70751 +typedef struct notifier_block __no_const notifier_block_no_const;
70752
70753 struct atomic_notifier_head {
70754 spinlock_t lock;
70755 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70756 index a4c5624..79d6d88 100644
70757 --- a/include/linux/oprofile.h
70758 +++ b/include/linux/oprofile.h
70759 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70760 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70761 char const * name, ulong * val);
70762
70763 -/** Create a file for read-only access to an atomic_t. */
70764 +/** Create a file for read-only access to an atomic_unchecked_t. */
70765 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70766 - char const * name, atomic_t * val);
70767 + char const * name, atomic_unchecked_t * val);
70768
70769 /** create a directory */
70770 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70771 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70772 index 45fc162..01a4068 100644
70773 --- a/include/linux/pci_hotplug.h
70774 +++ b/include/linux/pci_hotplug.h
70775 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70776 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70777 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70778 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70779 -};
70780 +} __do_const;
70781 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70782
70783 /**
70784 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70785 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70786 index a280650..2b67b91 100644
70787 --- a/include/linux/perf_event.h
70788 +++ b/include/linux/perf_event.h
70789 @@ -328,8 +328,8 @@ struct perf_event {
70790
70791 enum perf_event_active_state state;
70792 unsigned int attach_state;
70793 - local64_t count;
70794 - atomic64_t child_count;
70795 + local64_t count; /* PaX: fix it one day */
70796 + atomic64_unchecked_t child_count;
70797
70798 /*
70799 * These are the total time in nanoseconds that the event
70800 @@ -380,8 +380,8 @@ struct perf_event {
70801 * These accumulate total time (in nanoseconds) that children
70802 * events have been enabled and running, respectively.
70803 */
70804 - atomic64_t child_total_time_enabled;
70805 - atomic64_t child_total_time_running;
70806 + atomic64_unchecked_t child_total_time_enabled;
70807 + atomic64_unchecked_t child_total_time_running;
70808
70809 /*
70810 * Protect attach/detach and child_list:
70811 @@ -807,7 +807,7 @@ static inline void perf_restore_debug_store(void) { }
70812 */
70813 #define perf_cpu_notifier(fn) \
70814 do { \
70815 - static struct notifier_block fn##_nb __cpuinitdata = \
70816 + static struct notifier_block fn##_nb = \
70817 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
70818 unsigned long cpu = smp_processor_id(); \
70819 unsigned long flags; \
70820 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
70821 index ad1a427..6419649 100644
70822 --- a/include/linux/pipe_fs_i.h
70823 +++ b/include/linux/pipe_fs_i.h
70824 @@ -45,9 +45,9 @@ struct pipe_buffer {
70825 struct pipe_inode_info {
70826 wait_queue_head_t wait;
70827 unsigned int nrbufs, curbuf, buffers;
70828 - unsigned int readers;
70829 - unsigned int writers;
70830 - unsigned int waiting_writers;
70831 + atomic_t readers;
70832 + atomic_t writers;
70833 + atomic_t waiting_writers;
70834 unsigned int r_counter;
70835 unsigned int w_counter;
70836 struct page *tmp_page;
70837 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
70838 index 5f28cae..3d23723 100644
70839 --- a/include/linux/platform_data/usb-ehci-s5p.h
70840 +++ b/include/linux/platform_data/usb-ehci-s5p.h
70841 @@ -14,7 +14,7 @@
70842 struct s5p_ehci_platdata {
70843 int (*phy_init)(struct platform_device *pdev, int type);
70844 int (*phy_exit)(struct platform_device *pdev, int type);
70845 -};
70846 +} __no_const;
70847
70848 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
70849
70850 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
70851 index c256c59..8ea94c7 100644
70852 --- a/include/linux/platform_data/usb-exynos.h
70853 +++ b/include/linux/platform_data/usb-exynos.h
70854 @@ -14,7 +14,7 @@
70855 struct exynos4_ohci_platdata {
70856 int (*phy_init)(struct platform_device *pdev, int type);
70857 int (*phy_exit)(struct platform_device *pdev, int type);
70858 -};
70859 +} __no_const;
70860
70861 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
70862
70863 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
70864 index 7c1d252..c5c773e 100644
70865 --- a/include/linux/pm_domain.h
70866 +++ b/include/linux/pm_domain.h
70867 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
70868
70869 struct gpd_cpu_data {
70870 unsigned int saved_exit_latency;
70871 - struct cpuidle_state *idle_state;
70872 + cpuidle_state_no_const *idle_state;
70873 };
70874
70875 struct generic_pm_domain {
70876 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
70877 index f271860..6b3bec5 100644
70878 --- a/include/linux/pm_runtime.h
70879 +++ b/include/linux/pm_runtime.h
70880 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
70881
70882 static inline void pm_runtime_mark_last_busy(struct device *dev)
70883 {
70884 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
70885 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
70886 }
70887
70888 #else /* !CONFIG_PM_RUNTIME */
70889 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
70890 index 195aafc..49a7bc2 100644
70891 --- a/include/linux/pnp.h
70892 +++ b/include/linux/pnp.h
70893 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
70894 struct pnp_fixup {
70895 char id[7];
70896 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
70897 -};
70898 +} __do_const;
70899
70900 /* config parameters */
70901 #define PNP_CONFIG_NORMAL 0x0001
70902 diff --git a/include/linux/poison.h b/include/linux/poison.h
70903 index 2110a81..13a11bb 100644
70904 --- a/include/linux/poison.h
70905 +++ b/include/linux/poison.h
70906 @@ -19,8 +19,8 @@
70907 * under normal circumstances, used to verify that nobody uses
70908 * non-initialized list entries.
70909 */
70910 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
70911 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
70912 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
70913 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
70914
70915 /********** include/linux/timer.h **********/
70916 /*
70917 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
70918 index c0f44c2..1572583 100644
70919 --- a/include/linux/power/smartreflex.h
70920 +++ b/include/linux/power/smartreflex.h
70921 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
70922 int (*notify)(struct omap_sr *sr, u32 status);
70923 u8 notify_flags;
70924 u8 class_type;
70925 -};
70926 +} __do_const;
70927
70928 /**
70929 * struct omap_sr_nvalue_table - Smartreflex n-target value info
70930 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
70931 index 4ea1d37..80f4b33 100644
70932 --- a/include/linux/ppp-comp.h
70933 +++ b/include/linux/ppp-comp.h
70934 @@ -84,7 +84,7 @@ struct compressor {
70935 struct module *owner;
70936 /* Extra skb space needed by the compressor algorithm */
70937 unsigned int comp_extra;
70938 -};
70939 +} __do_const;
70940
70941 /*
70942 * The return value from decompress routine is the length of the
70943 diff --git a/include/linux/printk.h b/include/linux/printk.h
70944 index 9afc01e..92c32e8 100644
70945 --- a/include/linux/printk.h
70946 +++ b/include/linux/printk.h
70947 @@ -101,6 +101,8 @@ void early_printk(const char *fmt, ...);
70948 extern int printk_needs_cpu(int cpu);
70949 extern void printk_tick(void);
70950
70951 +extern int kptr_restrict;
70952 +
70953 #ifdef CONFIG_PRINTK
70954 asmlinkage __printf(5, 0)
70955 int vprintk_emit(int facility, int level,
70956 @@ -135,7 +137,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
70957
70958 extern int printk_delay_msec;
70959 extern int dmesg_restrict;
70960 -extern int kptr_restrict;
70961
70962 void log_buf_kexec_setup(void);
70963 void __init setup_log_buf(int early);
70964 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
70965 index 32676b3..e46f2c0 100644
70966 --- a/include/linux/proc_fs.h
70967 +++ b/include/linux/proc_fs.h
70968 @@ -159,6 +159,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
70969 return proc_create_data(name, mode, parent, proc_fops, NULL);
70970 }
70971
70972 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
70973 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
70974 +{
70975 +#ifdef CONFIG_GRKERNSEC_PROC_USER
70976 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
70977 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
70978 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
70979 +#else
70980 + return proc_create_data(name, mode, parent, proc_fops, NULL);
70981 +#endif
70982 +}
70983 +
70984 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
70985 umode_t mode, struct proc_dir_entry *base,
70986 read_proc_t *read_proc, void * data)
70987 @@ -268,7 +280,7 @@ struct proc_ns_operations {
70988 void (*put)(void *ns);
70989 int (*install)(struct nsproxy *nsproxy, void *ns);
70990 unsigned int (*inum)(void *ns);
70991 -};
70992 +} __do_const;
70993 extern const struct proc_ns_operations netns_operations;
70994 extern const struct proc_ns_operations utsns_operations;
70995 extern const struct proc_ns_operations ipcns_operations;
70996 diff --git a/include/linux/random.h b/include/linux/random.h
70997 index d984608..d6f0042 100644
70998 --- a/include/linux/random.h
70999 +++ b/include/linux/random.h
71000 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
71001 u32 prandom_u32_state(struct rnd_state *);
71002 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
71003
71004 +static inline unsigned long pax_get_random_long(void)
71005 +{
71006 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
71007 +}
71008 +
71009 /*
71010 * Handle minimum values for seeds
71011 */
71012 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
71013 index c92dd28..08f4eab 100644
71014 --- a/include/linux/rculist.h
71015 +++ b/include/linux/rculist.h
71016 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
71017 struct list_head *prev, struct list_head *next);
71018 #endif
71019
71020 +extern void __pax_list_add_rcu(struct list_head *new,
71021 + struct list_head *prev, struct list_head *next);
71022 +
71023 /**
71024 * list_add_rcu - add a new entry to rcu-protected list
71025 * @new: new entry to be added
71026 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
71027 __list_add_rcu(new, head, head->next);
71028 }
71029
71030 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
71031 +{
71032 + __pax_list_add_rcu(new, head, head->next);
71033 +}
71034 +
71035 /**
71036 * list_add_tail_rcu - add a new entry to rcu-protected list
71037 * @new: new entry to be added
71038 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
71039 __list_add_rcu(new, head->prev, head);
71040 }
71041
71042 +static inline void pax_list_add_tail_rcu(struct list_head *new,
71043 + struct list_head *head)
71044 +{
71045 + __pax_list_add_rcu(new, head->prev, head);
71046 +}
71047 +
71048 /**
71049 * list_del_rcu - deletes entry from list without re-initialization
71050 * @entry: the element to delete from the list.
71051 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
71052 entry->prev = LIST_POISON2;
71053 }
71054
71055 +extern void pax_list_del_rcu(struct list_head *entry);
71056 +
71057 /**
71058 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71059 * @n: the element to delete from the hash list.
71060 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71061 index 23b3630..e1bc12b 100644
71062 --- a/include/linux/reboot.h
71063 +++ b/include/linux/reboot.h
71064 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71065 * Architecture-specific implementations of sys_reboot commands.
71066 */
71067
71068 -extern void machine_restart(char *cmd);
71069 -extern void machine_halt(void);
71070 -extern void machine_power_off(void);
71071 +extern void machine_restart(char *cmd) __noreturn;
71072 +extern void machine_halt(void) __noreturn;
71073 +extern void machine_power_off(void) __noreturn;
71074
71075 extern void machine_shutdown(void);
71076 struct pt_regs;
71077 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71078 */
71079
71080 extern void kernel_restart_prepare(char *cmd);
71081 -extern void kernel_restart(char *cmd);
71082 -extern void kernel_halt(void);
71083 -extern void kernel_power_off(void);
71084 +extern void kernel_restart(char *cmd) __noreturn;
71085 +extern void kernel_halt(void) __noreturn;
71086 +extern void kernel_power_off(void) __noreturn;
71087
71088 extern int C_A_D; /* for sysctl */
71089 void ctrl_alt_del(void);
71090 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71091 * Emergency restart, callable from an interrupt handler.
71092 */
71093
71094 -extern void emergency_restart(void);
71095 +extern void emergency_restart(void) __noreturn;
71096 #include <asm/emergency-restart.h>
71097
71098 #endif /* _LINUX_REBOOT_H */
71099 diff --git a/include/linux/regset.h b/include/linux/regset.h
71100 index 8e0c9fe..ac4d221 100644
71101 --- a/include/linux/regset.h
71102 +++ b/include/linux/regset.h
71103 @@ -161,7 +161,8 @@ struct user_regset {
71104 unsigned int align;
71105 unsigned int bias;
71106 unsigned int core_note_type;
71107 -};
71108 +} __do_const;
71109 +typedef struct user_regset __no_const user_regset_no_const;
71110
71111 /**
71112 * struct user_regset_view - available regsets
71113 diff --git a/include/linux/relay.h b/include/linux/relay.h
71114 index 91cacc3..b55ff74 100644
71115 --- a/include/linux/relay.h
71116 +++ b/include/linux/relay.h
71117 @@ -160,7 +160,7 @@ struct rchan_callbacks
71118 * The callback should return 0 if successful, negative if not.
71119 */
71120 int (*remove_buf_file)(struct dentry *dentry);
71121 -};
71122 +} __no_const;
71123
71124 /*
71125 * CONFIG_RELAY kernel API, kernel/relay.c
71126 diff --git a/include/linux/rio.h b/include/linux/rio.h
71127 index a3e7842..d973ca6 100644
71128 --- a/include/linux/rio.h
71129 +++ b/include/linux/rio.h
71130 @@ -339,7 +339,7 @@ struct rio_ops {
71131 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71132 u64 rstart, u32 size, u32 flags);
71133 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71134 -};
71135 +} __no_const;
71136
71137 #define RIO_RESOURCE_MEM 0x00000100
71138 #define RIO_RESOURCE_DOORBELL 0x00000200
71139 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71140 index c20635c..2f5def4 100644
71141 --- a/include/linux/rmap.h
71142 +++ b/include/linux/rmap.h
71143 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71144 void anon_vma_init(void); /* create anon_vma_cachep */
71145 int anon_vma_prepare(struct vm_area_struct *);
71146 void unlink_anon_vmas(struct vm_area_struct *);
71147 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71148 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71149 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71150 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71151
71152 static inline void anon_vma_merge(struct vm_area_struct *vma,
71153 struct vm_area_struct *next)
71154 diff --git a/include/linux/sched.h b/include/linux/sched.h
71155 index d211247..eac6c2c 100644
71156 --- a/include/linux/sched.h
71157 +++ b/include/linux/sched.h
71158 @@ -61,6 +61,7 @@ struct bio_list;
71159 struct fs_struct;
71160 struct perf_event_context;
71161 struct blk_plug;
71162 +struct linux_binprm;
71163
71164 /*
71165 * List of flags we want to share for kernel threads,
71166 @@ -327,7 +328,7 @@ extern char __sched_text_start[], __sched_text_end[];
71167 extern int in_sched_functions(unsigned long addr);
71168
71169 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71170 -extern signed long schedule_timeout(signed long timeout);
71171 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71172 extern signed long schedule_timeout_interruptible(signed long timeout);
71173 extern signed long schedule_timeout_killable(signed long timeout);
71174 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71175 @@ -354,10 +355,23 @@ struct user_namespace;
71176 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71177
71178 extern int sysctl_max_map_count;
71179 +extern unsigned long sysctl_heap_stack_gap;
71180
71181 #include <linux/aio.h>
71182
71183 #ifdef CONFIG_MMU
71184 +
71185 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71186 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71187 +#else
71188 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71189 +{
71190 + return 0;
71191 +}
71192 +#endif
71193 +
71194 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71195 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71196 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71197 extern unsigned long
71198 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71199 @@ -639,6 +653,17 @@ struct signal_struct {
71200 #ifdef CONFIG_TASKSTATS
71201 struct taskstats *stats;
71202 #endif
71203 +
71204 +#ifdef CONFIG_GRKERNSEC
71205 + u32 curr_ip;
71206 + u32 saved_ip;
71207 + u32 gr_saddr;
71208 + u32 gr_daddr;
71209 + u16 gr_sport;
71210 + u16 gr_dport;
71211 + u8 used_accept:1;
71212 +#endif
71213 +
71214 #ifdef CONFIG_AUDIT
71215 unsigned audit_tty;
71216 struct tty_audit_buf *tty_audit_buf;
71217 @@ -717,6 +742,11 @@ struct user_struct {
71218 struct key *session_keyring; /* UID's default session keyring */
71219 #endif
71220
71221 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
71222 + unsigned int banned;
71223 + unsigned long ban_expires;
71224 +#endif
71225 +
71226 /* Hash table maintenance information */
71227 struct hlist_node uidhash_node;
71228 kuid_t uid;
71229 @@ -1116,7 +1146,7 @@ struct sched_class {
71230 #ifdef CONFIG_FAIR_GROUP_SCHED
71231 void (*task_move_group) (struct task_struct *p, int on_rq);
71232 #endif
71233 -};
71234 +} __do_const;
71235
71236 struct load_weight {
71237 unsigned long weight, inv_weight;
71238 @@ -1360,8 +1390,8 @@ struct task_struct {
71239 struct list_head thread_group;
71240
71241 struct completion *vfork_done; /* for vfork() */
71242 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71243 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71244 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71245 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71246
71247 cputime_t utime, stime, utimescaled, stimescaled;
71248 cputime_t gtime;
71249 @@ -1377,11 +1407,6 @@ struct task_struct {
71250 struct task_cputime cputime_expires;
71251 struct list_head cpu_timers[3];
71252
71253 -/* process credentials */
71254 - const struct cred __rcu *real_cred; /* objective and real subjective task
71255 - * credentials (COW) */
71256 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71257 - * credentials (COW) */
71258 char comm[TASK_COMM_LEN]; /* executable name excluding path
71259 - access with [gs]et_task_comm (which lock
71260 it with task_lock())
71261 @@ -1398,6 +1423,10 @@ struct task_struct {
71262 #endif
71263 /* CPU-specific state of this task */
71264 struct thread_struct thread;
71265 +/* thread_info moved to task_struct */
71266 +#ifdef CONFIG_X86
71267 + struct thread_info tinfo;
71268 +#endif
71269 /* filesystem information */
71270 struct fs_struct *fs;
71271 /* open file information */
71272 @@ -1471,6 +1500,10 @@ struct task_struct {
71273 gfp_t lockdep_reclaim_gfp;
71274 #endif
71275
71276 +/* process credentials */
71277 + const struct cred __rcu *real_cred; /* objective and real subjective task
71278 + * credentials (COW) */
71279 +
71280 /* journalling filesystem info */
71281 void *journal_info;
71282
71283 @@ -1509,6 +1542,10 @@ struct task_struct {
71284 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71285 struct list_head cg_list;
71286 #endif
71287 +
71288 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71289 + * credentials (COW) */
71290 +
71291 #ifdef CONFIG_FUTEX
71292 struct robust_list_head __user *robust_list;
71293 #ifdef CONFIG_COMPAT
71294 @@ -1605,8 +1642,74 @@ struct task_struct {
71295 #ifdef CONFIG_UPROBES
71296 struct uprobe_task *utask;
71297 #endif
71298 +
71299 +#ifdef CONFIG_GRKERNSEC
71300 + /* grsecurity */
71301 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71302 + u64 exec_id;
71303 +#endif
71304 +#ifdef CONFIG_GRKERNSEC_SETXID
71305 + const struct cred *delayed_cred;
71306 +#endif
71307 + struct dentry *gr_chroot_dentry;
71308 + struct acl_subject_label *acl;
71309 + struct acl_role_label *role;
71310 + struct file *exec_file;
71311 + unsigned long brute_expires;
71312 + u16 acl_role_id;
71313 + /* is this the task that authenticated to the special role */
71314 + u8 acl_sp_role;
71315 + u8 is_writable;
71316 + u8 brute;
71317 + u8 gr_is_chrooted;
71318 +#endif
71319 +
71320 };
71321
71322 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71323 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71324 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71325 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71326 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71327 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71328 +
71329 +#ifdef CONFIG_PAX_SOFTMODE
71330 +extern int pax_softmode;
71331 +#endif
71332 +
71333 +extern int pax_check_flags(unsigned long *);
71334 +
71335 +/* if tsk != current then task_lock must be held on it */
71336 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71337 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71338 +{
71339 + if (likely(tsk->mm))
71340 + return tsk->mm->pax_flags;
71341 + else
71342 + return 0UL;
71343 +}
71344 +
71345 +/* if tsk != current then task_lock must be held on it */
71346 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71347 +{
71348 + if (likely(tsk->mm)) {
71349 + tsk->mm->pax_flags = flags;
71350 + return 0;
71351 + }
71352 + return -EINVAL;
71353 +}
71354 +#endif
71355 +
71356 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71357 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71358 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71359 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71360 +#endif
71361 +
71362 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71363 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71364 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71365 +
71366 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71367 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71368
71369 @@ -1696,7 +1799,7 @@ struct pid_namespace;
71370 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71371 struct pid_namespace *ns);
71372
71373 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71374 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71375 {
71376 return tsk->pid;
71377 }
71378 @@ -2155,7 +2258,9 @@ void yield(void);
71379 extern struct exec_domain default_exec_domain;
71380
71381 union thread_union {
71382 +#ifndef CONFIG_X86
71383 struct thread_info thread_info;
71384 +#endif
71385 unsigned long stack[THREAD_SIZE/sizeof(long)];
71386 };
71387
71388 @@ -2188,6 +2293,7 @@ extern struct pid_namespace init_pid_ns;
71389 */
71390
71391 extern struct task_struct *find_task_by_vpid(pid_t nr);
71392 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71393 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71394 struct pid_namespace *ns);
71395
71396 @@ -2344,7 +2450,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71397 extern void exit_itimers(struct signal_struct *);
71398 extern void flush_itimer_signals(void);
71399
71400 -extern void do_group_exit(int);
71401 +extern __noreturn void do_group_exit(int);
71402
71403 extern int allow_signal(int);
71404 extern int disallow_signal(int);
71405 @@ -2545,9 +2651,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71406
71407 #endif
71408
71409 -static inline int object_is_on_stack(void *obj)
71410 +static inline int object_starts_on_stack(void *obj)
71411 {
71412 - void *stack = task_stack_page(current);
71413 + const void *stack = task_stack_page(current);
71414
71415 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71416 }
71417 diff --git a/include/linux/security.h b/include/linux/security.h
71418 index eee7478..290f7ba 100644
71419 --- a/include/linux/security.h
71420 +++ b/include/linux/security.h
71421 @@ -26,6 +26,7 @@
71422 #include <linux/capability.h>
71423 #include <linux/slab.h>
71424 #include <linux/err.h>
71425 +#include <linux/grsecurity.h>
71426
71427 struct linux_binprm;
71428 struct cred;
71429 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71430 index 68a04a3..866e6a1 100644
71431 --- a/include/linux/seq_file.h
71432 +++ b/include/linux/seq_file.h
71433 @@ -26,6 +26,9 @@ struct seq_file {
71434 struct mutex lock;
71435 const struct seq_operations *op;
71436 int poll_event;
71437 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71438 + u64 exec_id;
71439 +#endif
71440 #ifdef CONFIG_USER_NS
71441 struct user_namespace *user_ns;
71442 #endif
71443 @@ -38,6 +41,7 @@ struct seq_operations {
71444 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71445 int (*show) (struct seq_file *m, void *v);
71446 };
71447 +typedef struct seq_operations __no_const seq_operations_no_const;
71448
71449 #define SEQ_SKIP 1
71450
71451 diff --git a/include/linux/shm.h b/include/linux/shm.h
71452 index 429c199..4d42e38 100644
71453 --- a/include/linux/shm.h
71454 +++ b/include/linux/shm.h
71455 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71456
71457 /* The task created the shm object. NULL if the task is dead. */
71458 struct task_struct *shm_creator;
71459 +#ifdef CONFIG_GRKERNSEC
71460 + time_t shm_createtime;
71461 + pid_t shm_lapid;
71462 +#endif
71463 };
71464
71465 /* shm_mode upper byte flags */
71466 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71467 index 98399e2..7c74c41 100644
71468 --- a/include/linux/skbuff.h
71469 +++ b/include/linux/skbuff.h
71470 @@ -590,7 +590,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71471 extern struct sk_buff *__alloc_skb(unsigned int size,
71472 gfp_t priority, int flags, int node);
71473 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71474 -static inline struct sk_buff *alloc_skb(unsigned int size,
71475 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71476 gfp_t priority)
71477 {
71478 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71479 @@ -700,7 +700,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71480 */
71481 static inline int skb_queue_empty(const struct sk_buff_head *list)
71482 {
71483 - return list->next == (struct sk_buff *)list;
71484 + return list->next == (const struct sk_buff *)list;
71485 }
71486
71487 /**
71488 @@ -713,7 +713,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71489 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71490 const struct sk_buff *skb)
71491 {
71492 - return skb->next == (struct sk_buff *)list;
71493 + return skb->next == (const struct sk_buff *)list;
71494 }
71495
71496 /**
71497 @@ -726,7 +726,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71498 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71499 const struct sk_buff *skb)
71500 {
71501 - return skb->prev == (struct sk_buff *)list;
71502 + return skb->prev == (const struct sk_buff *)list;
71503 }
71504
71505 /**
71506 @@ -1727,7 +1727,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71507 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71508 */
71509 #ifndef NET_SKB_PAD
71510 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71511 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71512 #endif
71513
71514 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71515 @@ -2305,7 +2305,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71516 int noblock, int *err);
71517 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71518 struct poll_table_struct *wait);
71519 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71520 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71521 int offset, struct iovec *to,
71522 int size);
71523 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71524 @@ -2595,6 +2595,9 @@ static inline void nf_reset(struct sk_buff *skb)
71525 nf_bridge_put(skb->nf_bridge);
71526 skb->nf_bridge = NULL;
71527 #endif
71528 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71529 + skb->nf_trace = 0;
71530 +#endif
71531 }
71532
71533 /* Note: This doesn't put any conntrack and bridge info in dst. */
71534 diff --git a/include/linux/slab.h b/include/linux/slab.h
71535 index 5d168d7..720bff3 100644
71536 --- a/include/linux/slab.h
71537 +++ b/include/linux/slab.h
71538 @@ -12,13 +12,20 @@
71539 #include <linux/gfp.h>
71540 #include <linux/types.h>
71541 #include <linux/workqueue.h>
71542 -
71543 +#include <linux/err.h>
71544
71545 /*
71546 * Flags to pass to kmem_cache_create().
71547 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71548 */
71549 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71550 +
71551 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71552 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71553 +#else
71554 +#define SLAB_USERCOPY 0x00000000UL
71555 +#endif
71556 +
71557 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71558 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71559 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71560 @@ -89,10 +96,13 @@
71561 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71562 * Both make kfree a no-op.
71563 */
71564 -#define ZERO_SIZE_PTR ((void *)16)
71565 +#define ZERO_SIZE_PTR \
71566 +({ \
71567 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71568 + (void *)(-MAX_ERRNO-1L); \
71569 +})
71570
71571 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71572 - (unsigned long)ZERO_SIZE_PTR)
71573 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71574
71575 /*
71576 * Common fields provided in kmem_cache by all slab allocators
71577 @@ -112,7 +122,7 @@ struct kmem_cache {
71578 unsigned int align; /* Alignment as calculated */
71579 unsigned long flags; /* Active flags on the slab */
71580 const char *name; /* Slab name for sysfs */
71581 - int refcount; /* Use counter */
71582 + atomic_t refcount; /* Use counter */
71583 void (*ctor)(void *); /* Called on object slot creation */
71584 struct list_head list; /* List of all slab caches on the system */
71585 };
71586 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71587 void kfree(const void *);
71588 void kzfree(const void *);
71589 size_t ksize(const void *);
71590 +const char *check_heap_object(const void *ptr, unsigned long n);
71591 +bool is_usercopy_object(const void *ptr);
71592
71593 /*
71594 * Allocator specific definitions. These are mainly used to establish optimized
71595 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71596 * for general use, and so are not documented here. For a full list of
71597 * potential flags, always refer to linux/gfp.h.
71598 */
71599 +
71600 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71601 {
71602 if (size != 0 && n > SIZE_MAX / size)
71603 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71604 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71605 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71606 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71607 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71608 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71609 #define kmalloc_track_caller(size, flags) \
71610 __kmalloc_track_caller(size, flags, _RET_IP_)
71611 #else
71612 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71613 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71614 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71615 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71616 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71617 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71618 #define kmalloc_node_track_caller(size, flags, node) \
71619 __kmalloc_node_track_caller(size, flags, node, \
71620 _RET_IP_)
71621 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71622 index 8bb6e0e..8eb0dbe 100644
71623 --- a/include/linux/slab_def.h
71624 +++ b/include/linux/slab_def.h
71625 @@ -52,7 +52,7 @@ struct kmem_cache {
71626 /* 4) cache creation/removal */
71627 const char *name;
71628 struct list_head list;
71629 - int refcount;
71630 + atomic_t refcount;
71631 int object_size;
71632 int align;
71633
71634 @@ -68,10 +68,10 @@ struct kmem_cache {
71635 unsigned long node_allocs;
71636 unsigned long node_frees;
71637 unsigned long node_overflow;
71638 - atomic_t allochit;
71639 - atomic_t allocmiss;
71640 - atomic_t freehit;
71641 - atomic_t freemiss;
71642 + atomic_unchecked_t allochit;
71643 + atomic_unchecked_t allocmiss;
71644 + atomic_unchecked_t freehit;
71645 + atomic_unchecked_t freemiss;
71646
71647 /*
71648 * If debugging is enabled, then the allocator can add additional
71649 @@ -111,11 +111,16 @@ struct cache_sizes {
71650 #ifdef CONFIG_ZONE_DMA
71651 struct kmem_cache *cs_dmacachep;
71652 #endif
71653 +
71654 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71655 + struct kmem_cache *cs_usercopycachep;
71656 +#endif
71657 +
71658 };
71659 extern struct cache_sizes malloc_sizes[];
71660
71661 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71662 -void *__kmalloc(size_t size, gfp_t flags);
71663 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71664
71665 #ifdef CONFIG_TRACING
71666 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71667 @@ -152,6 +157,13 @@ found:
71668 cachep = malloc_sizes[i].cs_dmacachep;
71669 else
71670 #endif
71671 +
71672 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71673 + if (flags & GFP_USERCOPY)
71674 + cachep = malloc_sizes[i].cs_usercopycachep;
71675 + else
71676 +#endif
71677 +
71678 cachep = malloc_sizes[i].cs_cachep;
71679
71680 ret = kmem_cache_alloc_trace(cachep, flags, size);
71681 @@ -162,7 +174,7 @@ found:
71682 }
71683
71684 #ifdef CONFIG_NUMA
71685 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71686 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71687 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71688
71689 #ifdef CONFIG_TRACING
71690 @@ -205,6 +217,13 @@ found:
71691 cachep = malloc_sizes[i].cs_dmacachep;
71692 else
71693 #endif
71694 +
71695 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71696 + if (flags & GFP_USERCOPY)
71697 + cachep = malloc_sizes[i].cs_usercopycachep;
71698 + else
71699 +#endif
71700 +
71701 cachep = malloc_sizes[i].cs_cachep;
71702
71703 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71704 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71705 index f28e14a..7831211 100644
71706 --- a/include/linux/slob_def.h
71707 +++ b/include/linux/slob_def.h
71708 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71709 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71710 }
71711
71712 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71713 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71714
71715 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71716 {
71717 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71718 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71719 }
71720
71721 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71722 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71723 {
71724 return kmalloc(size, flags);
71725 }
71726 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71727 index 9db4825..ed42fb5 100644
71728 --- a/include/linux/slub_def.h
71729 +++ b/include/linux/slub_def.h
71730 @@ -91,7 +91,7 @@ struct kmem_cache {
71731 struct kmem_cache_order_objects max;
71732 struct kmem_cache_order_objects min;
71733 gfp_t allocflags; /* gfp flags to use on each alloc */
71734 - int refcount; /* Refcount for slab cache destroy */
71735 + atomic_t refcount; /* Refcount for slab cache destroy */
71736 void (*ctor)(void *);
71737 int inuse; /* Offset to metadata */
71738 int align; /* Alignment */
71739 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71740 * Sorry that the following has to be that ugly but some versions of GCC
71741 * have trouble with constant propagation and loops.
71742 */
71743 -static __always_inline int kmalloc_index(size_t size)
71744 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71745 {
71746 if (!size)
71747 return 0;
71748 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71749 }
71750
71751 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71752 -void *__kmalloc(size_t size, gfp_t flags);
71753 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71754
71755 static __always_inline void *
71756 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71757 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71758 }
71759 #endif
71760
71761 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71762 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71763 {
71764 unsigned int order = get_order(size);
71765 return kmalloc_order_trace(size, flags, order);
71766 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71767 }
71768
71769 #ifdef CONFIG_NUMA
71770 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71771 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71772 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71773
71774 #ifdef CONFIG_TRACING
71775 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71776 index e8d702e..0a56eb4 100644
71777 --- a/include/linux/sock_diag.h
71778 +++ b/include/linux/sock_diag.h
71779 @@ -10,7 +10,7 @@ struct sock;
71780 struct sock_diag_handler {
71781 __u8 family;
71782 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71783 -};
71784 +} __do_const;
71785
71786 int sock_diag_register(const struct sock_diag_handler *h);
71787 void sock_diag_unregister(const struct sock_diag_handler *h);
71788 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71789 index 680f9a3..f13aeb0 100644
71790 --- a/include/linux/sonet.h
71791 +++ b/include/linux/sonet.h
71792 @@ -7,7 +7,7 @@
71793 #include <uapi/linux/sonet.h>
71794
71795 struct k_sonet_stats {
71796 -#define __HANDLE_ITEM(i) atomic_t i
71797 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71798 __SONET_ITEMS
71799 #undef __HANDLE_ITEM
71800 };
71801 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
71802 index 34206b8..3db7f1c 100644
71803 --- a/include/linux/sunrpc/clnt.h
71804 +++ b/include/linux/sunrpc/clnt.h
71805 @@ -96,7 +96,7 @@ struct rpc_procinfo {
71806 unsigned int p_timer; /* Which RTT timer to use */
71807 u32 p_statidx; /* Which procedure to account */
71808 const char * p_name; /* name of procedure */
71809 -};
71810 +} __do_const;
71811
71812 #ifdef __KERNEL__
71813
71814 @@ -176,9 +176,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
71815 {
71816 switch (sap->sa_family) {
71817 case AF_INET:
71818 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
71819 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
71820 case AF_INET6:
71821 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
71822 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
71823 }
71824 return 0;
71825 }
71826 @@ -211,7 +211,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
71827 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
71828 const struct sockaddr *src)
71829 {
71830 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
71831 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
71832 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
71833
71834 dsin->sin_family = ssin->sin_family;
71835 @@ -314,7 +314,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
71836 if (sa->sa_family != AF_INET6)
71837 return 0;
71838
71839 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
71840 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
71841 }
71842
71843 #endif /* __KERNEL__ */
71844 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
71845 index 676ddf5..4c519a1 100644
71846 --- a/include/linux/sunrpc/svc.h
71847 +++ b/include/linux/sunrpc/svc.h
71848 @@ -410,7 +410,7 @@ struct svc_procedure {
71849 unsigned int pc_count; /* call count */
71850 unsigned int pc_cachetype; /* cache info (NFS) */
71851 unsigned int pc_xdrressize; /* maximum size of XDR reply */
71852 -};
71853 +} __do_const;
71854
71855 /*
71856 * Function prototypes.
71857 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
71858 index 0b8e3e6..33e0a01 100644
71859 --- a/include/linux/sunrpc/svc_rdma.h
71860 +++ b/include/linux/sunrpc/svc_rdma.h
71861 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
71862 extern unsigned int svcrdma_max_requests;
71863 extern unsigned int svcrdma_max_req_size;
71864
71865 -extern atomic_t rdma_stat_recv;
71866 -extern atomic_t rdma_stat_read;
71867 -extern atomic_t rdma_stat_write;
71868 -extern atomic_t rdma_stat_sq_starve;
71869 -extern atomic_t rdma_stat_rq_starve;
71870 -extern atomic_t rdma_stat_rq_poll;
71871 -extern atomic_t rdma_stat_rq_prod;
71872 -extern atomic_t rdma_stat_sq_poll;
71873 -extern atomic_t rdma_stat_sq_prod;
71874 +extern atomic_unchecked_t rdma_stat_recv;
71875 +extern atomic_unchecked_t rdma_stat_read;
71876 +extern atomic_unchecked_t rdma_stat_write;
71877 +extern atomic_unchecked_t rdma_stat_sq_starve;
71878 +extern atomic_unchecked_t rdma_stat_rq_starve;
71879 +extern atomic_unchecked_t rdma_stat_rq_poll;
71880 +extern atomic_unchecked_t rdma_stat_rq_prod;
71881 +extern atomic_unchecked_t rdma_stat_sq_poll;
71882 +extern atomic_unchecked_t rdma_stat_sq_prod;
71883
71884 #define RPCRDMA_VERSION 1
71885
71886 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
71887 index dd74084a..7f509d5 100644
71888 --- a/include/linux/sunrpc/svcauth.h
71889 +++ b/include/linux/sunrpc/svcauth.h
71890 @@ -109,7 +109,7 @@ struct auth_ops {
71891 int (*release)(struct svc_rqst *rq);
71892 void (*domain_release)(struct auth_domain *);
71893 int (*set_client)(struct svc_rqst *rq);
71894 -};
71895 +} __do_const;
71896
71897 #define SVC_GARBAGE 1
71898 #define SVC_SYSERR 2
71899 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
71900 index 071d62c..4ccc7ac 100644
71901 --- a/include/linux/swiotlb.h
71902 +++ b/include/linux/swiotlb.h
71903 @@ -59,7 +59,8 @@ extern void
71904
71905 extern void
71906 swiotlb_free_coherent(struct device *hwdev, size_t size,
71907 - void *vaddr, dma_addr_t dma_handle);
71908 + void *vaddr, dma_addr_t dma_handle,
71909 + struct dma_attrs *attrs);
71910
71911 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
71912 unsigned long offset, size_t size,
71913 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
71914 index 45e2db2..1635156a 100644
71915 --- a/include/linux/syscalls.h
71916 +++ b/include/linux/syscalls.h
71917 @@ -615,7 +615,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
71918 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
71919 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
71920 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
71921 - struct sockaddr __user *, int);
71922 + struct sockaddr __user *, int) __intentional_overflow(0);
71923 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
71924 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
71925 unsigned int vlen, unsigned flags);
71926 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
71927 index 27b3b0b..e093dd9 100644
71928 --- a/include/linux/syscore_ops.h
71929 +++ b/include/linux/syscore_ops.h
71930 @@ -16,7 +16,7 @@ struct syscore_ops {
71931 int (*suspend)(void);
71932 void (*resume)(void);
71933 void (*shutdown)(void);
71934 -};
71935 +} __do_const;
71936
71937 extern void register_syscore_ops(struct syscore_ops *ops);
71938 extern void unregister_syscore_ops(struct syscore_ops *ops);
71939 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
71940 index 14a8ff2..af52bad 100644
71941 --- a/include/linux/sysctl.h
71942 +++ b/include/linux/sysctl.h
71943 @@ -34,13 +34,13 @@ struct ctl_table_root;
71944 struct ctl_table_header;
71945 struct ctl_dir;
71946
71947 -typedef struct ctl_table ctl_table;
71948 -
71949 typedef int proc_handler (struct ctl_table *ctl, int write,
71950 void __user *buffer, size_t *lenp, loff_t *ppos);
71951
71952 extern int proc_dostring(struct ctl_table *, int,
71953 void __user *, size_t *, loff_t *);
71954 +extern int proc_dostring_modpriv(struct ctl_table *, int,
71955 + void __user *, size_t *, loff_t *);
71956 extern int proc_dointvec(struct ctl_table *, int,
71957 void __user *, size_t *, loff_t *);
71958 extern int proc_dointvec_minmax(struct ctl_table *, int,
71959 @@ -115,7 +115,9 @@ struct ctl_table
71960 struct ctl_table_poll *poll;
71961 void *extra1;
71962 void *extra2;
71963 -};
71964 +} __do_const;
71965 +typedef struct ctl_table __no_const ctl_table_no_const;
71966 +typedef struct ctl_table ctl_table;
71967
71968 struct ctl_node {
71969 struct rb_node node;
71970 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
71971 index 381f06d..dc16cc7 100644
71972 --- a/include/linux/sysfs.h
71973 +++ b/include/linux/sysfs.h
71974 @@ -31,7 +31,8 @@ struct attribute {
71975 struct lock_class_key *key;
71976 struct lock_class_key skey;
71977 #endif
71978 -};
71979 +} __do_const;
71980 +typedef struct attribute __no_const attribute_no_const;
71981
71982 /**
71983 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
71984 @@ -59,8 +60,8 @@ struct attribute_group {
71985 umode_t (*is_visible)(struct kobject *,
71986 struct attribute *, int);
71987 struct attribute **attrs;
71988 -};
71989 -
71990 +} __do_const;
71991 +typedef struct attribute_group __no_const attribute_group_no_const;
71992
71993
71994 /**
71995 @@ -107,7 +108,8 @@ struct bin_attribute {
71996 char *, loff_t, size_t);
71997 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
71998 struct vm_area_struct *vma);
71999 -};
72000 +} __do_const;
72001 +typedef struct bin_attribute __no_const bin_attribute_no_const;
72002
72003 /**
72004 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
72005 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
72006 index 7faf933..9b85a0c 100644
72007 --- a/include/linux/sysrq.h
72008 +++ b/include/linux/sysrq.h
72009 @@ -16,6 +16,7 @@
72010
72011 #include <linux/errno.h>
72012 #include <linux/types.h>
72013 +#include <linux/compiler.h>
72014
72015 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
72016 #define SYSRQ_DEFAULT_ENABLE 1
72017 @@ -36,7 +37,7 @@ struct sysrq_key_op {
72018 char *help_msg;
72019 char *action_msg;
72020 int enable_mask;
72021 -};
72022 +} __do_const;
72023
72024 #ifdef CONFIG_MAGIC_SYSRQ
72025
72026 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72027 index e7e0473..7989295 100644
72028 --- a/include/linux/thread_info.h
72029 +++ b/include/linux/thread_info.h
72030 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72031 #error "no set_restore_sigmask() provided and default one won't work"
72032 #endif
72033
72034 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72035 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72036 +{
72037 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72038 + if (!__builtin_constant_p(n))
72039 +#endif
72040 + __check_object_size(ptr, n, to_user);
72041 +}
72042 +
72043 #endif /* __KERNEL__ */
72044
72045 #endif /* _LINUX_THREAD_INFO_H */
72046 diff --git a/include/linux/tty.h b/include/linux/tty.h
72047 index 8db1b56..c16a040 100644
72048 --- a/include/linux/tty.h
72049 +++ b/include/linux/tty.h
72050 @@ -194,7 +194,7 @@ struct tty_port {
72051 const struct tty_port_operations *ops; /* Port operations */
72052 spinlock_t lock; /* Lock protecting tty field */
72053 int blocked_open; /* Waiting to open */
72054 - int count; /* Usage count */
72055 + atomic_t count; /* Usage count */
72056 wait_queue_head_t open_wait; /* Open waiters */
72057 wait_queue_head_t close_wait; /* Close waiters */
72058 wait_queue_head_t delta_msr_wait; /* Modem status change */
72059 @@ -490,7 +490,7 @@ extern int tty_port_open(struct tty_port *port,
72060 struct tty_struct *tty, struct file *filp);
72061 static inline int tty_port_users(struct tty_port *port)
72062 {
72063 - return port->count + port->blocked_open;
72064 + return atomic_read(&port->count) + port->blocked_open;
72065 }
72066
72067 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72068 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72069 index dd976cf..e272742 100644
72070 --- a/include/linux/tty_driver.h
72071 +++ b/include/linux/tty_driver.h
72072 @@ -284,7 +284,7 @@ struct tty_operations {
72073 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72074 #endif
72075 const struct file_operations *proc_fops;
72076 -};
72077 +} __do_const;
72078
72079 struct tty_driver {
72080 int magic; /* magic number for this structure */
72081 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72082 index fb79dd8d..07d4773 100644
72083 --- a/include/linux/tty_ldisc.h
72084 +++ b/include/linux/tty_ldisc.h
72085 @@ -149,7 +149,7 @@ struct tty_ldisc_ops {
72086
72087 struct module *owner;
72088
72089 - int refcount;
72090 + atomic_t refcount;
72091 };
72092
72093 struct tty_ldisc {
72094 diff --git a/include/linux/types.h b/include/linux/types.h
72095 index 4d118ba..c3ee9bf 100644
72096 --- a/include/linux/types.h
72097 +++ b/include/linux/types.h
72098 @@ -176,10 +176,26 @@ typedef struct {
72099 int counter;
72100 } atomic_t;
72101
72102 +#ifdef CONFIG_PAX_REFCOUNT
72103 +typedef struct {
72104 + int counter;
72105 +} atomic_unchecked_t;
72106 +#else
72107 +typedef atomic_t atomic_unchecked_t;
72108 +#endif
72109 +
72110 #ifdef CONFIG_64BIT
72111 typedef struct {
72112 long counter;
72113 } atomic64_t;
72114 +
72115 +#ifdef CONFIG_PAX_REFCOUNT
72116 +typedef struct {
72117 + long counter;
72118 +} atomic64_unchecked_t;
72119 +#else
72120 +typedef atomic64_t atomic64_unchecked_t;
72121 +#endif
72122 #endif
72123
72124 struct list_head {
72125 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72126 index 5ca0951..ab496a5 100644
72127 --- a/include/linux/uaccess.h
72128 +++ b/include/linux/uaccess.h
72129 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72130 long ret; \
72131 mm_segment_t old_fs = get_fs(); \
72132 \
72133 - set_fs(KERNEL_DS); \
72134 pagefault_disable(); \
72135 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72136 - pagefault_enable(); \
72137 + set_fs(KERNEL_DS); \
72138 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72139 set_fs(old_fs); \
72140 + pagefault_enable(); \
72141 ret; \
72142 })
72143
72144 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72145 index 8e522cbc..aa8572d 100644
72146 --- a/include/linux/uidgid.h
72147 +++ b/include/linux/uidgid.h
72148 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72149
72150 #endif /* CONFIG_USER_NS */
72151
72152 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72153 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72154 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72155 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72156 +
72157 #endif /* _LINUX_UIDGID_H */
72158 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72159 index 99c1b4d..562e6f3 100644
72160 --- a/include/linux/unaligned/access_ok.h
72161 +++ b/include/linux/unaligned/access_ok.h
72162 @@ -4,34 +4,34 @@
72163 #include <linux/kernel.h>
72164 #include <asm/byteorder.h>
72165
72166 -static inline u16 get_unaligned_le16(const void *p)
72167 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72168 {
72169 - return le16_to_cpup((__le16 *)p);
72170 + return le16_to_cpup((const __le16 *)p);
72171 }
72172
72173 -static inline u32 get_unaligned_le32(const void *p)
72174 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72175 {
72176 - return le32_to_cpup((__le32 *)p);
72177 + return le32_to_cpup((const __le32 *)p);
72178 }
72179
72180 -static inline u64 get_unaligned_le64(const void *p)
72181 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72182 {
72183 - return le64_to_cpup((__le64 *)p);
72184 + return le64_to_cpup((const __le64 *)p);
72185 }
72186
72187 -static inline u16 get_unaligned_be16(const void *p)
72188 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72189 {
72190 - return be16_to_cpup((__be16 *)p);
72191 + return be16_to_cpup((const __be16 *)p);
72192 }
72193
72194 -static inline u32 get_unaligned_be32(const void *p)
72195 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72196 {
72197 - return be32_to_cpup((__be32 *)p);
72198 + return be32_to_cpup((const __be32 *)p);
72199 }
72200
72201 -static inline u64 get_unaligned_be64(const void *p)
72202 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72203 {
72204 - return be64_to_cpup((__be64 *)p);
72205 + return be64_to_cpup((const __be64 *)p);
72206 }
72207
72208 static inline void put_unaligned_le16(u16 val, void *p)
72209 diff --git a/include/linux/usb.h b/include/linux/usb.h
72210 index 4d22d0f..8d0e8f8 100644
72211 --- a/include/linux/usb.h
72212 +++ b/include/linux/usb.h
72213 @@ -554,7 +554,7 @@ struct usb_device {
72214 int maxchild;
72215
72216 u32 quirks;
72217 - atomic_t urbnum;
72218 + atomic_unchecked_t urbnum;
72219
72220 unsigned long active_duration;
72221
72222 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72223
72224 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72225 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72226 - void *data, __u16 size, int timeout);
72227 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72228 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72229 void *data, int len, int *actual_length, int timeout);
72230 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72231 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72232 index c5d36c6..108f4f9 100644
72233 --- a/include/linux/usb/renesas_usbhs.h
72234 +++ b/include/linux/usb/renesas_usbhs.h
72235 @@ -39,7 +39,7 @@ enum {
72236 */
72237 struct renesas_usbhs_driver_callback {
72238 int (*notify_hotplug)(struct platform_device *pdev);
72239 -};
72240 +} __no_const;
72241
72242 /*
72243 * callback functions for platform
72244 diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
72245 index 5209cfe..b6b215f 100644
72246 --- a/include/linux/user_namespace.h
72247 +++ b/include/linux/user_namespace.h
72248 @@ -21,7 +21,7 @@ struct user_namespace {
72249 struct uid_gid_map uid_map;
72250 struct uid_gid_map gid_map;
72251 struct uid_gid_map projid_map;
72252 - struct kref kref;
72253 + atomic_t count;
72254 struct user_namespace *parent;
72255 kuid_t owner;
72256 kgid_t group;
72257 @@ -37,18 +37,18 @@ extern struct user_namespace init_user_ns;
72258 static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
72259 {
72260 if (ns)
72261 - kref_get(&ns->kref);
72262 + atomic_inc(&ns->count);
72263 return ns;
72264 }
72265
72266 extern int create_user_ns(struct cred *new);
72267 extern int unshare_userns(unsigned long unshare_flags, struct cred **new_cred);
72268 -extern void free_user_ns(struct kref *kref);
72269 +extern void free_user_ns(struct user_namespace *ns);
72270
72271 static inline void put_user_ns(struct user_namespace *ns)
72272 {
72273 - if (ns)
72274 - kref_put(&ns->kref, free_user_ns);
72275 + if (ns && atomic_dec_and_test(&ns->count))
72276 + free_user_ns(ns);
72277 }
72278
72279 struct seq_operations;
72280 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72281 index 6f8fbcf..8259001 100644
72282 --- a/include/linux/vermagic.h
72283 +++ b/include/linux/vermagic.h
72284 @@ -25,9 +25,35 @@
72285 #define MODULE_ARCH_VERMAGIC ""
72286 #endif
72287
72288 +#ifdef CONFIG_PAX_REFCOUNT
72289 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72290 +#else
72291 +#define MODULE_PAX_REFCOUNT ""
72292 +#endif
72293 +
72294 +#ifdef CONSTIFY_PLUGIN
72295 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72296 +#else
72297 +#define MODULE_CONSTIFY_PLUGIN ""
72298 +#endif
72299 +
72300 +#ifdef STACKLEAK_PLUGIN
72301 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72302 +#else
72303 +#define MODULE_STACKLEAK_PLUGIN ""
72304 +#endif
72305 +
72306 +#ifdef CONFIG_GRKERNSEC
72307 +#define MODULE_GRSEC "GRSEC "
72308 +#else
72309 +#define MODULE_GRSEC ""
72310 +#endif
72311 +
72312 #define VERMAGIC_STRING \
72313 UTS_RELEASE " " \
72314 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72315 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72316 - MODULE_ARCH_VERMAGIC
72317 + MODULE_ARCH_VERMAGIC \
72318 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72319 + MODULE_GRSEC
72320
72321 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72322 index 6071e91..ca6a489 100644
72323 --- a/include/linux/vmalloc.h
72324 +++ b/include/linux/vmalloc.h
72325 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72326 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72327 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72328 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72329 +
72330 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72331 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72332 +#endif
72333 +
72334 /* bits [20..32] reserved for arch specific ioremap internals */
72335
72336 /*
72337 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
72338 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72339 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72340 unsigned long start, unsigned long end, gfp_t gfp_mask,
72341 - pgprot_t prot, int node, const void *caller);
72342 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72343 extern void vfree(const void *addr);
72344
72345 extern void *vmap(struct page **pages, unsigned int count,
72346 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72347 extern void free_vm_area(struct vm_struct *area);
72348
72349 /* for /dev/kmem */
72350 -extern long vread(char *buf, char *addr, unsigned long count);
72351 -extern long vwrite(char *buf, char *addr, unsigned long count);
72352 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72353 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72354
72355 /*
72356 * Internals. Dont't use..
72357 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72358 index a13291f..af51fa3 100644
72359 --- a/include/linux/vmstat.h
72360 +++ b/include/linux/vmstat.h
72361 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
72362 /*
72363 * Zone based page accounting with per cpu differentials.
72364 */
72365 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72366 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72367
72368 static inline void zone_page_state_add(long x, struct zone *zone,
72369 enum zone_stat_item item)
72370 {
72371 - atomic_long_add(x, &zone->vm_stat[item]);
72372 - atomic_long_add(x, &vm_stat[item]);
72373 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72374 + atomic_long_add_unchecked(x, &vm_stat[item]);
72375 }
72376
72377 static inline unsigned long global_page_state(enum zone_stat_item item)
72378 {
72379 - long x = atomic_long_read(&vm_stat[item]);
72380 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72381 #ifdef CONFIG_SMP
72382 if (x < 0)
72383 x = 0;
72384 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72385 static inline unsigned long zone_page_state(struct zone *zone,
72386 enum zone_stat_item item)
72387 {
72388 - long x = atomic_long_read(&zone->vm_stat[item]);
72389 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72390 #ifdef CONFIG_SMP
72391 if (x < 0)
72392 x = 0;
72393 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72394 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72395 enum zone_stat_item item)
72396 {
72397 - long x = atomic_long_read(&zone->vm_stat[item]);
72398 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72399
72400 #ifdef CONFIG_SMP
72401 int cpu;
72402 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72403
72404 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72405 {
72406 - atomic_long_inc(&zone->vm_stat[item]);
72407 - atomic_long_inc(&vm_stat[item]);
72408 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72409 + atomic_long_inc_unchecked(&vm_stat[item]);
72410 }
72411
72412 static inline void __inc_zone_page_state(struct page *page,
72413 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72414
72415 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72416 {
72417 - atomic_long_dec(&zone->vm_stat[item]);
72418 - atomic_long_dec(&vm_stat[item]);
72419 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72420 + atomic_long_dec_unchecked(&vm_stat[item]);
72421 }
72422
72423 static inline void __dec_zone_page_state(struct page *page,
72424 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72425 index fdbafc6..b7ffd47 100644
72426 --- a/include/linux/xattr.h
72427 +++ b/include/linux/xattr.h
72428 @@ -28,7 +28,7 @@ struct xattr_handler {
72429 size_t size, int handler_flags);
72430 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72431 size_t size, int flags, int handler_flags);
72432 -};
72433 +} __do_const;
72434
72435 struct xattr {
72436 char *name;
72437 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72438 index 9c5a6b4..09c9438 100644
72439 --- a/include/linux/zlib.h
72440 +++ b/include/linux/zlib.h
72441 @@ -31,6 +31,7 @@
72442 #define _ZLIB_H
72443
72444 #include <linux/zconf.h>
72445 +#include <linux/compiler.h>
72446
72447 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72448 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72449 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72450
72451 /* basic functions */
72452
72453 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72454 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72455 /*
72456 Returns the number of bytes that needs to be allocated for a per-
72457 stream workspace with the specified parameters. A pointer to this
72458 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72459 index 95d1c91..6798cca 100644
72460 --- a/include/media/v4l2-dev.h
72461 +++ b/include/media/v4l2-dev.h
72462 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72463 int (*mmap) (struct file *, struct vm_area_struct *);
72464 int (*open) (struct file *);
72465 int (*release) (struct file *);
72466 -};
72467 +} __do_const;
72468
72469 /*
72470 * Newer version of video_device, handled by videodev2.c
72471 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72472 index 4118ad1..cb7e25f 100644
72473 --- a/include/media/v4l2-ioctl.h
72474 +++ b/include/media/v4l2-ioctl.h
72475 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72476 bool valid_prio, int cmd, void *arg);
72477 };
72478
72479 -
72480 /* v4l debugging and diagnostics */
72481
72482 /* Debug bitmask flags to be used on V4L2 */
72483 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72484 index adcbb20..62c2559 100644
72485 --- a/include/net/9p/transport.h
72486 +++ b/include/net/9p/transport.h
72487 @@ -57,7 +57,7 @@ struct p9_trans_module {
72488 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72489 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72490 char *, char *, int , int, int, int);
72491 -};
72492 +} __do_const;
72493
72494 void v9fs_register_trans(struct p9_trans_module *m);
72495 void v9fs_unregister_trans(struct p9_trans_module *m);
72496 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72497 index 7588ef4..e62d35f 100644
72498 --- a/include/net/bluetooth/l2cap.h
72499 +++ b/include/net/bluetooth/l2cap.h
72500 @@ -552,7 +552,7 @@ struct l2cap_ops {
72501 void (*defer) (struct l2cap_chan *chan);
72502 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72503 unsigned long len, int nb);
72504 -};
72505 +} __do_const;
72506
72507 struct l2cap_conn {
72508 struct hci_conn *hcon;
72509 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72510 index 9e5425b..8136ffc 100644
72511 --- a/include/net/caif/cfctrl.h
72512 +++ b/include/net/caif/cfctrl.h
72513 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72514 void (*radioset_rsp)(void);
72515 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72516 struct cflayer *client_layer);
72517 -};
72518 +} __no_const;
72519
72520 /* Link Setup Parameters for CAIF-Links. */
72521 struct cfctrl_link_param {
72522 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72523 struct cfctrl {
72524 struct cfsrvl serv;
72525 struct cfctrl_rsp res;
72526 - atomic_t req_seq_no;
72527 - atomic_t rsp_seq_no;
72528 + atomic_unchecked_t req_seq_no;
72529 + atomic_unchecked_t rsp_seq_no;
72530 struct list_head list;
72531 /* Protects from simultaneous access to first_req list */
72532 spinlock_t info_list_lock;
72533 diff --git a/include/net/flow.h b/include/net/flow.h
72534 index 628e11b..4c475df 100644
72535 --- a/include/net/flow.h
72536 +++ b/include/net/flow.h
72537 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72538
72539 extern void flow_cache_flush(void);
72540 extern void flow_cache_flush_deferred(void);
72541 -extern atomic_t flow_cache_genid;
72542 +extern atomic_unchecked_t flow_cache_genid;
72543
72544 #endif
72545 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72546 index bdfbe68..4402ebe 100644
72547 --- a/include/net/genetlink.h
72548 +++ b/include/net/genetlink.h
72549 @@ -118,7 +118,7 @@ struct genl_ops {
72550 struct netlink_callback *cb);
72551 int (*done)(struct netlink_callback *cb);
72552 struct list_head ops_list;
72553 -};
72554 +} __do_const;
72555
72556 extern int genl_register_family(struct genl_family *family);
72557 extern int genl_register_family_with_ops(struct genl_family *family,
72558 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72559 index e5062c9..48a9a4b 100644
72560 --- a/include/net/gro_cells.h
72561 +++ b/include/net/gro_cells.h
72562 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72563 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72564
72565 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72566 - atomic_long_inc(&dev->rx_dropped);
72567 + atomic_long_inc_unchecked(&dev->rx_dropped);
72568 kfree_skb(skb);
72569 return;
72570 }
72571 @@ -73,8 +73,8 @@ static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *de
72572 int i;
72573
72574 gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1;
72575 - gcells->cells = kcalloc(sizeof(struct gro_cell),
72576 - gcells->gro_cells_mask + 1,
72577 + gcells->cells = kcalloc(gcells->gro_cells_mask + 1,
72578 + sizeof(struct gro_cell),
72579 GFP_KERNEL);
72580 if (!gcells->cells)
72581 return -ENOMEM;
72582 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72583 index 1832927..ce39aea 100644
72584 --- a/include/net/inet_connection_sock.h
72585 +++ b/include/net/inet_connection_sock.h
72586 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72587 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72588 int (*bind_conflict)(const struct sock *sk,
72589 const struct inet_bind_bucket *tb, bool relax);
72590 -};
72591 +} __do_const;
72592
72593 /** inet_connection_sock - INET connection oriented sock
72594 *
72595 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72596 index 53f464d..ba76aaa 100644
72597 --- a/include/net/inetpeer.h
72598 +++ b/include/net/inetpeer.h
72599 @@ -47,8 +47,8 @@ struct inet_peer {
72600 */
72601 union {
72602 struct {
72603 - atomic_t rid; /* Frag reception counter */
72604 - atomic_t ip_id_count; /* IP ID for the next packet */
72605 + atomic_unchecked_t rid; /* Frag reception counter */
72606 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72607 };
72608 struct rcu_head rcu;
72609 struct inet_peer *gc_next;
72610 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72611 more++;
72612 inet_peer_refcheck(p);
72613 do {
72614 - old = atomic_read(&p->ip_id_count);
72615 + old = atomic_read_unchecked(&p->ip_id_count);
72616 new = old + more;
72617 if (!new)
72618 new = 1;
72619 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72620 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72621 return new;
72622 }
72623
72624 diff --git a/include/net/ip.h b/include/net/ip.h
72625 index a68f838..74518ab 100644
72626 --- a/include/net/ip.h
72627 +++ b/include/net/ip.h
72628 @@ -202,7 +202,7 @@ extern struct local_ports {
72629 } sysctl_local_ports;
72630 extern void inet_get_local_port_range(int *low, int *high);
72631
72632 -extern unsigned long *sysctl_local_reserved_ports;
72633 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72634 static inline int inet_is_reserved_local_port(int port)
72635 {
72636 return test_bit(port, sysctl_local_reserved_ports);
72637 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72638 index e49db91..76a81de 100644
72639 --- a/include/net/ip_fib.h
72640 +++ b/include/net/ip_fib.h
72641 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72642
72643 #define FIB_RES_SADDR(net, res) \
72644 ((FIB_RES_NH(res).nh_saddr_genid == \
72645 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72646 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72647 FIB_RES_NH(res).nh_saddr : \
72648 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72649 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72650 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72651 index 68c69d5..bdab192 100644
72652 --- a/include/net/ip_vs.h
72653 +++ b/include/net/ip_vs.h
72654 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72655 struct ip_vs_conn *control; /* Master control connection */
72656 atomic_t n_control; /* Number of controlled ones */
72657 struct ip_vs_dest *dest; /* real server */
72658 - atomic_t in_pkts; /* incoming packet counter */
72659 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72660
72661 /* packet transmitter for different forwarding methods. If it
72662 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72663 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72664 __be16 port; /* port number of the server */
72665 union nf_inet_addr addr; /* IP address of the server */
72666 volatile unsigned int flags; /* dest status flags */
72667 - atomic_t conn_flags; /* flags to copy to conn */
72668 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72669 atomic_t weight; /* server weight */
72670
72671 atomic_t refcnt; /* reference counter */
72672 @@ -980,11 +980,11 @@ struct netns_ipvs {
72673 /* ip_vs_lblc */
72674 int sysctl_lblc_expiration;
72675 struct ctl_table_header *lblc_ctl_header;
72676 - struct ctl_table *lblc_ctl_table;
72677 + ctl_table_no_const *lblc_ctl_table;
72678 /* ip_vs_lblcr */
72679 int sysctl_lblcr_expiration;
72680 struct ctl_table_header *lblcr_ctl_header;
72681 - struct ctl_table *lblcr_ctl_table;
72682 + ctl_table_no_const *lblcr_ctl_table;
72683 /* ip_vs_est */
72684 struct list_head est_list; /* estimator list */
72685 spinlock_t est_lock;
72686 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72687 index 80ffde3..968b0f4 100644
72688 --- a/include/net/irda/ircomm_tty.h
72689 +++ b/include/net/irda/ircomm_tty.h
72690 @@ -35,6 +35,7 @@
72691 #include <linux/termios.h>
72692 #include <linux/timer.h>
72693 #include <linux/tty.h> /* struct tty_struct */
72694 +#include <asm/local.h>
72695
72696 #include <net/irda/irias_object.h>
72697 #include <net/irda/ircomm_core.h>
72698 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72699 index cc7c197..9f2da2a 100644
72700 --- a/include/net/iucv/af_iucv.h
72701 +++ b/include/net/iucv/af_iucv.h
72702 @@ -141,7 +141,7 @@ struct iucv_sock {
72703 struct iucv_sock_list {
72704 struct hlist_head head;
72705 rwlock_t lock;
72706 - atomic_t autobind_name;
72707 + atomic_unchecked_t autobind_name;
72708 };
72709
72710 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72711 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72712 index df83f69..9b640b8 100644
72713 --- a/include/net/llc_c_ac.h
72714 +++ b/include/net/llc_c_ac.h
72715 @@ -87,7 +87,7 @@
72716 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72717 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72718
72719 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72720 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72721
72722 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72723 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72724 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72725 index 6ca3113..f8026dd 100644
72726 --- a/include/net/llc_c_ev.h
72727 +++ b/include/net/llc_c_ev.h
72728 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72729 return (struct llc_conn_state_ev *)skb->cb;
72730 }
72731
72732 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72733 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72734 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72735 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72736
72737 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72738 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72739 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72740 index 0e79cfb..f46db31 100644
72741 --- a/include/net/llc_c_st.h
72742 +++ b/include/net/llc_c_st.h
72743 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72744 u8 next_state;
72745 llc_conn_ev_qfyr_t *ev_qualifiers;
72746 llc_conn_action_t *ev_actions;
72747 -};
72748 +} __do_const;
72749
72750 struct llc_conn_state {
72751 u8 current_state;
72752 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72753 index 37a3bbd..55a4241 100644
72754 --- a/include/net/llc_s_ac.h
72755 +++ b/include/net/llc_s_ac.h
72756 @@ -23,7 +23,7 @@
72757 #define SAP_ACT_TEST_IND 9
72758
72759 /* All action functions must look like this */
72760 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72761 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72762
72763 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72764 struct sk_buff *skb);
72765 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72766 index 567c681..cd73ac0 100644
72767 --- a/include/net/llc_s_st.h
72768 +++ b/include/net/llc_s_st.h
72769 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72770 llc_sap_ev_t ev;
72771 u8 next_state;
72772 llc_sap_action_t *ev_actions;
72773 -};
72774 +} __do_const;
72775
72776 struct llc_sap_state {
72777 u8 curr_state;
72778 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72779 index ee50c5e..1bc3b1a 100644
72780 --- a/include/net/mac80211.h
72781 +++ b/include/net/mac80211.h
72782 @@ -3996,7 +3996,7 @@ struct rate_control_ops {
72783 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72784 struct dentry *dir);
72785 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72786 -};
72787 +} __do_const;
72788
72789 static inline int rate_supported(struct ieee80211_sta *sta,
72790 enum ieee80211_band band,
72791 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72792 index 0dab173..1b76af0 100644
72793 --- a/include/net/neighbour.h
72794 +++ b/include/net/neighbour.h
72795 @@ -123,7 +123,7 @@ struct neigh_ops {
72796 void (*error_report)(struct neighbour *, struct sk_buff *);
72797 int (*output)(struct neighbour *, struct sk_buff *);
72798 int (*connected_output)(struct neighbour *, struct sk_buff *);
72799 -};
72800 +} __do_const;
72801
72802 struct pneigh_entry {
72803 struct pneigh_entry *next;
72804 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72805 index de644bc..dfbcc4c 100644
72806 --- a/include/net/net_namespace.h
72807 +++ b/include/net/net_namespace.h
72808 @@ -115,7 +115,7 @@ struct net {
72809 #endif
72810 struct netns_ipvs *ipvs;
72811 struct sock *diag_nlsk;
72812 - atomic_t rt_genid;
72813 + atomic_unchecked_t rt_genid;
72814 };
72815
72816 /*
72817 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
72818 #define __net_init __init
72819 #define __net_exit __exit_refok
72820 #define __net_initdata __initdata
72821 +#ifdef CONSTIFY_PLUGIN
72822 #define __net_initconst __initconst
72823 +#else
72824 +#define __net_initconst __initdata
72825 +#endif
72826 #endif
72827
72828 struct pernet_operations {
72829 @@ -282,7 +286,7 @@ struct pernet_operations {
72830 void (*exit_batch)(struct list_head *net_exit_list);
72831 int *id;
72832 size_t size;
72833 -};
72834 +} __do_const;
72835
72836 /*
72837 * Use these carefully. If you implement a network device and it
72838 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
72839
72840 static inline int rt_genid(struct net *net)
72841 {
72842 - return atomic_read(&net->rt_genid);
72843 + return atomic_read_unchecked(&net->rt_genid);
72844 }
72845
72846 static inline void rt_genid_bump(struct net *net)
72847 {
72848 - atomic_inc(&net->rt_genid);
72849 + atomic_inc_unchecked(&net->rt_genid);
72850 }
72851
72852 #endif /* __NET_NET_NAMESPACE_H */
72853 diff --git a/include/net/netdma.h b/include/net/netdma.h
72854 index 8ba8ce2..99b7fff 100644
72855 --- a/include/net/netdma.h
72856 +++ b/include/net/netdma.h
72857 @@ -24,7 +24,7 @@
72858 #include <linux/dmaengine.h>
72859 #include <linux/skbuff.h>
72860
72861 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72862 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72863 struct sk_buff *skb, int offset, struct iovec *to,
72864 size_t len, struct dma_pinned_list *pinned_list);
72865
72866 diff --git a/include/net/netlink.h b/include/net/netlink.h
72867 index 9690b0f..87aded7 100644
72868 --- a/include/net/netlink.h
72869 +++ b/include/net/netlink.h
72870 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
72871 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
72872 {
72873 if (mark)
72874 - skb_trim(skb, (unsigned char *) mark - skb->data);
72875 + skb_trim(skb, (const unsigned char *) mark - skb->data);
72876 }
72877
72878 /**
72879 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
72880 index 923cb20..deae816 100644
72881 --- a/include/net/netns/conntrack.h
72882 +++ b/include/net/netns/conntrack.h
72883 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
72884 struct nf_proto_net {
72885 #ifdef CONFIG_SYSCTL
72886 struct ctl_table_header *ctl_table_header;
72887 - struct ctl_table *ctl_table;
72888 + ctl_table_no_const *ctl_table;
72889 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
72890 struct ctl_table_header *ctl_compat_header;
72891 - struct ctl_table *ctl_compat_table;
72892 + ctl_table_no_const *ctl_compat_table;
72893 #endif
72894 #endif
72895 unsigned int users;
72896 @@ -58,7 +58,7 @@ struct nf_ip_net {
72897 struct nf_icmp_net icmpv6;
72898 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
72899 struct ctl_table_header *ctl_table_header;
72900 - struct ctl_table *ctl_table;
72901 + ctl_table_no_const *ctl_table;
72902 #endif
72903 };
72904
72905 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
72906 index 2ae2b83..dbdc85e 100644
72907 --- a/include/net/netns/ipv4.h
72908 +++ b/include/net/netns/ipv4.h
72909 @@ -64,7 +64,7 @@ struct netns_ipv4 {
72910 kgid_t sysctl_ping_group_range[2];
72911 long sysctl_tcp_mem[3];
72912
72913 - atomic_t dev_addr_genid;
72914 + atomic_unchecked_t dev_addr_genid;
72915
72916 #ifdef CONFIG_IP_MROUTE
72917 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
72918 diff --git a/include/net/protocol.h b/include/net/protocol.h
72919 index 047c047..b9dad15 100644
72920 --- a/include/net/protocol.h
72921 +++ b/include/net/protocol.h
72922 @@ -44,7 +44,7 @@ struct net_protocol {
72923 void (*err_handler)(struct sk_buff *skb, u32 info);
72924 unsigned int no_policy:1,
72925 netns_ok:1;
72926 -};
72927 +} __do_const;
72928
72929 #if IS_ENABLED(CONFIG_IPV6)
72930 struct inet6_protocol {
72931 @@ -57,7 +57,7 @@ struct inet6_protocol {
72932 u8 type, u8 code, int offset,
72933 __be32 info);
72934 unsigned int flags; /* INET6_PROTO_xxx */
72935 -};
72936 +} __do_const;
72937
72938 #define INET6_PROTO_NOPOLICY 0x1
72939 #define INET6_PROTO_FINAL 0x2
72940 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
72941 index 5a15fab..d799ea7 100644
72942 --- a/include/net/rtnetlink.h
72943 +++ b/include/net/rtnetlink.h
72944 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
72945 const struct net_device *dev);
72946 unsigned int (*get_num_tx_queues)(void);
72947 unsigned int (*get_num_rx_queues)(void);
72948 -};
72949 +} __do_const;
72950
72951 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
72952 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
72953 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
72954 index 7fdf298..197e9f7 100644
72955 --- a/include/net/sctp/sctp.h
72956 +++ b/include/net/sctp/sctp.h
72957 @@ -330,9 +330,9 @@ do { \
72958
72959 #else /* SCTP_DEBUG */
72960
72961 -#define SCTP_DEBUG_PRINTK(whatever...)
72962 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
72963 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
72964 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
72965 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
72966 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
72967 #define SCTP_ENABLE_DEBUG
72968 #define SCTP_DISABLE_DEBUG
72969 #define SCTP_ASSERT(expr, str, func)
72970 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
72971 index 2a82d13..62a31c2 100644
72972 --- a/include/net/sctp/sm.h
72973 +++ b/include/net/sctp/sm.h
72974 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
72975 typedef struct {
72976 sctp_state_fn_t *fn;
72977 const char *name;
72978 -} sctp_sm_table_entry_t;
72979 +} __do_const sctp_sm_table_entry_t;
72980
72981 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
72982 * currently in use.
72983 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
72984 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
72985
72986 /* Extern declarations for major data structures. */
72987 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72988 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
72989
72990
72991 /* Get the size of a DATA chunk payload. */
72992 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
72993 index fdeb85a..1329d95 100644
72994 --- a/include/net/sctp/structs.h
72995 +++ b/include/net/sctp/structs.h
72996 @@ -517,7 +517,7 @@ struct sctp_pf {
72997 struct sctp_association *asoc);
72998 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
72999 struct sctp_af *af;
73000 -};
73001 +} __do_const;
73002
73003
73004 /* Structure to track chunk fragments that have been acked, but peer
73005 diff --git a/include/net/sock.h b/include/net/sock.h
73006 index 25afaa0..8bb0070 100644
73007 --- a/include/net/sock.h
73008 +++ b/include/net/sock.h
73009 @@ -322,7 +322,7 @@ struct sock {
73010 #ifdef CONFIG_RPS
73011 __u32 sk_rxhash;
73012 #endif
73013 - atomic_t sk_drops;
73014 + atomic_unchecked_t sk_drops;
73015 int sk_rcvbuf;
73016
73017 struct sk_filter __rcu *sk_filter;
73018 @@ -1781,7 +1781,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
73019 }
73020
73021 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
73022 - char __user *from, char *to,
73023 + char __user *from, unsigned char *to,
73024 int copy, int offset)
73025 {
73026 if (skb->ip_summed == CHECKSUM_NONE) {
73027 @@ -2040,7 +2040,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
73028 }
73029 }
73030
73031 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73032 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73033
73034 /**
73035 * sk_page_frag - return an appropriate page_frag
73036 diff --git a/include/net/tcp.h b/include/net/tcp.h
73037 index aed42c7..43890c6 100644
73038 --- a/include/net/tcp.h
73039 +++ b/include/net/tcp.h
73040 @@ -530,7 +530,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
73041 extern void tcp_xmit_retransmit_queue(struct sock *);
73042 extern void tcp_simple_retransmit(struct sock *);
73043 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
73044 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73045 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73046
73047 extern void tcp_send_probe0(struct sock *);
73048 extern void tcp_send_partial(struct sock *);
73049 @@ -701,8 +701,8 @@ struct tcp_skb_cb {
73050 struct inet6_skb_parm h6;
73051 #endif
73052 } header; /* For incoming frames */
73053 - __u32 seq; /* Starting sequence number */
73054 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73055 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73056 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73057 __u32 when; /* used to compute rtt's */
73058 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73059
73060 @@ -716,7 +716,7 @@ struct tcp_skb_cb {
73061
73062 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73063 /* 1 byte hole */
73064 - __u32 ack_seq; /* Sequence number ACK'd */
73065 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73066 };
73067
73068 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73069 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73070 index 63445ed..d6fc34f 100644
73071 --- a/include/net/xfrm.h
73072 +++ b/include/net/xfrm.h
73073 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
73074 struct net_device *dev,
73075 const struct flowi *fl);
73076 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73077 -};
73078 +} __do_const;
73079
73080 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73081 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73082 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
73083 struct sk_buff *skb);
73084 int (*transport_finish)(struct sk_buff *skb,
73085 int async);
73086 -};
73087 +} __do_const;
73088
73089 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73090 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73091 @@ -423,7 +423,7 @@ struct xfrm_mode {
73092 struct module *owner;
73093 unsigned int encap;
73094 int flags;
73095 -};
73096 +} __do_const;
73097
73098 /* Flags for xfrm_mode. */
73099 enum {
73100 @@ -514,7 +514,7 @@ struct xfrm_policy {
73101 struct timer_list timer;
73102
73103 struct flow_cache_object flo;
73104 - atomic_t genid;
73105 + atomic_unchecked_t genid;
73106 u32 priority;
73107 u32 index;
73108 struct xfrm_mark mark;
73109 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73110 index 1a046b1..ee0bef0 100644
73111 --- a/include/rdma/iw_cm.h
73112 +++ b/include/rdma/iw_cm.h
73113 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73114 int backlog);
73115
73116 int (*destroy_listen)(struct iw_cm_id *cm_id);
73117 -};
73118 +} __no_const;
73119
73120 /**
73121 * iw_create_cm_id - Create an IW CM identifier.
73122 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73123 index 399162b..b337f1a 100644
73124 --- a/include/scsi/libfc.h
73125 +++ b/include/scsi/libfc.h
73126 @@ -762,6 +762,7 @@ struct libfc_function_template {
73127 */
73128 void (*disc_stop_final) (struct fc_lport *);
73129 };
73130 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73131
73132 /**
73133 * struct fc_disc - Discovery context
73134 @@ -866,7 +867,7 @@ struct fc_lport {
73135 struct fc_vport *vport;
73136
73137 /* Operational Information */
73138 - struct libfc_function_template tt;
73139 + libfc_function_template_no_const tt;
73140 u8 link_up;
73141 u8 qfull;
73142 enum fc_lport_state state;
73143 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73144 index e65c62e..aa2e5a2 100644
73145 --- a/include/scsi/scsi_device.h
73146 +++ b/include/scsi/scsi_device.h
73147 @@ -170,9 +170,9 @@ struct scsi_device {
73148 unsigned int max_device_blocked; /* what device_blocked counts down from */
73149 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73150
73151 - atomic_t iorequest_cnt;
73152 - atomic_t iodone_cnt;
73153 - atomic_t ioerr_cnt;
73154 + atomic_unchecked_t iorequest_cnt;
73155 + atomic_unchecked_t iodone_cnt;
73156 + atomic_unchecked_t ioerr_cnt;
73157
73158 struct device sdev_gendev,
73159 sdev_dev;
73160 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73161 index b797e8f..8e2c3aa 100644
73162 --- a/include/scsi/scsi_transport_fc.h
73163 +++ b/include/scsi/scsi_transport_fc.h
73164 @@ -751,7 +751,8 @@ struct fc_function_template {
73165 unsigned long show_host_system_hostname:1;
73166
73167 unsigned long disable_target_scan:1;
73168 -};
73169 +} __do_const;
73170 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73171
73172
73173 /**
73174 diff --git a/include/sound/soc.h b/include/sound/soc.h
73175 index bc56738..a4be132 100644
73176 --- a/include/sound/soc.h
73177 +++ b/include/sound/soc.h
73178 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
73179 /* probe ordering - for components with runtime dependencies */
73180 int probe_order;
73181 int remove_order;
73182 -};
73183 +} __do_const;
73184
73185 /* SoC platform interface */
73186 struct snd_soc_platform_driver {
73187 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
73188 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73189 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73190 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73191 -};
73192 +} __do_const;
73193
73194 struct snd_soc_platform {
73195 const char *name;
73196 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73197 index 663e34a..91b306a 100644
73198 --- a/include/target/target_core_base.h
73199 +++ b/include/target/target_core_base.h
73200 @@ -654,7 +654,7 @@ struct se_device {
73201 spinlock_t stats_lock;
73202 /* Active commands on this virtual SE device */
73203 atomic_t simple_cmds;
73204 - atomic_t dev_ordered_id;
73205 + atomic_unchecked_t dev_ordered_id;
73206 atomic_t dev_ordered_sync;
73207 atomic_t dev_qf_count;
73208 int export_count;
73209 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73210 new file mode 100644
73211 index 0000000..fb634b7
73212 --- /dev/null
73213 +++ b/include/trace/events/fs.h
73214 @@ -0,0 +1,53 @@
73215 +#undef TRACE_SYSTEM
73216 +#define TRACE_SYSTEM fs
73217 +
73218 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73219 +#define _TRACE_FS_H
73220 +
73221 +#include <linux/fs.h>
73222 +#include <linux/tracepoint.h>
73223 +
73224 +TRACE_EVENT(do_sys_open,
73225 +
73226 + TP_PROTO(const char *filename, int flags, int mode),
73227 +
73228 + TP_ARGS(filename, flags, mode),
73229 +
73230 + TP_STRUCT__entry(
73231 + __string( filename, filename )
73232 + __field( int, flags )
73233 + __field( int, mode )
73234 + ),
73235 +
73236 + TP_fast_assign(
73237 + __assign_str(filename, filename);
73238 + __entry->flags = flags;
73239 + __entry->mode = mode;
73240 + ),
73241 +
73242 + TP_printk("\"%s\" %x %o",
73243 + __get_str(filename), __entry->flags, __entry->mode)
73244 +);
73245 +
73246 +TRACE_EVENT(open_exec,
73247 +
73248 + TP_PROTO(const char *filename),
73249 +
73250 + TP_ARGS(filename),
73251 +
73252 + TP_STRUCT__entry(
73253 + __string( filename, filename )
73254 + ),
73255 +
73256 + TP_fast_assign(
73257 + __assign_str(filename, filename);
73258 + ),
73259 +
73260 + TP_printk("\"%s\"",
73261 + __get_str(filename))
73262 +);
73263 +
73264 +#endif /* _TRACE_FS_H */
73265 +
73266 +/* This part must be outside protection */
73267 +#include <trace/define_trace.h>
73268 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73269 index 1c09820..7f5ec79 100644
73270 --- a/include/trace/events/irq.h
73271 +++ b/include/trace/events/irq.h
73272 @@ -36,7 +36,7 @@ struct softirq_action;
73273 */
73274 TRACE_EVENT(irq_handler_entry,
73275
73276 - TP_PROTO(int irq, struct irqaction *action),
73277 + TP_PROTO(int irq, const struct irqaction *action),
73278
73279 TP_ARGS(irq, action),
73280
73281 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73282 */
73283 TRACE_EVENT(irq_handler_exit,
73284
73285 - TP_PROTO(int irq, struct irqaction *action, int ret),
73286 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73287
73288 TP_ARGS(irq, action, ret),
73289
73290 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73291 index 7caf44c..23c6f27 100644
73292 --- a/include/uapi/linux/a.out.h
73293 +++ b/include/uapi/linux/a.out.h
73294 @@ -39,6 +39,14 @@ enum machine_type {
73295 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73296 };
73297
73298 +/* Constants for the N_FLAGS field */
73299 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73300 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73301 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73302 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73303 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73304 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73305 +
73306 #if !defined (N_MAGIC)
73307 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73308 #endif
73309 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73310 index d876736..ccce5c0 100644
73311 --- a/include/uapi/linux/byteorder/little_endian.h
73312 +++ b/include/uapi/linux/byteorder/little_endian.h
73313 @@ -42,51 +42,51 @@
73314
73315 static inline __le64 __cpu_to_le64p(const __u64 *p)
73316 {
73317 - return (__force __le64)*p;
73318 + return (__force const __le64)*p;
73319 }
73320 -static inline __u64 __le64_to_cpup(const __le64 *p)
73321 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73322 {
73323 - return (__force __u64)*p;
73324 + return (__force const __u64)*p;
73325 }
73326 static inline __le32 __cpu_to_le32p(const __u32 *p)
73327 {
73328 - return (__force __le32)*p;
73329 + return (__force const __le32)*p;
73330 }
73331 static inline __u32 __le32_to_cpup(const __le32 *p)
73332 {
73333 - return (__force __u32)*p;
73334 + return (__force const __u32)*p;
73335 }
73336 static inline __le16 __cpu_to_le16p(const __u16 *p)
73337 {
73338 - return (__force __le16)*p;
73339 + return (__force const __le16)*p;
73340 }
73341 static inline __u16 __le16_to_cpup(const __le16 *p)
73342 {
73343 - return (__force __u16)*p;
73344 + return (__force const __u16)*p;
73345 }
73346 static inline __be64 __cpu_to_be64p(const __u64 *p)
73347 {
73348 - return (__force __be64)__swab64p(p);
73349 + return (__force const __be64)__swab64p(p);
73350 }
73351 static inline __u64 __be64_to_cpup(const __be64 *p)
73352 {
73353 - return __swab64p((__u64 *)p);
73354 + return __swab64p((const __u64 *)p);
73355 }
73356 static inline __be32 __cpu_to_be32p(const __u32 *p)
73357 {
73358 - return (__force __be32)__swab32p(p);
73359 + return (__force const __be32)__swab32p(p);
73360 }
73361 -static inline __u32 __be32_to_cpup(const __be32 *p)
73362 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73363 {
73364 - return __swab32p((__u32 *)p);
73365 + return __swab32p((const __u32 *)p);
73366 }
73367 static inline __be16 __cpu_to_be16p(const __u16 *p)
73368 {
73369 - return (__force __be16)__swab16p(p);
73370 + return (__force const __be16)__swab16p(p);
73371 }
73372 static inline __u16 __be16_to_cpup(const __be16 *p)
73373 {
73374 - return __swab16p((__u16 *)p);
73375 + return __swab16p((const __u16 *)p);
73376 }
73377 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73378 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73379 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73380 index 126a817..d522bd1 100644
73381 --- a/include/uapi/linux/elf.h
73382 +++ b/include/uapi/linux/elf.h
73383 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73384 #define PT_GNU_EH_FRAME 0x6474e550
73385
73386 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73387 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73388 +
73389 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73390 +
73391 +/* Constants for the e_flags field */
73392 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73393 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73394 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73395 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73396 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73397 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73398
73399 /*
73400 * Extended Numbering
73401 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73402 #define DT_DEBUG 21
73403 #define DT_TEXTREL 22
73404 #define DT_JMPREL 23
73405 +#define DT_FLAGS 30
73406 + #define DF_TEXTREL 0x00000004
73407 #define DT_ENCODING 32
73408 #define OLD_DT_LOOS 0x60000000
73409 #define DT_LOOS 0x6000000d
73410 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73411 #define PF_W 0x2
73412 #define PF_X 0x1
73413
73414 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73415 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73416 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73417 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73418 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73419 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73420 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73421 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73422 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73423 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73424 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73425 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73426 +
73427 typedef struct elf32_phdr{
73428 Elf32_Word p_type;
73429 Elf32_Off p_offset;
73430 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73431 #define EI_OSABI 7
73432 #define EI_PAD 8
73433
73434 +#define EI_PAX 14
73435 +
73436 #define ELFMAG0 0x7f /* EI_MAG */
73437 #define ELFMAG1 'E'
73438 #define ELFMAG2 'L'
73439 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73440 index aa169c4..6a2771d 100644
73441 --- a/include/uapi/linux/personality.h
73442 +++ b/include/uapi/linux/personality.h
73443 @@ -30,6 +30,7 @@ enum {
73444 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73445 ADDR_NO_RANDOMIZE | \
73446 ADDR_COMPAT_LAYOUT | \
73447 + ADDR_LIMIT_3GB | \
73448 MMAP_PAGE_ZERO)
73449
73450 /*
73451 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73452 index 7530e74..e714828 100644
73453 --- a/include/uapi/linux/screen_info.h
73454 +++ b/include/uapi/linux/screen_info.h
73455 @@ -43,7 +43,8 @@ struct screen_info {
73456 __u16 pages; /* 0x32 */
73457 __u16 vesa_attributes; /* 0x34 */
73458 __u32 capabilities; /* 0x36 */
73459 - __u8 _reserved[6]; /* 0x3a */
73460 + __u16 vesapm_size; /* 0x3a */
73461 + __u8 _reserved[4]; /* 0x3c */
73462 } __attribute__((packed));
73463
73464 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73465 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73466 index 0e011eb..82681b1 100644
73467 --- a/include/uapi/linux/swab.h
73468 +++ b/include/uapi/linux/swab.h
73469 @@ -43,7 +43,7 @@
73470 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73471 */
73472
73473 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73474 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73475 {
73476 #ifdef __HAVE_BUILTIN_BSWAP16__
73477 return __builtin_bswap16(val);
73478 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73479 #endif
73480 }
73481
73482 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73483 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73484 {
73485 #ifdef __HAVE_BUILTIN_BSWAP32__
73486 return __builtin_bswap32(val);
73487 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73488 #endif
73489 }
73490
73491 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73492 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73493 {
73494 #ifdef __HAVE_BUILTIN_BSWAP64__
73495 return __builtin_bswap64(val);
73496 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73497 index 6d67213..8dab561 100644
73498 --- a/include/uapi/linux/sysctl.h
73499 +++ b/include/uapi/linux/sysctl.h
73500 @@ -155,7 +155,11 @@ enum
73501 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73502 };
73503
73504 -
73505 +#ifdef CONFIG_PAX_SOFTMODE
73506 +enum {
73507 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73508 +};
73509 +#endif
73510
73511 /* CTL_VM names: */
73512 enum
73513 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73514 index 26607bd..588b65f 100644
73515 --- a/include/uapi/linux/xattr.h
73516 +++ b/include/uapi/linux/xattr.h
73517 @@ -60,5 +60,9 @@
73518 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73519 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73520
73521 +/* User namespace */
73522 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73523 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73524 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73525
73526 #endif /* _UAPI_LINUX_XATTR_H */
73527 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73528 index f9466fa..f4e2b81 100644
73529 --- a/include/video/udlfb.h
73530 +++ b/include/video/udlfb.h
73531 @@ -53,10 +53,10 @@ struct dlfb_data {
73532 u32 pseudo_palette[256];
73533 int blank_mode; /*one of FB_BLANK_ */
73534 /* blit-only rendering path metrics, exposed through sysfs */
73535 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73536 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73537 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73538 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73539 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73540 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73541 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73542 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73543 };
73544
73545 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73546 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73547 index 0993a22..32ba2fe 100644
73548 --- a/include/video/uvesafb.h
73549 +++ b/include/video/uvesafb.h
73550 @@ -177,6 +177,7 @@ struct uvesafb_par {
73551 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73552 u8 pmi_setpal; /* PMI for palette changes */
73553 u16 *pmi_base; /* protected mode interface location */
73554 + u8 *pmi_code; /* protected mode code location */
73555 void *pmi_start;
73556 void *pmi_pal;
73557 u8 *vbe_state_orig; /*
73558 diff --git a/init/Kconfig b/init/Kconfig
73559 index be8b7f5..1eeca9b 100644
73560 --- a/init/Kconfig
73561 +++ b/init/Kconfig
73562 @@ -990,6 +990,7 @@ endif # CGROUPS
73563
73564 config CHECKPOINT_RESTORE
73565 bool "Checkpoint/restore support" if EXPERT
73566 + depends on !GRKERNSEC
73567 default n
73568 help
73569 Enables additional kernel features in a sake of checkpoint/restore.
73570 @@ -1468,7 +1469,7 @@ config SLUB_DEBUG
73571
73572 config COMPAT_BRK
73573 bool "Disable heap randomization"
73574 - default y
73575 + default n
73576 help
73577 Randomizing heap placement makes heap exploits harder, but it
73578 also breaks ancient binaries (including anything libc5 based).
73579 @@ -1711,7 +1712,7 @@ config INIT_ALL_POSSIBLE
73580 config STOP_MACHINE
73581 bool
73582 default y
73583 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73584 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73585 help
73586 Need stop_machine() primitive.
73587
73588 diff --git a/init/Makefile b/init/Makefile
73589 index 7bc47ee..6da2dc7 100644
73590 --- a/init/Makefile
73591 +++ b/init/Makefile
73592 @@ -2,6 +2,9 @@
73593 # Makefile for the linux kernel.
73594 #
73595
73596 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73597 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73598 +
73599 obj-y := main.o version.o mounts.o
73600 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73601 obj-y += noinitramfs.o
73602 diff --git a/init/do_mounts.c b/init/do_mounts.c
73603 index 1d1b634..a1c810f 100644
73604 --- a/init/do_mounts.c
73605 +++ b/init/do_mounts.c
73606 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73607 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73608 {
73609 struct super_block *s;
73610 - int err = sys_mount(name, "/root", fs, flags, data);
73611 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73612 if (err)
73613 return err;
73614
73615 - sys_chdir("/root");
73616 + sys_chdir((const char __force_user *)"/root");
73617 s = current->fs->pwd.dentry->d_sb;
73618 ROOT_DEV = s->s_dev;
73619 printk(KERN_INFO
73620 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73621 va_start(args, fmt);
73622 vsprintf(buf, fmt, args);
73623 va_end(args);
73624 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73625 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73626 if (fd >= 0) {
73627 sys_ioctl(fd, FDEJECT, 0);
73628 sys_close(fd);
73629 }
73630 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73631 - fd = sys_open("/dev/console", O_RDWR, 0);
73632 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73633 if (fd >= 0) {
73634 sys_ioctl(fd, TCGETS, (long)&termios);
73635 termios.c_lflag &= ~ICANON;
73636 sys_ioctl(fd, TCSETSF, (long)&termios);
73637 - sys_read(fd, &c, 1);
73638 + sys_read(fd, (char __user *)&c, 1);
73639 termios.c_lflag |= ICANON;
73640 sys_ioctl(fd, TCSETSF, (long)&termios);
73641 sys_close(fd);
73642 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73643 mount_root();
73644 out:
73645 devtmpfs_mount("dev");
73646 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73647 - sys_chroot(".");
73648 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73649 + sys_chroot((const char __force_user *)".");
73650 }
73651 diff --git a/init/do_mounts.h b/init/do_mounts.h
73652 index f5b978a..69dbfe8 100644
73653 --- a/init/do_mounts.h
73654 +++ b/init/do_mounts.h
73655 @@ -15,15 +15,15 @@ extern int root_mountflags;
73656
73657 static inline int create_dev(char *name, dev_t dev)
73658 {
73659 - sys_unlink(name);
73660 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73661 + sys_unlink((char __force_user *)name);
73662 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73663 }
73664
73665 #if BITS_PER_LONG == 32
73666 static inline u32 bstat(char *name)
73667 {
73668 struct stat64 stat;
73669 - if (sys_stat64(name, &stat) != 0)
73670 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73671 return 0;
73672 if (!S_ISBLK(stat.st_mode))
73673 return 0;
73674 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73675 static inline u32 bstat(char *name)
73676 {
73677 struct stat stat;
73678 - if (sys_newstat(name, &stat) != 0)
73679 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73680 return 0;
73681 if (!S_ISBLK(stat.st_mode))
73682 return 0;
73683 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73684 index f9acf71..1e19144 100644
73685 --- a/init/do_mounts_initrd.c
73686 +++ b/init/do_mounts_initrd.c
73687 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73688 create_dev("/dev/root.old", Root_RAM0);
73689 /* mount initrd on rootfs' /root */
73690 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73691 - sys_mkdir("/old", 0700);
73692 - sys_chdir("/old");
73693 + sys_mkdir((const char __force_user *)"/old", 0700);
73694 + sys_chdir((const char __force_user *)"/old");
73695
73696 /*
73697 * In case that a resume from disk is carried out by linuxrc or one of
73698 @@ -73,31 +73,31 @@ static void __init handle_initrd(void)
73699 current->flags &= ~PF_FREEZER_SKIP;
73700
73701 /* move initrd to rootfs' /old */
73702 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73703 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73704 /* switch root and cwd back to / of rootfs */
73705 - sys_chroot("..");
73706 + sys_chroot((const char __force_user *)"..");
73707
73708 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73709 - sys_chdir("/old");
73710 + sys_chdir((const char __force_user *)"/old");
73711 return;
73712 }
73713
73714 - sys_chdir("/");
73715 + sys_chdir((const char __force_user *)"/");
73716 ROOT_DEV = new_decode_dev(real_root_dev);
73717 mount_root();
73718
73719 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73720 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73721 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73722 if (!error)
73723 printk("okay\n");
73724 else {
73725 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73726 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73727 if (error == -ENOENT)
73728 printk("/initrd does not exist. Ignored.\n");
73729 else
73730 printk("failed\n");
73731 printk(KERN_NOTICE "Unmounting old root\n");
73732 - sys_umount("/old", MNT_DETACH);
73733 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73734 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73735 if (fd < 0) {
73736 error = fd;
73737 @@ -120,11 +120,11 @@ int __init initrd_load(void)
73738 * mounted in the normal path.
73739 */
73740 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73741 - sys_unlink("/initrd.image");
73742 + sys_unlink((const char __force_user *)"/initrd.image");
73743 handle_initrd();
73744 return 1;
73745 }
73746 }
73747 - sys_unlink("/initrd.image");
73748 + sys_unlink((const char __force_user *)"/initrd.image");
73749 return 0;
73750 }
73751 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73752 index 8cb6db5..d729f50 100644
73753 --- a/init/do_mounts_md.c
73754 +++ b/init/do_mounts_md.c
73755 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73756 partitioned ? "_d" : "", minor,
73757 md_setup_args[ent].device_names);
73758
73759 - fd = sys_open(name, 0, 0);
73760 + fd = sys_open((char __force_user *)name, 0, 0);
73761 if (fd < 0) {
73762 printk(KERN_ERR "md: open failed - cannot start "
73763 "array %s\n", name);
73764 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73765 * array without it
73766 */
73767 sys_close(fd);
73768 - fd = sys_open(name, 0, 0);
73769 + fd = sys_open((char __force_user *)name, 0, 0);
73770 sys_ioctl(fd, BLKRRPART, 0);
73771 }
73772 sys_close(fd);
73773 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73774
73775 wait_for_device_probe();
73776
73777 - fd = sys_open("/dev/md0", 0, 0);
73778 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73779 if (fd >= 0) {
73780 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73781 sys_close(fd);
73782 diff --git a/init/init_task.c b/init/init_task.c
73783 index 8b2f399..f0797c9 100644
73784 --- a/init/init_task.c
73785 +++ b/init/init_task.c
73786 @@ -20,5 +20,9 @@ EXPORT_SYMBOL(init_task);
73787 * Initial thread structure. Alignment of this is handled by a special
73788 * linker map entry.
73789 */
73790 +#ifdef CONFIG_X86
73791 +union thread_union init_thread_union __init_task_data;
73792 +#else
73793 union thread_union init_thread_union __init_task_data =
73794 { INIT_THREAD_INFO(init_task) };
73795 +#endif
73796 diff --git a/init/initramfs.c b/init/initramfs.c
73797 index 84c6bf1..8899338 100644
73798 --- a/init/initramfs.c
73799 +++ b/init/initramfs.c
73800 @@ -84,7 +84,7 @@ static void __init free_hash(void)
73801 }
73802 }
73803
73804 -static long __init do_utime(char *filename, time_t mtime)
73805 +static long __init do_utime(char __force_user *filename, time_t mtime)
73806 {
73807 struct timespec t[2];
73808
73809 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
73810 struct dir_entry *de, *tmp;
73811 list_for_each_entry_safe(de, tmp, &dir_list, list) {
73812 list_del(&de->list);
73813 - do_utime(de->name, de->mtime);
73814 + do_utime((char __force_user *)de->name, de->mtime);
73815 kfree(de->name);
73816 kfree(de);
73817 }
73818 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
73819 if (nlink >= 2) {
73820 char *old = find_link(major, minor, ino, mode, collected);
73821 if (old)
73822 - return (sys_link(old, collected) < 0) ? -1 : 1;
73823 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
73824 }
73825 return 0;
73826 }
73827 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
73828 {
73829 struct stat st;
73830
73831 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
73832 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
73833 if (S_ISDIR(st.st_mode))
73834 - sys_rmdir(path);
73835 + sys_rmdir((char __force_user *)path);
73836 else
73837 - sys_unlink(path);
73838 + sys_unlink((char __force_user *)path);
73839 }
73840 }
73841
73842 @@ -315,7 +315,7 @@ static int __init do_name(void)
73843 int openflags = O_WRONLY|O_CREAT;
73844 if (ml != 1)
73845 openflags |= O_TRUNC;
73846 - wfd = sys_open(collected, openflags, mode);
73847 + wfd = sys_open((char __force_user *)collected, openflags, mode);
73848
73849 if (wfd >= 0) {
73850 sys_fchown(wfd, uid, gid);
73851 @@ -327,17 +327,17 @@ static int __init do_name(void)
73852 }
73853 }
73854 } else if (S_ISDIR(mode)) {
73855 - sys_mkdir(collected, mode);
73856 - sys_chown(collected, uid, gid);
73857 - sys_chmod(collected, mode);
73858 + sys_mkdir((char __force_user *)collected, mode);
73859 + sys_chown((char __force_user *)collected, uid, gid);
73860 + sys_chmod((char __force_user *)collected, mode);
73861 dir_add(collected, mtime);
73862 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
73863 S_ISFIFO(mode) || S_ISSOCK(mode)) {
73864 if (maybe_link() == 0) {
73865 - sys_mknod(collected, mode, rdev);
73866 - sys_chown(collected, uid, gid);
73867 - sys_chmod(collected, mode);
73868 - do_utime(collected, mtime);
73869 + sys_mknod((char __force_user *)collected, mode, rdev);
73870 + sys_chown((char __force_user *)collected, uid, gid);
73871 + sys_chmod((char __force_user *)collected, mode);
73872 + do_utime((char __force_user *)collected, mtime);
73873 }
73874 }
73875 return 0;
73876 @@ -346,15 +346,15 @@ static int __init do_name(void)
73877 static int __init do_copy(void)
73878 {
73879 if (count >= body_len) {
73880 - sys_write(wfd, victim, body_len);
73881 + sys_write(wfd, (char __force_user *)victim, body_len);
73882 sys_close(wfd);
73883 - do_utime(vcollected, mtime);
73884 + do_utime((char __force_user *)vcollected, mtime);
73885 kfree(vcollected);
73886 eat(body_len);
73887 state = SkipIt;
73888 return 0;
73889 } else {
73890 - sys_write(wfd, victim, count);
73891 + sys_write(wfd, (char __force_user *)victim, count);
73892 body_len -= count;
73893 eat(count);
73894 return 1;
73895 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
73896 {
73897 collected[N_ALIGN(name_len) + body_len] = '\0';
73898 clean_path(collected, 0);
73899 - sys_symlink(collected + N_ALIGN(name_len), collected);
73900 - sys_lchown(collected, uid, gid);
73901 - do_utime(collected, mtime);
73902 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
73903 + sys_lchown((char __force_user *)collected, uid, gid);
73904 + do_utime((char __force_user *)collected, mtime);
73905 state = SkipIt;
73906 next_state = Reset;
73907 return 0;
73908 diff --git a/init/main.c b/init/main.c
73909 index cee4b5c..360e10a 100644
73910 --- a/init/main.c
73911 +++ b/init/main.c
73912 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
73913 extern void tc_init(void);
73914 #endif
73915
73916 +extern void grsecurity_init(void);
73917 +
73918 /*
73919 * Debug helper: via this flag we know that we are in 'early bootup code'
73920 * where only the boot processor is running with IRQ disabled. This means
73921 @@ -149,6 +151,61 @@ static int __init set_reset_devices(char *str)
73922
73923 __setup("reset_devices", set_reset_devices);
73924
73925 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
73926 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
73927 +static int __init setup_grsec_proc_gid(char *str)
73928 +{
73929 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
73930 + return 1;
73931 +}
73932 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
73933 +#endif
73934 +
73935 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
73936 +extern char pax_enter_kernel_user[];
73937 +extern char pax_exit_kernel_user[];
73938 +extern pgdval_t clone_pgd_mask;
73939 +#endif
73940 +
73941 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
73942 +static int __init setup_pax_nouderef(char *str)
73943 +{
73944 +#ifdef CONFIG_X86_32
73945 + unsigned int cpu;
73946 + struct desc_struct *gdt;
73947 +
73948 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
73949 + gdt = get_cpu_gdt_table(cpu);
73950 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
73951 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
73952 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
73953 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
73954 + }
73955 + loadsegment(ds, __KERNEL_DS);
73956 + loadsegment(es, __KERNEL_DS);
73957 + loadsegment(ss, __KERNEL_DS);
73958 +#else
73959 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
73960 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
73961 + clone_pgd_mask = ~(pgdval_t)0UL;
73962 +#endif
73963 +
73964 + return 0;
73965 +}
73966 +early_param("pax_nouderef", setup_pax_nouderef);
73967 +#endif
73968 +
73969 +#ifdef CONFIG_PAX_SOFTMODE
73970 +int pax_softmode;
73971 +
73972 +static int __init setup_pax_softmode(char *str)
73973 +{
73974 + get_option(&str, &pax_softmode);
73975 + return 1;
73976 +}
73977 +__setup("pax_softmode=", setup_pax_softmode);
73978 +#endif
73979 +
73980 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
73981 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
73982 static const char *panic_later, *panic_param;
73983 @@ -681,6 +738,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
73984 {
73985 int count = preempt_count();
73986 int ret;
73987 + const char *msg1 = "", *msg2 = "";
73988
73989 if (initcall_debug)
73990 ret = do_one_initcall_debug(fn);
73991 @@ -693,15 +751,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
73992 sprintf(msgbuf, "error code %d ", ret);
73993
73994 if (preempt_count() != count) {
73995 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
73996 + msg1 = " preemption imbalance";
73997 preempt_count() = count;
73998 }
73999 if (irqs_disabled()) {
74000 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
74001 + msg2 = " disabled interrupts";
74002 local_irq_enable();
74003 }
74004 - if (msgbuf[0]) {
74005 - printk("initcall %pF returned with %s\n", fn, msgbuf);
74006 + if (msgbuf[0] || *msg1 || *msg2) {
74007 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
74008 }
74009
74010 return ret;
74011 @@ -755,8 +813,14 @@ static void __init do_initcall_level(int level)
74012 level, level,
74013 &repair_env_string);
74014
74015 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
74016 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74017 do_one_initcall(*fn);
74018 +
74019 +#ifdef LATENT_ENTROPY_PLUGIN
74020 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74021 +#endif
74022 +
74023 + }
74024 }
74025
74026 static void __init do_initcalls(void)
74027 @@ -790,8 +854,14 @@ static void __init do_pre_smp_initcalls(void)
74028 {
74029 initcall_t *fn;
74030
74031 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74032 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
74033 do_one_initcall(*fn);
74034 +
74035 +#ifdef LATENT_ENTROPY_PLUGIN
74036 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74037 +#endif
74038 +
74039 + }
74040 }
74041
74042 static int run_init_process(const char *init_filename)
74043 @@ -877,7 +947,7 @@ static noinline void __init kernel_init_freeable(void)
74044 do_basic_setup();
74045
74046 /* Open the /dev/console on the rootfs, this should never fail */
74047 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74048 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74049 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
74050
74051 (void) sys_dup(0);
74052 @@ -890,11 +960,13 @@ static noinline void __init kernel_init_freeable(void)
74053 if (!ramdisk_execute_command)
74054 ramdisk_execute_command = "/init";
74055
74056 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74057 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74058 ramdisk_execute_command = NULL;
74059 prepare_namespace();
74060 }
74061
74062 + grsecurity_init();
74063 +
74064 /*
74065 * Ok, we have completed the initial bootup, and
74066 * we're essentially up and running. Get rid of the
74067 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74068 index 130dfec..cc88451 100644
74069 --- a/ipc/ipc_sysctl.c
74070 +++ b/ipc/ipc_sysctl.c
74071 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74072 static int proc_ipc_dointvec(ctl_table *table, int write,
74073 void __user *buffer, size_t *lenp, loff_t *ppos)
74074 {
74075 - struct ctl_table ipc_table;
74076 + ctl_table_no_const ipc_table;
74077
74078 memcpy(&ipc_table, table, sizeof(ipc_table));
74079 ipc_table.data = get_ipc(table);
74080 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74081 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74082 void __user *buffer, size_t *lenp, loff_t *ppos)
74083 {
74084 - struct ctl_table ipc_table;
74085 + ctl_table_no_const ipc_table;
74086
74087 memcpy(&ipc_table, table, sizeof(ipc_table));
74088 ipc_table.data = get_ipc(table);
74089 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74090 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74091 void __user *buffer, size_t *lenp, loff_t *ppos)
74092 {
74093 - struct ctl_table ipc_table;
74094 + ctl_table_no_const ipc_table;
74095 size_t lenp_bef = *lenp;
74096 int rc;
74097
74098 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74099 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74100 void __user *buffer, size_t *lenp, loff_t *ppos)
74101 {
74102 - struct ctl_table ipc_table;
74103 + ctl_table_no_const ipc_table;
74104 memcpy(&ipc_table, table, sizeof(ipc_table));
74105 ipc_table.data = get_ipc(table);
74106
74107 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74108 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74109 void __user *buffer, size_t *lenp, loff_t *ppos)
74110 {
74111 - struct ctl_table ipc_table;
74112 + ctl_table_no_const ipc_table;
74113 size_t lenp_bef = *lenp;
74114 int oldval;
74115 int rc;
74116 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74117 index 383d638..943fdbb 100644
74118 --- a/ipc/mq_sysctl.c
74119 +++ b/ipc/mq_sysctl.c
74120 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74121 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74122 void __user *buffer, size_t *lenp, loff_t *ppos)
74123 {
74124 - struct ctl_table mq_table;
74125 + ctl_table_no_const mq_table;
74126 memcpy(&mq_table, table, sizeof(mq_table));
74127 mq_table.data = get_mq(table);
74128
74129 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74130 index f3f40dc..ffe5a3a 100644
74131 --- a/ipc/mqueue.c
74132 +++ b/ipc/mqueue.c
74133 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74134 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74135 info->attr.mq_msgsize);
74136
74137 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74138 spin_lock(&mq_lock);
74139 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74140 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74141 diff --git a/ipc/msg.c b/ipc/msg.c
74142 index 31cd1bf..9778e0f8 100644
74143 --- a/ipc/msg.c
74144 +++ b/ipc/msg.c
74145 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74146 return security_msg_queue_associate(msq, msgflg);
74147 }
74148
74149 +static struct ipc_ops msg_ops = {
74150 + .getnew = newque,
74151 + .associate = msg_security,
74152 + .more_checks = NULL
74153 +};
74154 +
74155 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74156 {
74157 struct ipc_namespace *ns;
74158 - struct ipc_ops msg_ops;
74159 struct ipc_params msg_params;
74160
74161 ns = current->nsproxy->ipc_ns;
74162
74163 - msg_ops.getnew = newque;
74164 - msg_ops.associate = msg_security;
74165 - msg_ops.more_checks = NULL;
74166 -
74167 msg_params.key = key;
74168 msg_params.flg = msgflg;
74169
74170 @@ -872,6 +873,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp,
74171 goto out_unlock;
74172 break;
74173 }
74174 + msg = ERR_PTR(-EAGAIN);
74175 } else
74176 break;
74177 msg_counter++;
74178 diff --git a/ipc/sem.c b/ipc/sem.c
74179 index 58d31f1..cce7a55 100644
74180 --- a/ipc/sem.c
74181 +++ b/ipc/sem.c
74182 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74183 return 0;
74184 }
74185
74186 +static struct ipc_ops sem_ops = {
74187 + .getnew = newary,
74188 + .associate = sem_security,
74189 + .more_checks = sem_more_checks
74190 +};
74191 +
74192 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74193 {
74194 struct ipc_namespace *ns;
74195 - struct ipc_ops sem_ops;
74196 struct ipc_params sem_params;
74197
74198 ns = current->nsproxy->ipc_ns;
74199 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74200 if (nsems < 0 || nsems > ns->sc_semmsl)
74201 return -EINVAL;
74202
74203 - sem_ops.getnew = newary;
74204 - sem_ops.associate = sem_security;
74205 - sem_ops.more_checks = sem_more_checks;
74206 -
74207 sem_params.key = key;
74208 sem_params.flg = semflg;
74209 sem_params.u.nsems = nsems;
74210 diff --git a/ipc/shm.c b/ipc/shm.c
74211 index 4fa6d8f..55cff14 100644
74212 --- a/ipc/shm.c
74213 +++ b/ipc/shm.c
74214 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74215 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74216 #endif
74217
74218 +#ifdef CONFIG_GRKERNSEC
74219 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74220 + const time_t shm_createtime, const kuid_t cuid,
74221 + const int shmid);
74222 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74223 + const time_t shm_createtime);
74224 +#endif
74225 +
74226 void shm_init_ns(struct ipc_namespace *ns)
74227 {
74228 ns->shm_ctlmax = SHMMAX;
74229 @@ -521,6 +529,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74230 shp->shm_lprid = 0;
74231 shp->shm_atim = shp->shm_dtim = 0;
74232 shp->shm_ctim = get_seconds();
74233 +#ifdef CONFIG_GRKERNSEC
74234 + {
74235 + struct timespec timeval;
74236 + do_posix_clock_monotonic_gettime(&timeval);
74237 +
74238 + shp->shm_createtime = timeval.tv_sec;
74239 + }
74240 +#endif
74241 shp->shm_segsz = size;
74242 shp->shm_nattch = 0;
74243 shp->shm_file = file;
74244 @@ -572,18 +588,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74245 return 0;
74246 }
74247
74248 +static struct ipc_ops shm_ops = {
74249 + .getnew = newseg,
74250 + .associate = shm_security,
74251 + .more_checks = shm_more_checks
74252 +};
74253 +
74254 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74255 {
74256 struct ipc_namespace *ns;
74257 - struct ipc_ops shm_ops;
74258 struct ipc_params shm_params;
74259
74260 ns = current->nsproxy->ipc_ns;
74261
74262 - shm_ops.getnew = newseg;
74263 - shm_ops.associate = shm_security;
74264 - shm_ops.more_checks = shm_more_checks;
74265 -
74266 shm_params.key = key;
74267 shm_params.flg = shmflg;
74268 shm_params.u.size = size;
74269 @@ -1004,6 +1021,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74270 f_mode = FMODE_READ | FMODE_WRITE;
74271 }
74272 if (shmflg & SHM_EXEC) {
74273 +
74274 +#ifdef CONFIG_PAX_MPROTECT
74275 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74276 + goto out;
74277 +#endif
74278 +
74279 prot |= PROT_EXEC;
74280 acc_mode |= S_IXUGO;
74281 }
74282 @@ -1027,9 +1050,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74283 if (err)
74284 goto out_unlock;
74285
74286 +#ifdef CONFIG_GRKERNSEC
74287 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74288 + shp->shm_perm.cuid, shmid) ||
74289 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74290 + err = -EACCES;
74291 + goto out_unlock;
74292 + }
74293 +#endif
74294 +
74295 path = shp->shm_file->f_path;
74296 path_get(&path);
74297 shp->shm_nattch++;
74298 +#ifdef CONFIG_GRKERNSEC
74299 + shp->shm_lapid = current->pid;
74300 +#endif
74301 size = i_size_read(path.dentry->d_inode);
74302 shm_unlock(shp);
74303
74304 diff --git a/kernel/acct.c b/kernel/acct.c
74305 index 051e071..15e0920 100644
74306 --- a/kernel/acct.c
74307 +++ b/kernel/acct.c
74308 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74309 */
74310 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74311 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74312 - file->f_op->write(file, (char *)&ac,
74313 + file->f_op->write(file, (char __force_user *)&ac,
74314 sizeof(acct_t), &file->f_pos);
74315 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74316 set_fs(fs);
74317 diff --git a/kernel/audit.c b/kernel/audit.c
74318 index d596e53..dbef3c3 100644
74319 --- a/kernel/audit.c
74320 +++ b/kernel/audit.c
74321 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
74322 3) suppressed due to audit_rate_limit
74323 4) suppressed due to audit_backlog_limit
74324 */
74325 -static atomic_t audit_lost = ATOMIC_INIT(0);
74326 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74327
74328 /* The netlink socket. */
74329 static struct sock *audit_sock;
74330 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
74331 unsigned long now;
74332 int print;
74333
74334 - atomic_inc(&audit_lost);
74335 + atomic_inc_unchecked(&audit_lost);
74336
74337 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74338
74339 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74340 printk(KERN_WARNING
74341 "audit: audit_lost=%d audit_rate_limit=%d "
74342 "audit_backlog_limit=%d\n",
74343 - atomic_read(&audit_lost),
74344 + atomic_read_unchecked(&audit_lost),
74345 audit_rate_limit,
74346 audit_backlog_limit);
74347 audit_panic(message);
74348 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74349 status_set.pid = audit_pid;
74350 status_set.rate_limit = audit_rate_limit;
74351 status_set.backlog_limit = audit_backlog_limit;
74352 - status_set.lost = atomic_read(&audit_lost);
74353 + status_set.lost = atomic_read_unchecked(&audit_lost);
74354 status_set.backlog = skb_queue_len(&audit_skb_queue);
74355 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74356 &status_set, sizeof(status_set));
74357 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74358 index a371f85..da826c1 100644
74359 --- a/kernel/auditsc.c
74360 +++ b/kernel/auditsc.c
74361 @@ -2292,7 +2292,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74362 }
74363
74364 /* global counter which is incremented every time something logs in */
74365 -static atomic_t session_id = ATOMIC_INIT(0);
74366 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74367
74368 /**
74369 * audit_set_loginuid - set current task's audit_context loginuid
74370 @@ -2316,7 +2316,7 @@ int audit_set_loginuid(kuid_t loginuid)
74371 return -EPERM;
74372 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74373
74374 - sessionid = atomic_inc_return(&session_id);
74375 + sessionid = atomic_inc_return_unchecked(&session_id);
74376 if (context && context->in_syscall) {
74377 struct audit_buffer *ab;
74378
74379 diff --git a/kernel/capability.c b/kernel/capability.c
74380 index 493d972..f87dfbd 100644
74381 --- a/kernel/capability.c
74382 +++ b/kernel/capability.c
74383 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74384 * before modification is attempted and the application
74385 * fails.
74386 */
74387 + if (tocopy > ARRAY_SIZE(kdata))
74388 + return -EFAULT;
74389 +
74390 if (copy_to_user(dataptr, kdata, tocopy
74391 * sizeof(struct __user_cap_data_struct))) {
74392 return -EFAULT;
74393 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74394 int ret;
74395
74396 rcu_read_lock();
74397 - ret = security_capable(__task_cred(t), ns, cap);
74398 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74399 + gr_task_is_capable(t, __task_cred(t), cap);
74400 rcu_read_unlock();
74401
74402 - return (ret == 0);
74403 + return ret;
74404 }
74405
74406 /**
74407 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74408 int ret;
74409
74410 rcu_read_lock();
74411 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74412 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74413 rcu_read_unlock();
74414
74415 - return (ret == 0);
74416 + return ret;
74417 }
74418
74419 /**
74420 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74421 BUG();
74422 }
74423
74424 - if (security_capable(current_cred(), ns, cap) == 0) {
74425 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74426 current->flags |= PF_SUPERPRIV;
74427 return true;
74428 }
74429 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74430 }
74431 EXPORT_SYMBOL(ns_capable);
74432
74433 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74434 +{
74435 + if (unlikely(!cap_valid(cap))) {
74436 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74437 + BUG();
74438 + }
74439 +
74440 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74441 + current->flags |= PF_SUPERPRIV;
74442 + return true;
74443 + }
74444 + return false;
74445 +}
74446 +EXPORT_SYMBOL(ns_capable_nolog);
74447 +
74448 /**
74449 * capable - Determine if the current task has a superior capability in effect
74450 * @cap: The capability to be tested for
74451 @@ -408,6 +427,12 @@ bool capable(int cap)
74452 }
74453 EXPORT_SYMBOL(capable);
74454
74455 +bool capable_nolog(int cap)
74456 +{
74457 + return ns_capable_nolog(&init_user_ns, cap);
74458 +}
74459 +EXPORT_SYMBOL(capable_nolog);
74460 +
74461 /**
74462 * nsown_capable - Check superior capability to one's own user_ns
74463 * @cap: The capability in question
74464 @@ -440,3 +465,10 @@ bool inode_capable(const struct inode *inode, int cap)
74465
74466 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74467 }
74468 +
74469 +bool inode_capable_nolog(const struct inode *inode, int cap)
74470 +{
74471 + struct user_namespace *ns = current_user_ns();
74472 +
74473 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74474 +}
74475 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74476 index 1e23664..570a83d 100644
74477 --- a/kernel/cgroup.c
74478 +++ b/kernel/cgroup.c
74479 @@ -5543,7 +5543,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74480 struct css_set *cg = link->cg;
74481 struct task_struct *task;
74482 int count = 0;
74483 - seq_printf(seq, "css_set %p\n", cg);
74484 + seq_printf(seq, "css_set %pK\n", cg);
74485 list_for_each_entry(task, &cg->tasks, cg_list) {
74486 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74487 seq_puts(seq, " ...\n");
74488 diff --git a/kernel/compat.c b/kernel/compat.c
74489 index 36700e9..73d770c 100644
74490 --- a/kernel/compat.c
74491 +++ b/kernel/compat.c
74492 @@ -13,6 +13,7 @@
74493
74494 #include <linux/linkage.h>
74495 #include <linux/compat.h>
74496 +#include <linux/module.h>
74497 #include <linux/errno.h>
74498 #include <linux/time.h>
74499 #include <linux/signal.h>
74500 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74501 mm_segment_t oldfs;
74502 long ret;
74503
74504 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74505 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74506 oldfs = get_fs();
74507 set_fs(KERNEL_DS);
74508 ret = hrtimer_nanosleep_restart(restart);
74509 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74510 oldfs = get_fs();
74511 set_fs(KERNEL_DS);
74512 ret = hrtimer_nanosleep(&tu,
74513 - rmtp ? (struct timespec __user *)&rmt : NULL,
74514 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74515 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74516 set_fs(oldfs);
74517
74518 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74519 mm_segment_t old_fs = get_fs();
74520
74521 set_fs(KERNEL_DS);
74522 - ret = sys_sigpending((old_sigset_t __user *) &s);
74523 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74524 set_fs(old_fs);
74525 if (ret == 0)
74526 ret = put_user(s, set);
74527 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74528 mm_segment_t old_fs = get_fs();
74529
74530 set_fs(KERNEL_DS);
74531 - ret = sys_old_getrlimit(resource, &r);
74532 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74533 set_fs(old_fs);
74534
74535 if (!ret) {
74536 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74537 mm_segment_t old_fs = get_fs();
74538
74539 set_fs(KERNEL_DS);
74540 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74541 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74542 set_fs(old_fs);
74543
74544 if (ret)
74545 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74546 set_fs (KERNEL_DS);
74547 ret = sys_wait4(pid,
74548 (stat_addr ?
74549 - (unsigned int __user *) &status : NULL),
74550 - options, (struct rusage __user *) &r);
74551 + (unsigned int __force_user *) &status : NULL),
74552 + options, (struct rusage __force_user *) &r);
74553 set_fs (old_fs);
74554
74555 if (ret > 0) {
74556 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74557 memset(&info, 0, sizeof(info));
74558
74559 set_fs(KERNEL_DS);
74560 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74561 - uru ? (struct rusage __user *)&ru : NULL);
74562 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74563 + uru ? (struct rusage __force_user *)&ru : NULL);
74564 set_fs(old_fs);
74565
74566 if ((ret < 0) || (info.si_signo == 0))
74567 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74568 oldfs = get_fs();
74569 set_fs(KERNEL_DS);
74570 err = sys_timer_settime(timer_id, flags,
74571 - (struct itimerspec __user *) &newts,
74572 - (struct itimerspec __user *) &oldts);
74573 + (struct itimerspec __force_user *) &newts,
74574 + (struct itimerspec __force_user *) &oldts);
74575 set_fs(oldfs);
74576 if (!err && old && put_compat_itimerspec(old, &oldts))
74577 return -EFAULT;
74578 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74579 oldfs = get_fs();
74580 set_fs(KERNEL_DS);
74581 err = sys_timer_gettime(timer_id,
74582 - (struct itimerspec __user *) &ts);
74583 + (struct itimerspec __force_user *) &ts);
74584 set_fs(oldfs);
74585 if (!err && put_compat_itimerspec(setting, &ts))
74586 return -EFAULT;
74587 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74588 oldfs = get_fs();
74589 set_fs(KERNEL_DS);
74590 err = sys_clock_settime(which_clock,
74591 - (struct timespec __user *) &ts);
74592 + (struct timespec __force_user *) &ts);
74593 set_fs(oldfs);
74594 return err;
74595 }
74596 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74597 oldfs = get_fs();
74598 set_fs(KERNEL_DS);
74599 err = sys_clock_gettime(which_clock,
74600 - (struct timespec __user *) &ts);
74601 + (struct timespec __force_user *) &ts);
74602 set_fs(oldfs);
74603 if (!err && put_compat_timespec(&ts, tp))
74604 return -EFAULT;
74605 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74606
74607 oldfs = get_fs();
74608 set_fs(KERNEL_DS);
74609 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74610 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74611 set_fs(oldfs);
74612
74613 err = compat_put_timex(utp, &txc);
74614 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74615 oldfs = get_fs();
74616 set_fs(KERNEL_DS);
74617 err = sys_clock_getres(which_clock,
74618 - (struct timespec __user *) &ts);
74619 + (struct timespec __force_user *) &ts);
74620 set_fs(oldfs);
74621 if (!err && tp && put_compat_timespec(&ts, tp))
74622 return -EFAULT;
74623 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74624 long err;
74625 mm_segment_t oldfs;
74626 struct timespec tu;
74627 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74628 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74629
74630 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74631 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74632 oldfs = get_fs();
74633 set_fs(KERNEL_DS);
74634 err = clock_nanosleep_restart(restart);
74635 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74636 oldfs = get_fs();
74637 set_fs(KERNEL_DS);
74638 err = sys_clock_nanosleep(which_clock, flags,
74639 - (struct timespec __user *) &in,
74640 - (struct timespec __user *) &out);
74641 + (struct timespec __force_user *) &in,
74642 + (struct timespec __force_user *) &out);
74643 set_fs(oldfs);
74644
74645 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74646 diff --git a/kernel/configs.c b/kernel/configs.c
74647 index 42e8fa0..9e7406b 100644
74648 --- a/kernel/configs.c
74649 +++ b/kernel/configs.c
74650 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74651 struct proc_dir_entry *entry;
74652
74653 /* create the current config file */
74654 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74655 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74656 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74657 + &ikconfig_file_ops);
74658 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74659 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74660 + &ikconfig_file_ops);
74661 +#endif
74662 +#else
74663 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74664 &ikconfig_file_ops);
74665 +#endif
74666 +
74667 if (!entry)
74668 return -ENOMEM;
74669
74670 diff --git a/kernel/cred.c b/kernel/cred.c
74671 index e0573a4..3874e41 100644
74672 --- a/kernel/cred.c
74673 +++ b/kernel/cred.c
74674 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74675 validate_creds(cred);
74676 alter_cred_subscribers(cred, -1);
74677 put_cred(cred);
74678 +
74679 +#ifdef CONFIG_GRKERNSEC_SETXID
74680 + cred = (struct cred *) tsk->delayed_cred;
74681 + if (cred != NULL) {
74682 + tsk->delayed_cred = NULL;
74683 + validate_creds(cred);
74684 + alter_cred_subscribers(cred, -1);
74685 + put_cred(cred);
74686 + }
74687 +#endif
74688 }
74689
74690 /**
74691 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74692 * Always returns 0 thus allowing this function to be tail-called at the end
74693 * of, say, sys_setgid().
74694 */
74695 -int commit_creds(struct cred *new)
74696 +static int __commit_creds(struct cred *new)
74697 {
74698 struct task_struct *task = current;
74699 const struct cred *old = task->real_cred;
74700 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74701
74702 get_cred(new); /* we will require a ref for the subj creds too */
74703
74704 + gr_set_role_label(task, new->uid, new->gid);
74705 +
74706 /* dumpability changes */
74707 if (!uid_eq(old->euid, new->euid) ||
74708 !gid_eq(old->egid, new->egid) ||
74709 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74710 put_cred(old);
74711 return 0;
74712 }
74713 +#ifdef CONFIG_GRKERNSEC_SETXID
74714 +extern int set_user(struct cred *new);
74715 +
74716 +void gr_delayed_cred_worker(void)
74717 +{
74718 + const struct cred *new = current->delayed_cred;
74719 + struct cred *ncred;
74720 +
74721 + current->delayed_cred = NULL;
74722 +
74723 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74724 + // from doing get_cred on it when queueing this
74725 + put_cred(new);
74726 + return;
74727 + } else if (new == NULL)
74728 + return;
74729 +
74730 + ncred = prepare_creds();
74731 + if (!ncred)
74732 + goto die;
74733 + // uids
74734 + ncred->uid = new->uid;
74735 + ncred->euid = new->euid;
74736 + ncred->suid = new->suid;
74737 + ncred->fsuid = new->fsuid;
74738 + // gids
74739 + ncred->gid = new->gid;
74740 + ncred->egid = new->egid;
74741 + ncred->sgid = new->sgid;
74742 + ncred->fsgid = new->fsgid;
74743 + // groups
74744 + if (set_groups(ncred, new->group_info) < 0) {
74745 + abort_creds(ncred);
74746 + goto die;
74747 + }
74748 + // caps
74749 + ncred->securebits = new->securebits;
74750 + ncred->cap_inheritable = new->cap_inheritable;
74751 + ncred->cap_permitted = new->cap_permitted;
74752 + ncred->cap_effective = new->cap_effective;
74753 + ncred->cap_bset = new->cap_bset;
74754 +
74755 + if (set_user(ncred)) {
74756 + abort_creds(ncred);
74757 + goto die;
74758 + }
74759 +
74760 + // from doing get_cred on it when queueing this
74761 + put_cred(new);
74762 +
74763 + __commit_creds(ncred);
74764 + return;
74765 +die:
74766 + // from doing get_cred on it when queueing this
74767 + put_cred(new);
74768 + do_group_exit(SIGKILL);
74769 +}
74770 +#endif
74771 +
74772 +int commit_creds(struct cred *new)
74773 +{
74774 +#ifdef CONFIG_GRKERNSEC_SETXID
74775 + int ret;
74776 + int schedule_it = 0;
74777 + struct task_struct *t;
74778 +
74779 + /* we won't get called with tasklist_lock held for writing
74780 + and interrupts disabled as the cred struct in that case is
74781 + init_cred
74782 + */
74783 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74784 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74785 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74786 + schedule_it = 1;
74787 + }
74788 + ret = __commit_creds(new);
74789 + if (schedule_it) {
74790 + rcu_read_lock();
74791 + read_lock(&tasklist_lock);
74792 + for (t = next_thread(current); t != current;
74793 + t = next_thread(t)) {
74794 + if (t->delayed_cred == NULL) {
74795 + t->delayed_cred = get_cred(new);
74796 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74797 + set_tsk_need_resched(t);
74798 + }
74799 + }
74800 + read_unlock(&tasklist_lock);
74801 + rcu_read_unlock();
74802 + }
74803 + return ret;
74804 +#else
74805 + return __commit_creds(new);
74806 +#endif
74807 +}
74808 +
74809 EXPORT_SYMBOL(commit_creds);
74810
74811 /**
74812 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
74813 index 9a61738..c5c8f3a 100644
74814 --- a/kernel/debug/debug_core.c
74815 +++ b/kernel/debug/debug_core.c
74816 @@ -122,7 +122,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
74817 */
74818 static atomic_t masters_in_kgdb;
74819 static atomic_t slaves_in_kgdb;
74820 -static atomic_t kgdb_break_tasklet_var;
74821 +static atomic_unchecked_t kgdb_break_tasklet_var;
74822 atomic_t kgdb_setting_breakpoint;
74823
74824 struct task_struct *kgdb_usethread;
74825 @@ -132,7 +132,7 @@ int kgdb_single_step;
74826 static pid_t kgdb_sstep_pid;
74827
74828 /* to keep track of the CPU which is doing the single stepping*/
74829 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74830 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74831
74832 /*
74833 * If you are debugging a problem where roundup (the collection of
74834 @@ -540,7 +540,7 @@ return_normal:
74835 * kernel will only try for the value of sstep_tries before
74836 * giving up and continuing on.
74837 */
74838 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
74839 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
74840 (kgdb_info[cpu].task &&
74841 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
74842 atomic_set(&kgdb_active, -1);
74843 @@ -634,8 +634,8 @@ cpu_master_loop:
74844 }
74845
74846 kgdb_restore:
74847 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
74848 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
74849 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
74850 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
74851 if (kgdb_info[sstep_cpu].task)
74852 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
74853 else
74854 @@ -887,18 +887,18 @@ static void kgdb_unregister_callbacks(void)
74855 static void kgdb_tasklet_bpt(unsigned long ing)
74856 {
74857 kgdb_breakpoint();
74858 - atomic_set(&kgdb_break_tasklet_var, 0);
74859 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
74860 }
74861
74862 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
74863
74864 void kgdb_schedule_breakpoint(void)
74865 {
74866 - if (atomic_read(&kgdb_break_tasklet_var) ||
74867 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
74868 atomic_read(&kgdb_active) != -1 ||
74869 atomic_read(&kgdb_setting_breakpoint))
74870 return;
74871 - atomic_inc(&kgdb_break_tasklet_var);
74872 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
74873 tasklet_schedule(&kgdb_tasklet_breakpoint);
74874 }
74875 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
74876 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
74877 index 8875254..7cf4928 100644
74878 --- a/kernel/debug/kdb/kdb_main.c
74879 +++ b/kernel/debug/kdb/kdb_main.c
74880 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
74881 continue;
74882
74883 kdb_printf("%-20s%8u 0x%p ", mod->name,
74884 - mod->core_size, (void *)mod);
74885 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
74886 #ifdef CONFIG_MODULE_UNLOAD
74887 kdb_printf("%4ld ", module_refcount(mod));
74888 #endif
74889 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
74890 kdb_printf(" (Loading)");
74891 else
74892 kdb_printf(" (Live)");
74893 - kdb_printf(" 0x%p", mod->module_core);
74894 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
74895
74896 #ifdef CONFIG_MODULE_UNLOAD
74897 {
74898 diff --git a/kernel/events/core.c b/kernel/events/core.c
74899 index 7b6646a..3cb1135 100644
74900 --- a/kernel/events/core.c
74901 +++ b/kernel/events/core.c
74902 @@ -182,7 +182,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
74903 return 0;
74904 }
74905
74906 -static atomic64_t perf_event_id;
74907 +static atomic64_unchecked_t perf_event_id;
74908
74909 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
74910 enum event_type_t event_type);
74911 @@ -2677,7 +2677,7 @@ static void __perf_event_read(void *info)
74912
74913 static inline u64 perf_event_count(struct perf_event *event)
74914 {
74915 - return local64_read(&event->count) + atomic64_read(&event->child_count);
74916 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
74917 }
74918
74919 static u64 perf_event_read(struct perf_event *event)
74920 @@ -3007,9 +3007,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
74921 mutex_lock(&event->child_mutex);
74922 total += perf_event_read(event);
74923 *enabled += event->total_time_enabled +
74924 - atomic64_read(&event->child_total_time_enabled);
74925 + atomic64_read_unchecked(&event->child_total_time_enabled);
74926 *running += event->total_time_running +
74927 - atomic64_read(&event->child_total_time_running);
74928 + atomic64_read_unchecked(&event->child_total_time_running);
74929
74930 list_for_each_entry(child, &event->child_list, child_list) {
74931 total += perf_event_read(child);
74932 @@ -3412,10 +3412,10 @@ void perf_event_update_userpage(struct perf_event *event)
74933 userpg->offset -= local64_read(&event->hw.prev_count);
74934
74935 userpg->time_enabled = enabled +
74936 - atomic64_read(&event->child_total_time_enabled);
74937 + atomic64_read_unchecked(&event->child_total_time_enabled);
74938
74939 userpg->time_running = running +
74940 - atomic64_read(&event->child_total_time_running);
74941 + atomic64_read_unchecked(&event->child_total_time_running);
74942
74943 arch_perf_update_userpage(userpg, now);
74944
74945 @@ -3974,11 +3974,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
74946 values[n++] = perf_event_count(event);
74947 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
74948 values[n++] = enabled +
74949 - atomic64_read(&event->child_total_time_enabled);
74950 + atomic64_read_unchecked(&event->child_total_time_enabled);
74951 }
74952 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
74953 values[n++] = running +
74954 - atomic64_read(&event->child_total_time_running);
74955 + atomic64_read_unchecked(&event->child_total_time_running);
74956 }
74957 if (read_format & PERF_FORMAT_ID)
74958 values[n++] = primary_event_id(event);
74959 @@ -4721,12 +4721,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
74960 * need to add enough zero bytes after the string to handle
74961 * the 64bit alignment we do later.
74962 */
74963 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
74964 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
74965 if (!buf) {
74966 name = strncpy(tmp, "//enomem", sizeof(tmp));
74967 goto got_name;
74968 }
74969 - name = d_path(&file->f_path, buf, PATH_MAX);
74970 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
74971 if (IS_ERR(name)) {
74972 name = strncpy(tmp, "//toolong", sizeof(tmp));
74973 goto got_name;
74974 @@ -6165,7 +6165,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
74975 event->parent = parent_event;
74976
74977 event->ns = get_pid_ns(task_active_pid_ns(current));
74978 - event->id = atomic64_inc_return(&perf_event_id);
74979 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
74980
74981 event->state = PERF_EVENT_STATE_INACTIVE;
74982
74983 @@ -6790,10 +6790,10 @@ static void sync_child_event(struct perf_event *child_event,
74984 /*
74985 * Add back the child's count to the parent's count:
74986 */
74987 - atomic64_add(child_val, &parent_event->child_count);
74988 - atomic64_add(child_event->total_time_enabled,
74989 + atomic64_add_unchecked(child_val, &parent_event->child_count);
74990 + atomic64_add_unchecked(child_event->total_time_enabled,
74991 &parent_event->child_total_time_enabled);
74992 - atomic64_add(child_event->total_time_running,
74993 + atomic64_add_unchecked(child_event->total_time_running,
74994 &parent_event->child_total_time_running);
74995
74996 /*
74997 diff --git a/kernel/exit.c b/kernel/exit.c
74998 index b4df219..f13c02d 100644
74999 --- a/kernel/exit.c
75000 +++ b/kernel/exit.c
75001 @@ -170,6 +170,10 @@ void release_task(struct task_struct * p)
75002 struct task_struct *leader;
75003 int zap_leader;
75004 repeat:
75005 +#ifdef CONFIG_NET
75006 + gr_del_task_from_ip_table(p);
75007 +#endif
75008 +
75009 /* don't need to get the RCU readlock here - the process is dead and
75010 * can't be modifying its own credentials. But shut RCU-lockdep up */
75011 rcu_read_lock();
75012 @@ -338,7 +342,7 @@ int allow_signal(int sig)
75013 * know it'll be handled, so that they don't get converted to
75014 * SIGKILL or just silently dropped.
75015 */
75016 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75017 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75018 recalc_sigpending();
75019 spin_unlock_irq(&current->sighand->siglock);
75020 return 0;
75021 @@ -708,6 +712,8 @@ void do_exit(long code)
75022 struct task_struct *tsk = current;
75023 int group_dead;
75024
75025 + set_fs(USER_DS);
75026 +
75027 profile_task_exit(tsk);
75028
75029 WARN_ON(blk_needs_flush_plug(tsk));
75030 @@ -724,7 +730,6 @@ void do_exit(long code)
75031 * mm_release()->clear_child_tid() from writing to a user-controlled
75032 * kernel address.
75033 */
75034 - set_fs(USER_DS);
75035
75036 ptrace_event(PTRACE_EVENT_EXIT, code);
75037
75038 @@ -783,6 +788,9 @@ void do_exit(long code)
75039 tsk->exit_code = code;
75040 taskstats_exit(tsk, group_dead);
75041
75042 + gr_acl_handle_psacct(tsk, code);
75043 + gr_acl_handle_exit();
75044 +
75045 exit_mm(tsk);
75046
75047 if (group_dead)
75048 @@ -903,7 +911,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75049 * Take down every thread in the group. This is called by fatal signals
75050 * as well as by sys_exit_group (below).
75051 */
75052 -void
75053 +__noreturn void
75054 do_group_exit(int exit_code)
75055 {
75056 struct signal_struct *sig = current->signal;
75057 diff --git a/kernel/fork.c b/kernel/fork.c
75058 index 5630e52..0cee608 100644
75059 --- a/kernel/fork.c
75060 +++ b/kernel/fork.c
75061 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75062 *stackend = STACK_END_MAGIC; /* for overflow detection */
75063
75064 #ifdef CONFIG_CC_STACKPROTECTOR
75065 - tsk->stack_canary = get_random_int();
75066 + tsk->stack_canary = pax_get_random_long();
75067 #endif
75068
75069 /*
75070 @@ -344,13 +344,81 @@ free_tsk:
75071 }
75072
75073 #ifdef CONFIG_MMU
75074 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75075 +{
75076 + struct vm_area_struct *tmp;
75077 + unsigned long charge;
75078 + struct mempolicy *pol;
75079 + struct file *file;
75080 +
75081 + charge = 0;
75082 + if (mpnt->vm_flags & VM_ACCOUNT) {
75083 + unsigned long len = vma_pages(mpnt);
75084 +
75085 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75086 + goto fail_nomem;
75087 + charge = len;
75088 + }
75089 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75090 + if (!tmp)
75091 + goto fail_nomem;
75092 + *tmp = *mpnt;
75093 + tmp->vm_mm = mm;
75094 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75095 + pol = mpol_dup(vma_policy(mpnt));
75096 + if (IS_ERR(pol))
75097 + goto fail_nomem_policy;
75098 + vma_set_policy(tmp, pol);
75099 + if (anon_vma_fork(tmp, mpnt))
75100 + goto fail_nomem_anon_vma_fork;
75101 + tmp->vm_flags &= ~VM_LOCKED;
75102 + tmp->vm_next = tmp->vm_prev = NULL;
75103 + tmp->vm_mirror = NULL;
75104 + file = tmp->vm_file;
75105 + if (file) {
75106 + struct inode *inode = file->f_path.dentry->d_inode;
75107 + struct address_space *mapping = file->f_mapping;
75108 +
75109 + get_file(file);
75110 + if (tmp->vm_flags & VM_DENYWRITE)
75111 + atomic_dec(&inode->i_writecount);
75112 + mutex_lock(&mapping->i_mmap_mutex);
75113 + if (tmp->vm_flags & VM_SHARED)
75114 + mapping->i_mmap_writable++;
75115 + flush_dcache_mmap_lock(mapping);
75116 + /* insert tmp into the share list, just after mpnt */
75117 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75118 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75119 + else
75120 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75121 + flush_dcache_mmap_unlock(mapping);
75122 + mutex_unlock(&mapping->i_mmap_mutex);
75123 + }
75124 +
75125 + /*
75126 + * Clear hugetlb-related page reserves for children. This only
75127 + * affects MAP_PRIVATE mappings. Faults generated by the child
75128 + * are not guaranteed to succeed, even if read-only
75129 + */
75130 + if (is_vm_hugetlb_page(tmp))
75131 + reset_vma_resv_huge_pages(tmp);
75132 +
75133 + return tmp;
75134 +
75135 +fail_nomem_anon_vma_fork:
75136 + mpol_put(pol);
75137 +fail_nomem_policy:
75138 + kmem_cache_free(vm_area_cachep, tmp);
75139 +fail_nomem:
75140 + vm_unacct_memory(charge);
75141 + return NULL;
75142 +}
75143 +
75144 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75145 {
75146 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75147 struct rb_node **rb_link, *rb_parent;
75148 int retval;
75149 - unsigned long charge;
75150 - struct mempolicy *pol;
75151
75152 uprobe_start_dup_mmap();
75153 down_write(&oldmm->mmap_sem);
75154 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75155 mm->locked_vm = 0;
75156 mm->mmap = NULL;
75157 mm->mmap_cache = NULL;
75158 - mm->free_area_cache = oldmm->mmap_base;
75159 - mm->cached_hole_size = ~0UL;
75160 + mm->free_area_cache = oldmm->free_area_cache;
75161 + mm->cached_hole_size = oldmm->cached_hole_size;
75162 mm->map_count = 0;
75163 cpumask_clear(mm_cpumask(mm));
75164 mm->mm_rb = RB_ROOT;
75165 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75166
75167 prev = NULL;
75168 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75169 - struct file *file;
75170 -
75171 if (mpnt->vm_flags & VM_DONTCOPY) {
75172 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75173 -vma_pages(mpnt));
75174 continue;
75175 }
75176 - charge = 0;
75177 - if (mpnt->vm_flags & VM_ACCOUNT) {
75178 - unsigned long len = vma_pages(mpnt);
75179 -
75180 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75181 - goto fail_nomem;
75182 - charge = len;
75183 - }
75184 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75185 - if (!tmp)
75186 - goto fail_nomem;
75187 - *tmp = *mpnt;
75188 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75189 - pol = mpol_dup(vma_policy(mpnt));
75190 - retval = PTR_ERR(pol);
75191 - if (IS_ERR(pol))
75192 - goto fail_nomem_policy;
75193 - vma_set_policy(tmp, pol);
75194 - tmp->vm_mm = mm;
75195 - if (anon_vma_fork(tmp, mpnt))
75196 - goto fail_nomem_anon_vma_fork;
75197 - tmp->vm_flags &= ~VM_LOCKED;
75198 - tmp->vm_next = tmp->vm_prev = NULL;
75199 - file = tmp->vm_file;
75200 - if (file) {
75201 - struct inode *inode = file->f_path.dentry->d_inode;
75202 - struct address_space *mapping = file->f_mapping;
75203 -
75204 - get_file(file);
75205 - if (tmp->vm_flags & VM_DENYWRITE)
75206 - atomic_dec(&inode->i_writecount);
75207 - mutex_lock(&mapping->i_mmap_mutex);
75208 - if (tmp->vm_flags & VM_SHARED)
75209 - mapping->i_mmap_writable++;
75210 - flush_dcache_mmap_lock(mapping);
75211 - /* insert tmp into the share list, just after mpnt */
75212 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75213 - vma_nonlinear_insert(tmp,
75214 - &mapping->i_mmap_nonlinear);
75215 - else
75216 - vma_interval_tree_insert_after(tmp, mpnt,
75217 - &mapping->i_mmap);
75218 - flush_dcache_mmap_unlock(mapping);
75219 - mutex_unlock(&mapping->i_mmap_mutex);
75220 + tmp = dup_vma(mm, oldmm, mpnt);
75221 + if (!tmp) {
75222 + retval = -ENOMEM;
75223 + goto out;
75224 }
75225
75226 /*
75227 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75228 if (retval)
75229 goto out;
75230 }
75231 +
75232 +#ifdef CONFIG_PAX_SEGMEXEC
75233 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75234 + struct vm_area_struct *mpnt_m;
75235 +
75236 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75237 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75238 +
75239 + if (!mpnt->vm_mirror)
75240 + continue;
75241 +
75242 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75243 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75244 + mpnt->vm_mirror = mpnt_m;
75245 + } else {
75246 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75247 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75248 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75249 + mpnt->vm_mirror->vm_mirror = mpnt;
75250 + }
75251 + }
75252 + BUG_ON(mpnt_m);
75253 + }
75254 +#endif
75255 +
75256 /* a new mm has just been created */
75257 arch_dup_mmap(oldmm, mm);
75258 retval = 0;
75259 @@ -472,14 +523,6 @@ out:
75260 up_write(&oldmm->mmap_sem);
75261 uprobe_end_dup_mmap();
75262 return retval;
75263 -fail_nomem_anon_vma_fork:
75264 - mpol_put(pol);
75265 -fail_nomem_policy:
75266 - kmem_cache_free(vm_area_cachep, tmp);
75267 -fail_nomem:
75268 - retval = -ENOMEM;
75269 - vm_unacct_memory(charge);
75270 - goto out;
75271 }
75272
75273 static inline int mm_alloc_pgd(struct mm_struct *mm)
75274 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75275 return ERR_PTR(err);
75276
75277 mm = get_task_mm(task);
75278 - if (mm && mm != current->mm &&
75279 - !ptrace_may_access(task, mode)) {
75280 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75281 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75282 mmput(mm);
75283 mm = ERR_PTR(-EACCES);
75284 }
75285 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75286 spin_unlock(&fs->lock);
75287 return -EAGAIN;
75288 }
75289 - fs->users++;
75290 + atomic_inc(&fs->users);
75291 spin_unlock(&fs->lock);
75292 return 0;
75293 }
75294 tsk->fs = copy_fs_struct(fs);
75295 if (!tsk->fs)
75296 return -ENOMEM;
75297 + /* Carry through gr_chroot_dentry and is_chrooted instead
75298 + of recomputing it here. Already copied when the task struct
75299 + is duplicated. This allows pivot_root to not be treated as
75300 + a chroot
75301 + */
75302 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75303 +
75304 return 0;
75305 }
75306
75307 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75308 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75309 #endif
75310 retval = -EAGAIN;
75311 +
75312 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75313 +
75314 if (atomic_read(&p->real_cred->user->processes) >=
75315 task_rlimit(p, RLIMIT_NPROC)) {
75316 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75317 @@ -1435,6 +1488,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75318 goto bad_fork_free_pid;
75319 }
75320
75321 + /* synchronizes with gr_set_acls()
75322 + we need to call this past the point of no return for fork()
75323 + */
75324 + gr_copy_label(p);
75325 +
75326 if (clone_flags & CLONE_THREAD) {
75327 current->signal->nr_threads++;
75328 atomic_inc(&current->signal->live);
75329 @@ -1518,6 +1576,8 @@ bad_fork_cleanup_count:
75330 bad_fork_free:
75331 free_task(p);
75332 fork_out:
75333 + gr_log_forkfail(retval);
75334 +
75335 return ERR_PTR(retval);
75336 }
75337
75338 @@ -1568,6 +1628,23 @@ long do_fork(unsigned long clone_flags,
75339 return -EINVAL;
75340 }
75341
75342 +#ifdef CONFIG_GRKERNSEC
75343 + if (clone_flags & CLONE_NEWUSER) {
75344 + /*
75345 + * This doesn't really inspire confidence:
75346 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75347 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75348 + * Increases kernel attack surface in areas developers
75349 + * previously cared little about ("low importance due
75350 + * to requiring "root" capability")
75351 + * To be removed when this code receives *proper* review
75352 + */
75353 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75354 + !capable(CAP_SETGID))
75355 + return -EPERM;
75356 + }
75357 +#endif
75358 +
75359 /*
75360 * Determine whether and which event to report to ptracer. When
75361 * called from kernel_thread or CLONE_UNTRACED is explicitly
75362 @@ -1602,6 +1679,8 @@ long do_fork(unsigned long clone_flags,
75363 if (clone_flags & CLONE_PARENT_SETTID)
75364 put_user(nr, parent_tidptr);
75365
75366 + gr_handle_brute_check();
75367 +
75368 if (clone_flags & CLONE_VFORK) {
75369 p->vfork_done = &vfork;
75370 init_completion(&vfork);
75371 @@ -1755,7 +1834,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75372 return 0;
75373
75374 /* don't need lock here; in the worst case we'll do useless copy */
75375 - if (fs->users == 1)
75376 + if (atomic_read(&fs->users) == 1)
75377 return 0;
75378
75379 *new_fsp = copy_fs_struct(fs);
75380 @@ -1869,7 +1948,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75381 fs = current->fs;
75382 spin_lock(&fs->lock);
75383 current->fs = new_fs;
75384 - if (--fs->users)
75385 + gr_set_chroot_entries(current, &current->fs->root);
75386 + if (atomic_dec_return(&fs->users))
75387 new_fs = NULL;
75388 else
75389 new_fs = fs;
75390 diff --git a/kernel/futex.c b/kernel/futex.c
75391 index 8879430..31696f1 100644
75392 --- a/kernel/futex.c
75393 +++ b/kernel/futex.c
75394 @@ -54,6 +54,7 @@
75395 #include <linux/mount.h>
75396 #include <linux/pagemap.h>
75397 #include <linux/syscalls.h>
75398 +#include <linux/ptrace.h>
75399 #include <linux/signal.h>
75400 #include <linux/export.h>
75401 #include <linux/magic.h>
75402 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75403 struct page *page, *page_head;
75404 int err, ro = 0;
75405
75406 +#ifdef CONFIG_PAX_SEGMEXEC
75407 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75408 + return -EFAULT;
75409 +#endif
75410 +
75411 /*
75412 * The futex address must be "naturally" aligned.
75413 */
75414 @@ -2731,6 +2737,7 @@ static int __init futex_init(void)
75415 {
75416 u32 curval;
75417 int i;
75418 + mm_segment_t oldfs;
75419
75420 /*
75421 * This will fail and we want it. Some arch implementations do
75422 @@ -2742,8 +2749,11 @@ static int __init futex_init(void)
75423 * implementation, the non-functional ones will return
75424 * -ENOSYS.
75425 */
75426 + oldfs = get_fs();
75427 + set_fs(USER_DS);
75428 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75429 futex_cmpxchg_enabled = 1;
75430 + set_fs(oldfs);
75431
75432 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75433 plist_head_init(&futex_queues[i].chain);
75434 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75435 index a9642d5..51eb98c 100644
75436 --- a/kernel/futex_compat.c
75437 +++ b/kernel/futex_compat.c
75438 @@ -31,7 +31,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75439 return 0;
75440 }
75441
75442 -static void __user *futex_uaddr(struct robust_list __user *entry,
75443 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75444 compat_long_t futex_offset)
75445 {
75446 compat_uptr_t base = ptr_to_compat(entry);
75447 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75448 index 9b22d03..6295b62 100644
75449 --- a/kernel/gcov/base.c
75450 +++ b/kernel/gcov/base.c
75451 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75452 }
75453
75454 #ifdef CONFIG_MODULES
75455 -static inline int within(void *addr, void *start, unsigned long size)
75456 -{
75457 - return ((addr >= start) && (addr < start + size));
75458 -}
75459 -
75460 /* Update list and generate events when modules are unloaded. */
75461 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75462 void *data)
75463 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75464 prev = NULL;
75465 /* Remove entries located in module from linked list. */
75466 for (info = gcov_info_head; info; info = info->next) {
75467 - if (within(info, mod->module_core, mod->core_size)) {
75468 + if (within_module_core_rw((unsigned long)info, mod)) {
75469 if (prev)
75470 prev->next = info->next;
75471 else
75472 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75473 index cdd5607..c3fc919 100644
75474 --- a/kernel/hrtimer.c
75475 +++ b/kernel/hrtimer.c
75476 @@ -1407,7 +1407,7 @@ void hrtimer_peek_ahead_timers(void)
75477 local_irq_restore(flags);
75478 }
75479
75480 -static void run_hrtimer_softirq(struct softirq_action *h)
75481 +static void run_hrtimer_softirq(void)
75482 {
75483 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75484
75485 @@ -1751,7 +1751,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75486 return NOTIFY_OK;
75487 }
75488
75489 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75490 +static struct notifier_block hrtimers_nb = {
75491 .notifier_call = hrtimer_cpu_notify,
75492 };
75493
75494 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75495 index 60f48fa..7f3a770 100644
75496 --- a/kernel/jump_label.c
75497 +++ b/kernel/jump_label.c
75498 @@ -13,6 +13,7 @@
75499 #include <linux/sort.h>
75500 #include <linux/err.h>
75501 #include <linux/static_key.h>
75502 +#include <linux/mm.h>
75503
75504 #ifdef HAVE_JUMP_LABEL
75505
75506 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75507
75508 size = (((unsigned long)stop - (unsigned long)start)
75509 / sizeof(struct jump_entry));
75510 + pax_open_kernel();
75511 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75512 + pax_close_kernel();
75513 }
75514
75515 static void jump_label_update(struct static_key *key, int enable);
75516 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75517 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75518 struct jump_entry *iter;
75519
75520 + pax_open_kernel();
75521 for (iter = iter_start; iter < iter_stop; iter++) {
75522 if (within_module_init(iter->code, mod))
75523 iter->code = 0;
75524 }
75525 + pax_close_kernel();
75526 }
75527
75528 static int
75529 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75530 index 2169fee..706ccca 100644
75531 --- a/kernel/kallsyms.c
75532 +++ b/kernel/kallsyms.c
75533 @@ -11,6 +11,9 @@
75534 * Changed the compression method from stem compression to "table lookup"
75535 * compression (see scripts/kallsyms.c for a more complete description)
75536 */
75537 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75538 +#define __INCLUDED_BY_HIDESYM 1
75539 +#endif
75540 #include <linux/kallsyms.h>
75541 #include <linux/module.h>
75542 #include <linux/init.h>
75543 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75544
75545 static inline int is_kernel_inittext(unsigned long addr)
75546 {
75547 + if (system_state != SYSTEM_BOOTING)
75548 + return 0;
75549 +
75550 if (addr >= (unsigned long)_sinittext
75551 && addr <= (unsigned long)_einittext)
75552 return 1;
75553 return 0;
75554 }
75555
75556 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75557 +#ifdef CONFIG_MODULES
75558 +static inline int is_module_text(unsigned long addr)
75559 +{
75560 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75561 + return 1;
75562 +
75563 + addr = ktla_ktva(addr);
75564 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75565 +}
75566 +#else
75567 +static inline int is_module_text(unsigned long addr)
75568 +{
75569 + return 0;
75570 +}
75571 +#endif
75572 +#endif
75573 +
75574 static inline int is_kernel_text(unsigned long addr)
75575 {
75576 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75577 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75578
75579 static inline int is_kernel(unsigned long addr)
75580 {
75581 +
75582 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75583 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75584 + return 1;
75585 +
75586 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75587 +#else
75588 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75589 +#endif
75590 +
75591 return 1;
75592 return in_gate_area_no_mm(addr);
75593 }
75594
75595 static int is_ksym_addr(unsigned long addr)
75596 {
75597 +
75598 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75599 + if (is_module_text(addr))
75600 + return 0;
75601 +#endif
75602 +
75603 if (all_var)
75604 return is_kernel(addr);
75605
75606 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75607
75608 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75609 {
75610 - iter->name[0] = '\0';
75611 iter->nameoff = get_symbol_offset(new_pos);
75612 iter->pos = new_pos;
75613 }
75614 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75615 {
75616 struct kallsym_iter *iter = m->private;
75617
75618 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75619 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75620 + return 0;
75621 +#endif
75622 +
75623 /* Some debugging symbols have no name. Ignore them. */
75624 if (!iter->name[0])
75625 return 0;
75626 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75627 */
75628 type = iter->exported ? toupper(iter->type) :
75629 tolower(iter->type);
75630 +
75631 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75632 type, iter->name, iter->module_name);
75633 } else
75634 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75635 struct kallsym_iter *iter;
75636 int ret;
75637
75638 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75639 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75640 if (!iter)
75641 return -ENOMEM;
75642 reset_iter(iter, 0);
75643 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75644 index e30ac0f..3528cac 100644
75645 --- a/kernel/kcmp.c
75646 +++ b/kernel/kcmp.c
75647 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75648 struct task_struct *task1, *task2;
75649 int ret;
75650
75651 +#ifdef CONFIG_GRKERNSEC
75652 + return -ENOSYS;
75653 +#endif
75654 +
75655 rcu_read_lock();
75656
75657 /*
75658 diff --git a/kernel/kexec.c b/kernel/kexec.c
75659 index 5e4bd78..00c5b91 100644
75660 --- a/kernel/kexec.c
75661 +++ b/kernel/kexec.c
75662 @@ -1045,7 +1045,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
75663 unsigned long flags)
75664 {
75665 struct compat_kexec_segment in;
75666 - struct kexec_segment out, __user *ksegments;
75667 + struct kexec_segment out;
75668 + struct kexec_segment __user *ksegments;
75669 unsigned long i, result;
75670
75671 /* Don't allow clients that don't understand the native
75672 diff --git a/kernel/kmod.c b/kernel/kmod.c
75673 index 0023a87..9c0c068 100644
75674 --- a/kernel/kmod.c
75675 +++ b/kernel/kmod.c
75676 @@ -74,7 +74,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
75677 kfree(info->argv);
75678 }
75679
75680 -static int call_modprobe(char *module_name, int wait)
75681 +static int call_modprobe(char *module_name, char *module_param, int wait)
75682 {
75683 static char *envp[] = {
75684 "HOME=/",
75685 @@ -83,7 +83,7 @@ static int call_modprobe(char *module_name, int wait)
75686 NULL
75687 };
75688
75689 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
75690 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
75691 if (!argv)
75692 goto out;
75693
75694 @@ -95,7 +95,8 @@ static int call_modprobe(char *module_name, int wait)
75695 argv[1] = "-q";
75696 argv[2] = "--";
75697 argv[3] = module_name; /* check free_modprobe_argv() */
75698 - argv[4] = NULL;
75699 + argv[4] = module_param;
75700 + argv[5] = NULL;
75701
75702 return call_usermodehelper_fns(modprobe_path, argv, envp,
75703 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
75704 @@ -120,9 +121,8 @@ out:
75705 * If module auto-loading support is disabled then this function
75706 * becomes a no-operation.
75707 */
75708 -int __request_module(bool wait, const char *fmt, ...)
75709 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
75710 {
75711 - va_list args;
75712 char module_name[MODULE_NAME_LEN];
75713 unsigned int max_modprobes;
75714 int ret;
75715 @@ -130,9 +130,7 @@ int __request_module(bool wait, const char *fmt, ...)
75716 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
75717 static int kmod_loop_msg;
75718
75719 - va_start(args, fmt);
75720 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
75721 - va_end(args);
75722 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
75723 if (ret >= MODULE_NAME_LEN)
75724 return -ENAMETOOLONG;
75725
75726 @@ -140,6 +138,20 @@ int __request_module(bool wait, const char *fmt, ...)
75727 if (ret)
75728 return ret;
75729
75730 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75731 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75732 + /* hack to workaround consolekit/udisks stupidity */
75733 + read_lock(&tasklist_lock);
75734 + if (!strcmp(current->comm, "mount") &&
75735 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75736 + read_unlock(&tasklist_lock);
75737 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75738 + return -EPERM;
75739 + }
75740 + read_unlock(&tasklist_lock);
75741 + }
75742 +#endif
75743 +
75744 /* If modprobe needs a service that is in a module, we get a recursive
75745 * loop. Limit the number of running kmod threads to max_threads/2 or
75746 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75747 @@ -168,11 +180,52 @@ int __request_module(bool wait, const char *fmt, ...)
75748
75749 trace_module_request(module_name, wait, _RET_IP_);
75750
75751 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75752 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75753
75754 atomic_dec(&kmod_concurrent);
75755 return ret;
75756 }
75757 +
75758 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75759 +{
75760 + va_list args;
75761 + int ret;
75762 +
75763 + va_start(args, fmt);
75764 + ret = ____request_module(wait, module_param, fmt, args);
75765 + va_end(args);
75766 +
75767 + return ret;
75768 +}
75769 +
75770 +int __request_module(bool wait, const char *fmt, ...)
75771 +{
75772 + va_list args;
75773 + int ret;
75774 +
75775 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75776 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75777 + char module_param[MODULE_NAME_LEN];
75778 +
75779 + memset(module_param, 0, sizeof(module_param));
75780 +
75781 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75782 +
75783 + va_start(args, fmt);
75784 + ret = ____request_module(wait, module_param, fmt, args);
75785 + va_end(args);
75786 +
75787 + return ret;
75788 + }
75789 +#endif
75790 +
75791 + va_start(args, fmt);
75792 + ret = ____request_module(wait, NULL, fmt, args);
75793 + va_end(args);
75794 +
75795 + return ret;
75796 +}
75797 +
75798 EXPORT_SYMBOL(__request_module);
75799 #endif /* CONFIG_MODULES */
75800
75801 @@ -283,7 +336,7 @@ static int wait_for_helper(void *data)
75802 *
75803 * Thus the __user pointer cast is valid here.
75804 */
75805 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
75806 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
75807
75808 /*
75809 * If ret is 0, either ____call_usermodehelper failed and the
75810 @@ -635,7 +688,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
75811 static int proc_cap_handler(struct ctl_table *table, int write,
75812 void __user *buffer, size_t *lenp, loff_t *ppos)
75813 {
75814 - struct ctl_table t;
75815 + ctl_table_no_const t;
75816 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
75817 kernel_cap_t new_cap;
75818 int err, i;
75819 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
75820 index 098f396..fe85ff1 100644
75821 --- a/kernel/kprobes.c
75822 +++ b/kernel/kprobes.c
75823 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
75824 * kernel image and loaded module images reside. This is required
75825 * so x86_64 can correctly handle the %rip-relative fixups.
75826 */
75827 - kip->insns = module_alloc(PAGE_SIZE);
75828 + kip->insns = module_alloc_exec(PAGE_SIZE);
75829 if (!kip->insns) {
75830 kfree(kip);
75831 return NULL;
75832 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
75833 */
75834 if (!list_is_singular(&kip->list)) {
75835 list_del(&kip->list);
75836 - module_free(NULL, kip->insns);
75837 + module_free_exec(NULL, kip->insns);
75838 kfree(kip);
75839 }
75840 return 1;
75841 @@ -2063,7 +2063,7 @@ static int __init init_kprobes(void)
75842 {
75843 int i, err = 0;
75844 unsigned long offset = 0, size = 0;
75845 - char *modname, namebuf[128];
75846 + char *modname, namebuf[KSYM_NAME_LEN];
75847 const char *symbol_name;
75848 void *addr;
75849 struct kprobe_blackpoint *kb;
75850 @@ -2148,11 +2148,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
75851 kprobe_type = "k";
75852
75853 if (sym)
75854 - seq_printf(pi, "%p %s %s+0x%x %s ",
75855 + seq_printf(pi, "%pK %s %s+0x%x %s ",
75856 p->addr, kprobe_type, sym, offset,
75857 (modname ? modname : " "));
75858 else
75859 - seq_printf(pi, "%p %s %p ",
75860 + seq_printf(pi, "%pK %s %pK ",
75861 p->addr, kprobe_type, p->addr);
75862
75863 if (!pp)
75864 @@ -2190,7 +2190,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
75865 const char *sym = NULL;
75866 unsigned int i = *(loff_t *) v;
75867 unsigned long offset = 0;
75868 - char *modname, namebuf[128];
75869 + char *modname, namebuf[KSYM_NAME_LEN];
75870
75871 head = &kprobe_table[i];
75872 preempt_disable();
75873 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
75874 index 6ada93c..dce7d5d 100644
75875 --- a/kernel/ksysfs.c
75876 +++ b/kernel/ksysfs.c
75877 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
75878 {
75879 if (count+1 > UEVENT_HELPER_PATH_LEN)
75880 return -ENOENT;
75881 + if (!capable(CAP_SYS_ADMIN))
75882 + return -EPERM;
75883 memcpy(uevent_helper, buf, count);
75884 uevent_helper[count] = '\0';
75885 if (count && uevent_helper[count-1] == '\n')
75886 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
75887 return count;
75888 }
75889
75890 -static struct bin_attribute notes_attr = {
75891 +static bin_attribute_no_const notes_attr __read_only = {
75892 .attr = {
75893 .name = "notes",
75894 .mode = S_IRUGO,
75895 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
75896 index 7981e5b..7f2105c 100644
75897 --- a/kernel/lockdep.c
75898 +++ b/kernel/lockdep.c
75899 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
75900 end = (unsigned long) &_end,
75901 addr = (unsigned long) obj;
75902
75903 +#ifdef CONFIG_PAX_KERNEXEC
75904 + start = ktla_ktva(start);
75905 +#endif
75906 +
75907 /*
75908 * static variable?
75909 */
75910 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
75911 if (!static_obj(lock->key)) {
75912 debug_locks_off();
75913 printk("INFO: trying to register non-static key.\n");
75914 + printk("lock:%pS key:%pS.\n", lock, lock->key);
75915 printk("the code is fine but needs lockdep annotation.\n");
75916 printk("turning off the locking correctness validator.\n");
75917 dump_stack();
75918 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
75919 if (!class)
75920 return 0;
75921 }
75922 - atomic_inc((atomic_t *)&class->ops);
75923 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
75924 if (very_verbose(class)) {
75925 printk("\nacquire class [%p] %s", class->key, class->name);
75926 if (class->name_version > 1)
75927 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
75928 index b2c71c5..7b88d63 100644
75929 --- a/kernel/lockdep_proc.c
75930 +++ b/kernel/lockdep_proc.c
75931 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
75932 return 0;
75933 }
75934
75935 - seq_printf(m, "%p", class->key);
75936 + seq_printf(m, "%pK", class->key);
75937 #ifdef CONFIG_DEBUG_LOCKDEP
75938 seq_printf(m, " OPS:%8ld", class->ops);
75939 #endif
75940 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
75941
75942 list_for_each_entry(entry, &class->locks_after, entry) {
75943 if (entry->distance == 1) {
75944 - seq_printf(m, " -> [%p] ", entry->class->key);
75945 + seq_printf(m, " -> [%pK] ", entry->class->key);
75946 print_name(m, entry->class);
75947 seq_puts(m, "\n");
75948 }
75949 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
75950 if (!class->key)
75951 continue;
75952
75953 - seq_printf(m, "[%p] ", class->key);
75954 + seq_printf(m, "[%pK] ", class->key);
75955 print_name(m, class);
75956 seq_puts(m, "\n");
75957 }
75958 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75959 if (!i)
75960 seq_line(m, '-', 40-namelen, namelen);
75961
75962 - snprintf(ip, sizeof(ip), "[<%p>]",
75963 + snprintf(ip, sizeof(ip), "[<%pK>]",
75964 (void *)class->contention_point[i]);
75965 seq_printf(m, "%40s %14lu %29s %pS\n",
75966 name, stats->contention_point[i],
75967 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
75968 if (!i)
75969 seq_line(m, '-', 40-namelen, namelen);
75970
75971 - snprintf(ip, sizeof(ip), "[<%p>]",
75972 + snprintf(ip, sizeof(ip), "[<%pK>]",
75973 (void *)class->contending_point[i]);
75974 seq_printf(m, "%40s %14lu %29s %pS\n",
75975 name, stats->contending_point[i],
75976 diff --git a/kernel/module.c b/kernel/module.c
75977 index eab0827..f488603 100644
75978 --- a/kernel/module.c
75979 +++ b/kernel/module.c
75980 @@ -61,6 +61,7 @@
75981 #include <linux/pfn.h>
75982 #include <linux/bsearch.h>
75983 #include <linux/fips.h>
75984 +#include <linux/grsecurity.h>
75985 #include <uapi/linux/module.h>
75986 #include "module-internal.h"
75987
75988 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
75989
75990 /* Bounds of module allocation, for speeding __module_address.
75991 * Protected by module_mutex. */
75992 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
75993 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
75994 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
75995
75996 int register_module_notifier(struct notifier_block * nb)
75997 {
75998 @@ -322,7 +324,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
75999 return true;
76000
76001 list_for_each_entry_rcu(mod, &modules, list) {
76002 - struct symsearch arr[] = {
76003 + struct symsearch modarr[] = {
76004 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76005 NOT_GPL_ONLY, false },
76006 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76007 @@ -347,7 +349,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76008 if (mod->state == MODULE_STATE_UNFORMED)
76009 continue;
76010
76011 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76012 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76013 return true;
76014 }
76015 return false;
76016 @@ -484,7 +486,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76017 static int percpu_modalloc(struct module *mod,
76018 unsigned long size, unsigned long align)
76019 {
76020 - if (align > PAGE_SIZE) {
76021 + if (align-1 >= PAGE_SIZE) {
76022 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76023 mod->name, align, PAGE_SIZE);
76024 align = PAGE_SIZE;
76025 @@ -1088,7 +1090,7 @@ struct module_attribute module_uevent =
76026 static ssize_t show_coresize(struct module_attribute *mattr,
76027 struct module_kobject *mk, char *buffer)
76028 {
76029 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76030 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76031 }
76032
76033 static struct module_attribute modinfo_coresize =
76034 @@ -1097,7 +1099,7 @@ static struct module_attribute modinfo_coresize =
76035 static ssize_t show_initsize(struct module_attribute *mattr,
76036 struct module_kobject *mk, char *buffer)
76037 {
76038 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76039 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76040 }
76041
76042 static struct module_attribute modinfo_initsize =
76043 @@ -1311,7 +1313,7 @@ resolve_symbol_wait(struct module *mod,
76044 */
76045 #ifdef CONFIG_SYSFS
76046
76047 -#ifdef CONFIG_KALLSYMS
76048 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76049 static inline bool sect_empty(const Elf_Shdr *sect)
76050 {
76051 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76052 @@ -1451,7 +1453,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76053 {
76054 unsigned int notes, loaded, i;
76055 struct module_notes_attrs *notes_attrs;
76056 - struct bin_attribute *nattr;
76057 + bin_attribute_no_const *nattr;
76058
76059 /* failed to create section attributes, so can't create notes */
76060 if (!mod->sect_attrs)
76061 @@ -1563,7 +1565,7 @@ static void del_usage_links(struct module *mod)
76062 static int module_add_modinfo_attrs(struct module *mod)
76063 {
76064 struct module_attribute *attr;
76065 - struct module_attribute *temp_attr;
76066 + module_attribute_no_const *temp_attr;
76067 int error = 0;
76068 int i;
76069
76070 @@ -1777,21 +1779,21 @@ static void set_section_ro_nx(void *base,
76071
76072 static void unset_module_core_ro_nx(struct module *mod)
76073 {
76074 - set_page_attributes(mod->module_core + mod->core_text_size,
76075 - mod->module_core + mod->core_size,
76076 + set_page_attributes(mod->module_core_rw,
76077 + mod->module_core_rw + mod->core_size_rw,
76078 set_memory_x);
76079 - set_page_attributes(mod->module_core,
76080 - mod->module_core + mod->core_ro_size,
76081 + set_page_attributes(mod->module_core_rx,
76082 + mod->module_core_rx + mod->core_size_rx,
76083 set_memory_rw);
76084 }
76085
76086 static void unset_module_init_ro_nx(struct module *mod)
76087 {
76088 - set_page_attributes(mod->module_init + mod->init_text_size,
76089 - mod->module_init + mod->init_size,
76090 + set_page_attributes(mod->module_init_rw,
76091 + mod->module_init_rw + mod->init_size_rw,
76092 set_memory_x);
76093 - set_page_attributes(mod->module_init,
76094 - mod->module_init + mod->init_ro_size,
76095 + set_page_attributes(mod->module_init_rx,
76096 + mod->module_init_rx + mod->init_size_rx,
76097 set_memory_rw);
76098 }
76099
76100 @@ -1804,14 +1806,14 @@ void set_all_modules_text_rw(void)
76101 list_for_each_entry_rcu(mod, &modules, list) {
76102 if (mod->state == MODULE_STATE_UNFORMED)
76103 continue;
76104 - if ((mod->module_core) && (mod->core_text_size)) {
76105 - set_page_attributes(mod->module_core,
76106 - mod->module_core + mod->core_text_size,
76107 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76108 + set_page_attributes(mod->module_core_rx,
76109 + mod->module_core_rx + mod->core_size_rx,
76110 set_memory_rw);
76111 }
76112 - if ((mod->module_init) && (mod->init_text_size)) {
76113 - set_page_attributes(mod->module_init,
76114 - mod->module_init + mod->init_text_size,
76115 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76116 + set_page_attributes(mod->module_init_rx,
76117 + mod->module_init_rx + mod->init_size_rx,
76118 set_memory_rw);
76119 }
76120 }
76121 @@ -1827,14 +1829,14 @@ void set_all_modules_text_ro(void)
76122 list_for_each_entry_rcu(mod, &modules, list) {
76123 if (mod->state == MODULE_STATE_UNFORMED)
76124 continue;
76125 - if ((mod->module_core) && (mod->core_text_size)) {
76126 - set_page_attributes(mod->module_core,
76127 - mod->module_core + mod->core_text_size,
76128 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76129 + set_page_attributes(mod->module_core_rx,
76130 + mod->module_core_rx + mod->core_size_rx,
76131 set_memory_ro);
76132 }
76133 - if ((mod->module_init) && (mod->init_text_size)) {
76134 - set_page_attributes(mod->module_init,
76135 - mod->module_init + mod->init_text_size,
76136 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76137 + set_page_attributes(mod->module_init_rx,
76138 + mod->module_init_rx + mod->init_size_rx,
76139 set_memory_ro);
76140 }
76141 }
76142 @@ -1880,16 +1882,19 @@ static void free_module(struct module *mod)
76143
76144 /* This may be NULL, but that's OK */
76145 unset_module_init_ro_nx(mod);
76146 - module_free(mod, mod->module_init);
76147 + module_free(mod, mod->module_init_rw);
76148 + module_free_exec(mod, mod->module_init_rx);
76149 kfree(mod->args);
76150 percpu_modfree(mod);
76151
76152 /* Free lock-classes: */
76153 - lockdep_free_key_range(mod->module_core, mod->core_size);
76154 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76155 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76156
76157 /* Finally, free the core (containing the module structure) */
76158 unset_module_core_ro_nx(mod);
76159 - module_free(mod, mod->module_core);
76160 + module_free_exec(mod, mod->module_core_rx);
76161 + module_free(mod, mod->module_core_rw);
76162
76163 #ifdef CONFIG_MPU
76164 update_protections(current->mm);
76165 @@ -1959,9 +1964,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76166 int ret = 0;
76167 const struct kernel_symbol *ksym;
76168
76169 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76170 + int is_fs_load = 0;
76171 + int register_filesystem_found = 0;
76172 + char *p;
76173 +
76174 + p = strstr(mod->args, "grsec_modharden_fs");
76175 + if (p) {
76176 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76177 + /* copy \0 as well */
76178 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76179 + is_fs_load = 1;
76180 + }
76181 +#endif
76182 +
76183 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76184 const char *name = info->strtab + sym[i].st_name;
76185
76186 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76187 + /* it's a real shame this will never get ripped and copied
76188 + upstream! ;(
76189 + */
76190 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76191 + register_filesystem_found = 1;
76192 +#endif
76193 +
76194 switch (sym[i].st_shndx) {
76195 case SHN_COMMON:
76196 /* We compiled with -fno-common. These are not
76197 @@ -1982,7 +2009,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76198 ksym = resolve_symbol_wait(mod, info, name);
76199 /* Ok if resolved. */
76200 if (ksym && !IS_ERR(ksym)) {
76201 + pax_open_kernel();
76202 sym[i].st_value = ksym->value;
76203 + pax_close_kernel();
76204 break;
76205 }
76206
76207 @@ -2001,11 +2030,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76208 secbase = (unsigned long)mod_percpu(mod);
76209 else
76210 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76211 + pax_open_kernel();
76212 sym[i].st_value += secbase;
76213 + pax_close_kernel();
76214 break;
76215 }
76216 }
76217
76218 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76219 + if (is_fs_load && !register_filesystem_found) {
76220 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76221 + ret = -EPERM;
76222 + }
76223 +#endif
76224 +
76225 return ret;
76226 }
76227
76228 @@ -2089,22 +2127,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76229 || s->sh_entsize != ~0UL
76230 || strstarts(sname, ".init"))
76231 continue;
76232 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76233 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76234 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76235 + else
76236 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76237 pr_debug("\t%s\n", sname);
76238 }
76239 - switch (m) {
76240 - case 0: /* executable */
76241 - mod->core_size = debug_align(mod->core_size);
76242 - mod->core_text_size = mod->core_size;
76243 - break;
76244 - case 1: /* RO: text and ro-data */
76245 - mod->core_size = debug_align(mod->core_size);
76246 - mod->core_ro_size = mod->core_size;
76247 - break;
76248 - case 3: /* whole core */
76249 - mod->core_size = debug_align(mod->core_size);
76250 - break;
76251 - }
76252 }
76253
76254 pr_debug("Init section allocation order:\n");
76255 @@ -2118,23 +2146,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76256 || s->sh_entsize != ~0UL
76257 || !strstarts(sname, ".init"))
76258 continue;
76259 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76260 - | INIT_OFFSET_MASK);
76261 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76262 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76263 + else
76264 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76265 + s->sh_entsize |= INIT_OFFSET_MASK;
76266 pr_debug("\t%s\n", sname);
76267 }
76268 - switch (m) {
76269 - case 0: /* executable */
76270 - mod->init_size = debug_align(mod->init_size);
76271 - mod->init_text_size = mod->init_size;
76272 - break;
76273 - case 1: /* RO: text and ro-data */
76274 - mod->init_size = debug_align(mod->init_size);
76275 - mod->init_ro_size = mod->init_size;
76276 - break;
76277 - case 3: /* whole init */
76278 - mod->init_size = debug_align(mod->init_size);
76279 - break;
76280 - }
76281 }
76282 }
76283
76284 @@ -2306,7 +2324,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76285
76286 /* Put symbol section at end of init part of module. */
76287 symsect->sh_flags |= SHF_ALLOC;
76288 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76289 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76290 info->index.sym) | INIT_OFFSET_MASK;
76291 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76292
76293 @@ -2323,13 +2341,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76294 }
76295
76296 /* Append room for core symbols at end of core part. */
76297 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76298 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76299 - mod->core_size += strtab_size;
76300 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76301 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76302 + mod->core_size_rx += strtab_size;
76303
76304 /* Put string table section at end of init part of module. */
76305 strsect->sh_flags |= SHF_ALLOC;
76306 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76307 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76308 info->index.str) | INIT_OFFSET_MASK;
76309 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76310 }
76311 @@ -2347,12 +2365,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76312 /* Make sure we get permanent strtab: don't use info->strtab. */
76313 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76314
76315 + pax_open_kernel();
76316 +
76317 /* Set types up while we still have access to sections. */
76318 for (i = 0; i < mod->num_symtab; i++)
76319 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76320
76321 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76322 - mod->core_strtab = s = mod->module_core + info->stroffs;
76323 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76324 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76325 src = mod->symtab;
76326 for (ndst = i = 0; i < mod->num_symtab; i++) {
76327 if (i == 0 ||
76328 @@ -2364,6 +2384,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76329 }
76330 }
76331 mod->core_num_syms = ndst;
76332 +
76333 + pax_close_kernel();
76334 }
76335 #else
76336 static inline void layout_symtab(struct module *mod, struct load_info *info)
76337 @@ -2397,17 +2419,33 @@ void * __weak module_alloc(unsigned long size)
76338 return vmalloc_exec(size);
76339 }
76340
76341 -static void *module_alloc_update_bounds(unsigned long size)
76342 +static void *module_alloc_update_bounds_rw(unsigned long size)
76343 {
76344 void *ret = module_alloc(size);
76345
76346 if (ret) {
76347 mutex_lock(&module_mutex);
76348 /* Update module bounds. */
76349 - if ((unsigned long)ret < module_addr_min)
76350 - module_addr_min = (unsigned long)ret;
76351 - if ((unsigned long)ret + size > module_addr_max)
76352 - module_addr_max = (unsigned long)ret + size;
76353 + if ((unsigned long)ret < module_addr_min_rw)
76354 + module_addr_min_rw = (unsigned long)ret;
76355 + if ((unsigned long)ret + size > module_addr_max_rw)
76356 + module_addr_max_rw = (unsigned long)ret + size;
76357 + mutex_unlock(&module_mutex);
76358 + }
76359 + return ret;
76360 +}
76361 +
76362 +static void *module_alloc_update_bounds_rx(unsigned long size)
76363 +{
76364 + void *ret = module_alloc_exec(size);
76365 +
76366 + if (ret) {
76367 + mutex_lock(&module_mutex);
76368 + /* Update module bounds. */
76369 + if ((unsigned long)ret < module_addr_min_rx)
76370 + module_addr_min_rx = (unsigned long)ret;
76371 + if ((unsigned long)ret + size > module_addr_max_rx)
76372 + module_addr_max_rx = (unsigned long)ret + size;
76373 mutex_unlock(&module_mutex);
76374 }
76375 return ret;
76376 @@ -2683,8 +2721,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76377 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76378 {
76379 const char *modmagic = get_modinfo(info, "vermagic");
76380 + const char *license = get_modinfo(info, "license");
76381 int err;
76382
76383 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76384 + if (!license || !license_is_gpl_compatible(license))
76385 + return -ENOEXEC;
76386 +#endif
76387 +
76388 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76389 modmagic = NULL;
76390
76391 @@ -2710,7 +2754,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76392 }
76393
76394 /* Set up license info based on the info section */
76395 - set_license(mod, get_modinfo(info, "license"));
76396 + set_license(mod, license);
76397
76398 return 0;
76399 }
76400 @@ -2804,7 +2848,7 @@ static int move_module(struct module *mod, struct load_info *info)
76401 void *ptr;
76402
76403 /* Do the allocs. */
76404 - ptr = module_alloc_update_bounds(mod->core_size);
76405 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76406 /*
76407 * The pointer to this block is stored in the module structure
76408 * which is inside the block. Just mark it as not being a
76409 @@ -2814,11 +2858,11 @@ static int move_module(struct module *mod, struct load_info *info)
76410 if (!ptr)
76411 return -ENOMEM;
76412
76413 - memset(ptr, 0, mod->core_size);
76414 - mod->module_core = ptr;
76415 + memset(ptr, 0, mod->core_size_rw);
76416 + mod->module_core_rw = ptr;
76417
76418 - if (mod->init_size) {
76419 - ptr = module_alloc_update_bounds(mod->init_size);
76420 + if (mod->init_size_rw) {
76421 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76422 /*
76423 * The pointer to this block is stored in the module structure
76424 * which is inside the block. This block doesn't need to be
76425 @@ -2827,13 +2871,45 @@ static int move_module(struct module *mod, struct load_info *info)
76426 */
76427 kmemleak_ignore(ptr);
76428 if (!ptr) {
76429 - module_free(mod, mod->module_core);
76430 + module_free(mod, mod->module_core_rw);
76431 return -ENOMEM;
76432 }
76433 - memset(ptr, 0, mod->init_size);
76434 - mod->module_init = ptr;
76435 + memset(ptr, 0, mod->init_size_rw);
76436 + mod->module_init_rw = ptr;
76437 } else
76438 - mod->module_init = NULL;
76439 + mod->module_init_rw = NULL;
76440 +
76441 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76442 + kmemleak_not_leak(ptr);
76443 + if (!ptr) {
76444 + if (mod->module_init_rw)
76445 + module_free(mod, mod->module_init_rw);
76446 + module_free(mod, mod->module_core_rw);
76447 + return -ENOMEM;
76448 + }
76449 +
76450 + pax_open_kernel();
76451 + memset(ptr, 0, mod->core_size_rx);
76452 + pax_close_kernel();
76453 + mod->module_core_rx = ptr;
76454 +
76455 + if (mod->init_size_rx) {
76456 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76457 + kmemleak_ignore(ptr);
76458 + if (!ptr && mod->init_size_rx) {
76459 + module_free_exec(mod, mod->module_core_rx);
76460 + if (mod->module_init_rw)
76461 + module_free(mod, mod->module_init_rw);
76462 + module_free(mod, mod->module_core_rw);
76463 + return -ENOMEM;
76464 + }
76465 +
76466 + pax_open_kernel();
76467 + memset(ptr, 0, mod->init_size_rx);
76468 + pax_close_kernel();
76469 + mod->module_init_rx = ptr;
76470 + } else
76471 + mod->module_init_rx = NULL;
76472
76473 /* Transfer each section which specifies SHF_ALLOC */
76474 pr_debug("final section addresses:\n");
76475 @@ -2844,16 +2920,45 @@ static int move_module(struct module *mod, struct load_info *info)
76476 if (!(shdr->sh_flags & SHF_ALLOC))
76477 continue;
76478
76479 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76480 - dest = mod->module_init
76481 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76482 - else
76483 - dest = mod->module_core + shdr->sh_entsize;
76484 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76485 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76486 + dest = mod->module_init_rw
76487 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76488 + else
76489 + dest = mod->module_init_rx
76490 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76491 + } else {
76492 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76493 + dest = mod->module_core_rw + shdr->sh_entsize;
76494 + else
76495 + dest = mod->module_core_rx + shdr->sh_entsize;
76496 + }
76497 +
76498 + if (shdr->sh_type != SHT_NOBITS) {
76499 +
76500 +#ifdef CONFIG_PAX_KERNEXEC
76501 +#ifdef CONFIG_X86_64
76502 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76503 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76504 +#endif
76505 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76506 + pax_open_kernel();
76507 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76508 + pax_close_kernel();
76509 + } else
76510 +#endif
76511
76512 - if (shdr->sh_type != SHT_NOBITS)
76513 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76514 + }
76515 /* Update sh_addr to point to copy in image. */
76516 - shdr->sh_addr = (unsigned long)dest;
76517 +
76518 +#ifdef CONFIG_PAX_KERNEXEC
76519 + if (shdr->sh_flags & SHF_EXECINSTR)
76520 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76521 + else
76522 +#endif
76523 +
76524 + shdr->sh_addr = (unsigned long)dest;
76525 pr_debug("\t0x%lx %s\n",
76526 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76527 }
76528 @@ -2908,12 +3013,12 @@ static void flush_module_icache(const struct module *mod)
76529 * Do it before processing of module parameters, so the module
76530 * can provide parameter accessor functions of its own.
76531 */
76532 - if (mod->module_init)
76533 - flush_icache_range((unsigned long)mod->module_init,
76534 - (unsigned long)mod->module_init
76535 - + mod->init_size);
76536 - flush_icache_range((unsigned long)mod->module_core,
76537 - (unsigned long)mod->module_core + mod->core_size);
76538 + if (mod->module_init_rx)
76539 + flush_icache_range((unsigned long)mod->module_init_rx,
76540 + (unsigned long)mod->module_init_rx
76541 + + mod->init_size_rx);
76542 + flush_icache_range((unsigned long)mod->module_core_rx,
76543 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76544
76545 set_fs(old_fs);
76546 }
76547 @@ -2983,8 +3088,10 @@ out:
76548 static void module_deallocate(struct module *mod, struct load_info *info)
76549 {
76550 percpu_modfree(mod);
76551 - module_free(mod, mod->module_init);
76552 - module_free(mod, mod->module_core);
76553 + module_free_exec(mod, mod->module_init_rx);
76554 + module_free_exec(mod, mod->module_core_rx);
76555 + module_free(mod, mod->module_init_rw);
76556 + module_free(mod, mod->module_core_rw);
76557 }
76558
76559 int __weak module_finalize(const Elf_Ehdr *hdr,
76560 @@ -2997,7 +3104,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76561 static int post_relocation(struct module *mod, const struct load_info *info)
76562 {
76563 /* Sort exception table now relocations are done. */
76564 + pax_open_kernel();
76565 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76566 + pax_close_kernel();
76567
76568 /* Copy relocated percpu area over. */
76569 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76570 @@ -3051,16 +3160,16 @@ static int do_init_module(struct module *mod)
76571 MODULE_STATE_COMING, mod);
76572
76573 /* Set RO and NX regions for core */
76574 - set_section_ro_nx(mod->module_core,
76575 - mod->core_text_size,
76576 - mod->core_ro_size,
76577 - mod->core_size);
76578 + set_section_ro_nx(mod->module_core_rx,
76579 + mod->core_size_rx,
76580 + mod->core_size_rx,
76581 + mod->core_size_rx);
76582
76583 /* Set RO and NX regions for init */
76584 - set_section_ro_nx(mod->module_init,
76585 - mod->init_text_size,
76586 - mod->init_ro_size,
76587 - mod->init_size);
76588 + set_section_ro_nx(mod->module_init_rx,
76589 + mod->init_size_rx,
76590 + mod->init_size_rx,
76591 + mod->init_size_rx);
76592
76593 do_mod_ctors(mod);
76594 /* Start the module */
76595 @@ -3122,11 +3231,12 @@ static int do_init_module(struct module *mod)
76596 mod->strtab = mod->core_strtab;
76597 #endif
76598 unset_module_init_ro_nx(mod);
76599 - module_free(mod, mod->module_init);
76600 - mod->module_init = NULL;
76601 - mod->init_size = 0;
76602 - mod->init_ro_size = 0;
76603 - mod->init_text_size = 0;
76604 + module_free(mod, mod->module_init_rw);
76605 + module_free_exec(mod, mod->module_init_rx);
76606 + mod->module_init_rw = NULL;
76607 + mod->module_init_rx = NULL;
76608 + mod->init_size_rw = 0;
76609 + mod->init_size_rx = 0;
76610 mutex_unlock(&module_mutex);
76611 wake_up_all(&module_wq);
76612
76613 @@ -3209,9 +3319,38 @@ again:
76614 if (err)
76615 goto free_unload;
76616
76617 + /* Now copy in args */
76618 + mod->args = strndup_user(uargs, ~0UL >> 1);
76619 + if (IS_ERR(mod->args)) {
76620 + err = PTR_ERR(mod->args);
76621 + goto free_unload;
76622 + }
76623 +
76624 /* Set up MODINFO_ATTR fields */
76625 setup_modinfo(mod, info);
76626
76627 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76628 + {
76629 + char *p, *p2;
76630 +
76631 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76632 + 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);
76633 + err = -EPERM;
76634 + goto free_modinfo;
76635 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76636 + p += sizeof("grsec_modharden_normal") - 1;
76637 + p2 = strstr(p, "_");
76638 + if (p2) {
76639 + *p2 = '\0';
76640 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76641 + *p2 = '_';
76642 + }
76643 + err = -EPERM;
76644 + goto free_modinfo;
76645 + }
76646 + }
76647 +#endif
76648 +
76649 /* Fix up syms, so that st_value is a pointer to location. */
76650 err = simplify_symbols(mod, info);
76651 if (err < 0)
76652 @@ -3227,13 +3366,6 @@ again:
76653
76654 flush_module_icache(mod);
76655
76656 - /* Now copy in args */
76657 - mod->args = strndup_user(uargs, ~0UL >> 1);
76658 - if (IS_ERR(mod->args)) {
76659 - err = PTR_ERR(mod->args);
76660 - goto free_arch_cleanup;
76661 - }
76662 -
76663 dynamic_debug_setup(info->debug, info->num_debug);
76664
76665 mutex_lock(&module_mutex);
76666 @@ -3278,11 +3410,10 @@ again:
76667 mutex_unlock(&module_mutex);
76668 dynamic_debug_remove(info->debug);
76669 synchronize_sched();
76670 - kfree(mod->args);
76671 - free_arch_cleanup:
76672 module_arch_cleanup(mod);
76673 free_modinfo:
76674 free_modinfo(mod);
76675 + kfree(mod->args);
76676 free_unload:
76677 module_unload_free(mod);
76678 unlink_mod:
76679 @@ -3365,10 +3496,16 @@ static const char *get_ksymbol(struct module *mod,
76680 unsigned long nextval;
76681
76682 /* At worse, next value is at end of module */
76683 - if (within_module_init(addr, mod))
76684 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
76685 + if (within_module_init_rx(addr, mod))
76686 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
76687 + else if (within_module_init_rw(addr, mod))
76688 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
76689 + else if (within_module_core_rx(addr, mod))
76690 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
76691 + else if (within_module_core_rw(addr, mod))
76692 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
76693 else
76694 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
76695 + return NULL;
76696
76697 /* Scan for closest preceding symbol, and next symbol. (ELF
76698 starts real symbols at 1). */
76699 @@ -3621,7 +3758,7 @@ static int m_show(struct seq_file *m, void *p)
76700 return 0;
76701
76702 seq_printf(m, "%s %u",
76703 - mod->name, mod->init_size + mod->core_size);
76704 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
76705 print_unload_info(m, mod);
76706
76707 /* Informative for users. */
76708 @@ -3630,7 +3767,7 @@ static int m_show(struct seq_file *m, void *p)
76709 mod->state == MODULE_STATE_COMING ? "Loading":
76710 "Live");
76711 /* Used by oprofile and other similar tools. */
76712 - seq_printf(m, " 0x%pK", mod->module_core);
76713 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
76714
76715 /* Taints info */
76716 if (mod->taints)
76717 @@ -3666,7 +3803,17 @@ static const struct file_operations proc_modules_operations = {
76718
76719 static int __init proc_modules_init(void)
76720 {
76721 +#ifndef CONFIG_GRKERNSEC_HIDESYM
76722 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76723 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76724 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76725 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
76726 +#else
76727 proc_create("modules", 0, NULL, &proc_modules_operations);
76728 +#endif
76729 +#else
76730 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76731 +#endif
76732 return 0;
76733 }
76734 module_init(proc_modules_init);
76735 @@ -3727,14 +3874,14 @@ struct module *__module_address(unsigned long addr)
76736 {
76737 struct module *mod;
76738
76739 - if (addr < module_addr_min || addr > module_addr_max)
76740 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76741 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76742 return NULL;
76743
76744 list_for_each_entry_rcu(mod, &modules, list) {
76745 if (mod->state == MODULE_STATE_UNFORMED)
76746 continue;
76747 - if (within_module_core(addr, mod)
76748 - || within_module_init(addr, mod))
76749 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76750 return mod;
76751 }
76752 return NULL;
76753 @@ -3769,11 +3916,20 @@ bool is_module_text_address(unsigned long addr)
76754 */
76755 struct module *__module_text_address(unsigned long addr)
76756 {
76757 - struct module *mod = __module_address(addr);
76758 + struct module *mod;
76759 +
76760 +#ifdef CONFIG_X86_32
76761 + addr = ktla_ktva(addr);
76762 +#endif
76763 +
76764 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76765 + return NULL;
76766 +
76767 + mod = __module_address(addr);
76768 +
76769 if (mod) {
76770 /* Make sure it's within the text section. */
76771 - if (!within(addr, mod->module_init, mod->init_text_size)
76772 - && !within(addr, mod->module_core, mod->core_text_size))
76773 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76774 mod = NULL;
76775 }
76776 return mod;
76777 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76778 index 7e3443f..b2a1e6b 100644
76779 --- a/kernel/mutex-debug.c
76780 +++ b/kernel/mutex-debug.c
76781 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76782 }
76783
76784 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76785 - struct thread_info *ti)
76786 + struct task_struct *task)
76787 {
76788 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76789
76790 /* Mark the current thread as blocked on the lock: */
76791 - ti->task->blocked_on = waiter;
76792 + task->blocked_on = waiter;
76793 }
76794
76795 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76796 - struct thread_info *ti)
76797 + struct task_struct *task)
76798 {
76799 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
76800 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
76801 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
76802 - ti->task->blocked_on = NULL;
76803 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
76804 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
76805 + task->blocked_on = NULL;
76806
76807 list_del_init(&waiter->list);
76808 waiter->task = NULL;
76809 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
76810 index 0799fd3..d06ae3b 100644
76811 --- a/kernel/mutex-debug.h
76812 +++ b/kernel/mutex-debug.h
76813 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
76814 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
76815 extern void debug_mutex_add_waiter(struct mutex *lock,
76816 struct mutex_waiter *waiter,
76817 - struct thread_info *ti);
76818 + struct task_struct *task);
76819 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76820 - struct thread_info *ti);
76821 + struct task_struct *task);
76822 extern void debug_mutex_unlock(struct mutex *lock);
76823 extern void debug_mutex_init(struct mutex *lock, const char *name,
76824 struct lock_class_key *key);
76825 diff --git a/kernel/mutex.c b/kernel/mutex.c
76826 index a307cc9..27fd2e9 100644
76827 --- a/kernel/mutex.c
76828 +++ b/kernel/mutex.c
76829 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76830 spin_lock_mutex(&lock->wait_lock, flags);
76831
76832 debug_mutex_lock_common(lock, &waiter);
76833 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
76834 + debug_mutex_add_waiter(lock, &waiter, task);
76835
76836 /* add waiting tasks to the end of the waitqueue (FIFO): */
76837 list_add_tail(&waiter.list, &lock->wait_list);
76838 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76839 * TASK_UNINTERRUPTIBLE case.)
76840 */
76841 if (unlikely(signal_pending_state(state, task))) {
76842 - mutex_remove_waiter(lock, &waiter,
76843 - task_thread_info(task));
76844 + mutex_remove_waiter(lock, &waiter, task);
76845 mutex_release(&lock->dep_map, 1, ip);
76846 spin_unlock_mutex(&lock->wait_lock, flags);
76847
76848 @@ -247,7 +246,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76849 done:
76850 lock_acquired(&lock->dep_map, ip);
76851 /* got the lock - rejoice! */
76852 - mutex_remove_waiter(lock, &waiter, current_thread_info());
76853 + mutex_remove_waiter(lock, &waiter, task);
76854 mutex_set_owner(lock);
76855
76856 /* set it to 0 if there are no waiters left: */
76857 diff --git a/kernel/notifier.c b/kernel/notifier.c
76858 index 2d5cc4c..d9ea600 100644
76859 --- a/kernel/notifier.c
76860 +++ b/kernel/notifier.c
76861 @@ -5,6 +5,7 @@
76862 #include <linux/rcupdate.h>
76863 #include <linux/vmalloc.h>
76864 #include <linux/reboot.h>
76865 +#include <linux/mm.h>
76866
76867 /*
76868 * Notifier list for kernel code which wants to be called
76869 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
76870 while ((*nl) != NULL) {
76871 if (n->priority > (*nl)->priority)
76872 break;
76873 - nl = &((*nl)->next);
76874 + nl = (struct notifier_block **)&((*nl)->next);
76875 }
76876 - n->next = *nl;
76877 + pax_open_kernel();
76878 + *(const void **)&n->next = *nl;
76879 rcu_assign_pointer(*nl, n);
76880 + pax_close_kernel();
76881 return 0;
76882 }
76883
76884 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
76885 return 0;
76886 if (n->priority > (*nl)->priority)
76887 break;
76888 - nl = &((*nl)->next);
76889 + nl = (struct notifier_block **)&((*nl)->next);
76890 }
76891 - n->next = *nl;
76892 + pax_open_kernel();
76893 + *(const void **)&n->next = *nl;
76894 rcu_assign_pointer(*nl, n);
76895 + pax_close_kernel();
76896 return 0;
76897 }
76898
76899 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
76900 {
76901 while ((*nl) != NULL) {
76902 if ((*nl) == n) {
76903 + pax_open_kernel();
76904 rcu_assign_pointer(*nl, n->next);
76905 + pax_close_kernel();
76906 return 0;
76907 }
76908 - nl = &((*nl)->next);
76909 + nl = (struct notifier_block **)&((*nl)->next);
76910 }
76911 return -ENOENT;
76912 }
76913 diff --git a/kernel/panic.c b/kernel/panic.c
76914 index e1b2822..5edc1d9 100644
76915 --- a/kernel/panic.c
76916 +++ b/kernel/panic.c
76917 @@ -410,7 +410,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
76918 const char *board;
76919
76920 printk(KERN_WARNING "------------[ cut here ]------------\n");
76921 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
76922 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
76923 board = dmi_get_system_info(DMI_PRODUCT_NAME);
76924 if (board)
76925 printk(KERN_WARNING "Hardware name: %s\n", board);
76926 @@ -465,7 +465,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
76927 */
76928 void __stack_chk_fail(void)
76929 {
76930 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
76931 + dump_stack();
76932 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
76933 __builtin_return_address(0));
76934 }
76935 EXPORT_SYMBOL(__stack_chk_fail);
76936 diff --git a/kernel/pid.c b/kernel/pid.c
76937 index f2c6a68..4922d97 100644
76938 --- a/kernel/pid.c
76939 +++ b/kernel/pid.c
76940 @@ -33,6 +33,7 @@
76941 #include <linux/rculist.h>
76942 #include <linux/bootmem.h>
76943 #include <linux/hash.h>
76944 +#include <linux/security.h>
76945 #include <linux/pid_namespace.h>
76946 #include <linux/init_task.h>
76947 #include <linux/syscalls.h>
76948 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
76949
76950 int pid_max = PID_MAX_DEFAULT;
76951
76952 -#define RESERVED_PIDS 300
76953 +#define RESERVED_PIDS 500
76954
76955 int pid_max_min = RESERVED_PIDS + 1;
76956 int pid_max_max = PID_MAX_LIMIT;
76957 @@ -441,10 +442,18 @@ EXPORT_SYMBOL(pid_task);
76958 */
76959 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
76960 {
76961 + struct task_struct *task;
76962 +
76963 rcu_lockdep_assert(rcu_read_lock_held(),
76964 "find_task_by_pid_ns() needs rcu_read_lock()"
76965 " protection");
76966 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76967 +
76968 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
76969 +
76970 + if (gr_pid_is_chrooted(task))
76971 + return NULL;
76972 +
76973 + return task;
76974 }
76975
76976 struct task_struct *find_task_by_vpid(pid_t vnr)
76977 @@ -452,6 +461,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
76978 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
76979 }
76980
76981 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
76982 +{
76983 + rcu_lockdep_assert(rcu_read_lock_held(),
76984 + "find_task_by_pid_ns() needs rcu_read_lock()"
76985 + " protection");
76986 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
76987 +}
76988 +
76989 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
76990 {
76991 struct pid *pid;
76992 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
76993 index bea15bd..789f3d0 100644
76994 --- a/kernel/pid_namespace.c
76995 +++ b/kernel/pid_namespace.c
76996 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
76997 void __user *buffer, size_t *lenp, loff_t *ppos)
76998 {
76999 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77000 - struct ctl_table tmp = *table;
77001 + ctl_table_no_const tmp = *table;
77002
77003 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77004 return -EPERM;
77005 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77006 index 942ca27..111e609 100644
77007 --- a/kernel/posix-cpu-timers.c
77008 +++ b/kernel/posix-cpu-timers.c
77009 @@ -1576,14 +1576,14 @@ struct k_clock clock_posix_cpu = {
77010
77011 static __init int init_posix_cpu_timers(void)
77012 {
77013 - struct k_clock process = {
77014 + static struct k_clock process = {
77015 .clock_getres = process_cpu_clock_getres,
77016 .clock_get = process_cpu_clock_get,
77017 .timer_create = process_cpu_timer_create,
77018 .nsleep = process_cpu_nsleep,
77019 .nsleep_restart = process_cpu_nsleep_restart,
77020 };
77021 - struct k_clock thread = {
77022 + static struct k_clock thread = {
77023 .clock_getres = thread_cpu_clock_getres,
77024 .clock_get = thread_cpu_clock_get,
77025 .timer_create = thread_cpu_timer_create,
77026 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77027 index e885be1..380fe76 100644
77028 --- a/kernel/posix-timers.c
77029 +++ b/kernel/posix-timers.c
77030 @@ -43,6 +43,7 @@
77031 #include <linux/idr.h>
77032 #include <linux/posix-clock.h>
77033 #include <linux/posix-timers.h>
77034 +#include <linux/grsecurity.h>
77035 #include <linux/syscalls.h>
77036 #include <linux/wait.h>
77037 #include <linux/workqueue.h>
77038 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
77039 * which we beg off on and pass to do_sys_settimeofday().
77040 */
77041
77042 -static struct k_clock posix_clocks[MAX_CLOCKS];
77043 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77044
77045 /*
77046 * These ones are defined below.
77047 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
77048 */
77049 static __init int init_posix_timers(void)
77050 {
77051 - struct k_clock clock_realtime = {
77052 + static struct k_clock clock_realtime = {
77053 .clock_getres = hrtimer_get_res,
77054 .clock_get = posix_clock_realtime_get,
77055 .clock_set = posix_clock_realtime_set,
77056 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
77057 .timer_get = common_timer_get,
77058 .timer_del = common_timer_del,
77059 };
77060 - struct k_clock clock_monotonic = {
77061 + static struct k_clock clock_monotonic = {
77062 .clock_getres = hrtimer_get_res,
77063 .clock_get = posix_ktime_get_ts,
77064 .nsleep = common_nsleep,
77065 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
77066 .timer_get = common_timer_get,
77067 .timer_del = common_timer_del,
77068 };
77069 - struct k_clock clock_monotonic_raw = {
77070 + static struct k_clock clock_monotonic_raw = {
77071 .clock_getres = hrtimer_get_res,
77072 .clock_get = posix_get_monotonic_raw,
77073 };
77074 - struct k_clock clock_realtime_coarse = {
77075 + static struct k_clock clock_realtime_coarse = {
77076 .clock_getres = posix_get_coarse_res,
77077 .clock_get = posix_get_realtime_coarse,
77078 };
77079 - struct k_clock clock_monotonic_coarse = {
77080 + static struct k_clock clock_monotonic_coarse = {
77081 .clock_getres = posix_get_coarse_res,
77082 .clock_get = posix_get_monotonic_coarse,
77083 };
77084 - struct k_clock clock_boottime = {
77085 + static struct k_clock clock_boottime = {
77086 .clock_getres = hrtimer_get_res,
77087 .clock_get = posix_get_boottime,
77088 .nsleep = common_nsleep,
77089 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77090 return;
77091 }
77092
77093 - posix_clocks[clock_id] = *new_clock;
77094 + posix_clocks[clock_id] = new_clock;
77095 }
77096 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77097
77098 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77099 return (id & CLOCKFD_MASK) == CLOCKFD ?
77100 &clock_posix_dynamic : &clock_posix_cpu;
77101
77102 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77103 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77104 return NULL;
77105 - return &posix_clocks[id];
77106 + return posix_clocks[id];
77107 }
77108
77109 static int common_timer_create(struct k_itimer *new_timer)
77110 @@ -966,6 +967,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77111 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77112 return -EFAULT;
77113
77114 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77115 + have their clock_set fptr set to a nosettime dummy function
77116 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77117 + call common_clock_set, which calls do_sys_settimeofday, which
77118 + we hook
77119 + */
77120 +
77121 return kc->clock_set(which_clock, &new_tp);
77122 }
77123
77124 diff --git a/kernel/power/process.c b/kernel/power/process.c
77125 index d5a258b..4271191 100644
77126 --- a/kernel/power/process.c
77127 +++ b/kernel/power/process.c
77128 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77129 u64 elapsed_csecs64;
77130 unsigned int elapsed_csecs;
77131 bool wakeup = false;
77132 + bool timedout = false;
77133
77134 do_gettimeofday(&start);
77135
77136 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77137
77138 while (true) {
77139 todo = 0;
77140 + if (time_after(jiffies, end_time))
77141 + timedout = true;
77142 read_lock(&tasklist_lock);
77143 do_each_thread(g, p) {
77144 if (p == current || !freeze_task(p))
77145 continue;
77146
77147 - if (!freezer_should_skip(p))
77148 + if (!freezer_should_skip(p)) {
77149 todo++;
77150 + if (timedout) {
77151 + printk(KERN_ERR "Task refusing to freeze:\n");
77152 + sched_show_task(p);
77153 + }
77154 + }
77155 } while_each_thread(g, p);
77156 read_unlock(&tasklist_lock);
77157
77158 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77159 todo += wq_busy;
77160 }
77161
77162 - if (!todo || time_after(jiffies, end_time))
77163 + if (!todo || timedout)
77164 break;
77165
77166 if (pm_wakeup_pending()) {
77167 diff --git a/kernel/printk.c b/kernel/printk.c
77168 index 267ce78..2487112 100644
77169 --- a/kernel/printk.c
77170 +++ b/kernel/printk.c
77171 @@ -609,11 +609,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
77172 return ret;
77173 }
77174
77175 +static int check_syslog_permissions(int type, bool from_file);
77176 +
77177 static int devkmsg_open(struct inode *inode, struct file *file)
77178 {
77179 struct devkmsg_user *user;
77180 int err;
77181
77182 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
77183 + if (err)
77184 + return err;
77185 +
77186 /* write-only does not need any file context */
77187 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
77188 return 0;
77189 @@ -822,7 +828,7 @@ static int syslog_action_restricted(int type)
77190 if (dmesg_restrict)
77191 return 1;
77192 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
77193 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77194 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77195 }
77196
77197 static int check_syslog_permissions(int type, bool from_file)
77198 @@ -834,6 +840,11 @@ static int check_syslog_permissions(int type, bool from_file)
77199 if (from_file && type != SYSLOG_ACTION_OPEN)
77200 return 0;
77201
77202 +#ifdef CONFIG_GRKERNSEC_DMESG
77203 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77204 + return -EPERM;
77205 +#endif
77206 +
77207 if (syslog_action_restricted(type)) {
77208 if (capable(CAP_SYSLOG))
77209 return 0;
77210 diff --git a/kernel/profile.c b/kernel/profile.c
77211 index 1f39181..86093471 100644
77212 --- a/kernel/profile.c
77213 +++ b/kernel/profile.c
77214 @@ -40,7 +40,7 @@ struct profile_hit {
77215 /* Oprofile timer tick hook */
77216 static int (*timer_hook)(struct pt_regs *) __read_mostly;
77217
77218 -static atomic_t *prof_buffer;
77219 +static atomic_unchecked_t *prof_buffer;
77220 static unsigned long prof_len, prof_shift;
77221
77222 int prof_on __read_mostly;
77223 @@ -282,7 +282,7 @@ static void profile_flip_buffers(void)
77224 hits[i].pc = 0;
77225 continue;
77226 }
77227 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77228 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77229 hits[i].hits = hits[i].pc = 0;
77230 }
77231 }
77232 @@ -343,9 +343,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77233 * Add the current hit(s) and flush the write-queue out
77234 * to the global buffer:
77235 */
77236 - atomic_add(nr_hits, &prof_buffer[pc]);
77237 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77238 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77239 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77240 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77241 hits[i].pc = hits[i].hits = 0;
77242 }
77243 out:
77244 @@ -420,7 +420,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77245 {
77246 unsigned long pc;
77247 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77248 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77249 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77250 }
77251 #endif /* !CONFIG_SMP */
77252
77253 @@ -518,7 +518,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77254 return -EFAULT;
77255 buf++; p++; count--; read++;
77256 }
77257 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77258 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77259 if (copy_to_user(buf, (void *)pnt, count))
77260 return -EFAULT;
77261 read += count;
77262 @@ -549,7 +549,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77263 }
77264 #endif
77265 profile_discard_flip_buffers();
77266 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77267 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77268 return count;
77269 }
77270
77271 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77272 index 6cbeaae..cfe7ff0 100644
77273 --- a/kernel/ptrace.c
77274 +++ b/kernel/ptrace.c
77275 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77276 if (seize)
77277 flags |= PT_SEIZED;
77278 rcu_read_lock();
77279 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77280 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77281 flags |= PT_PTRACE_CAP;
77282 rcu_read_unlock();
77283 task->ptrace = flags;
77284 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77285 break;
77286 return -EIO;
77287 }
77288 - if (copy_to_user(dst, buf, retval))
77289 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77290 return -EFAULT;
77291 copied += retval;
77292 src += retval;
77293 @@ -720,7 +720,7 @@ int ptrace_request(struct task_struct *child, long request,
77294 bool seized = child->ptrace & PT_SEIZED;
77295 int ret = -EIO;
77296 siginfo_t siginfo, *si;
77297 - void __user *datavp = (void __user *) data;
77298 + void __user *datavp = (__force void __user *) data;
77299 unsigned long __user *datalp = datavp;
77300 unsigned long flags;
77301
77302 @@ -922,14 +922,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77303 goto out;
77304 }
77305
77306 + if (gr_handle_ptrace(child, request)) {
77307 + ret = -EPERM;
77308 + goto out_put_task_struct;
77309 + }
77310 +
77311 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77312 ret = ptrace_attach(child, request, addr, data);
77313 /*
77314 * Some architectures need to do book-keeping after
77315 * a ptrace attach.
77316 */
77317 - if (!ret)
77318 + if (!ret) {
77319 arch_ptrace_attach(child);
77320 + gr_audit_ptrace(child);
77321 + }
77322 goto out_put_task_struct;
77323 }
77324
77325 @@ -957,7 +964,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77326 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77327 if (copied != sizeof(tmp))
77328 return -EIO;
77329 - return put_user(tmp, (unsigned long __user *)data);
77330 + return put_user(tmp, (__force unsigned long __user *)data);
77331 }
77332
77333 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77334 @@ -1051,7 +1058,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77335 }
77336
77337 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77338 - compat_long_t addr, compat_long_t data)
77339 + compat_ulong_t addr, compat_ulong_t data)
77340 {
77341 struct task_struct *child;
77342 long ret;
77343 @@ -1067,14 +1074,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77344 goto out;
77345 }
77346
77347 + if (gr_handle_ptrace(child, request)) {
77348 + ret = -EPERM;
77349 + goto out_put_task_struct;
77350 + }
77351 +
77352 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77353 ret = ptrace_attach(child, request, addr, data);
77354 /*
77355 * Some architectures need to do book-keeping after
77356 * a ptrace attach.
77357 */
77358 - if (!ret)
77359 + if (!ret) {
77360 arch_ptrace_attach(child);
77361 + gr_audit_ptrace(child);
77362 + }
77363 goto out_put_task_struct;
77364 }
77365
77366 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77367 index e7dce58..ad0d7b7 100644
77368 --- a/kernel/rcutiny.c
77369 +++ b/kernel/rcutiny.c
77370 @@ -46,7 +46,7 @@
77371 struct rcu_ctrlblk;
77372 static void invoke_rcu_callbacks(void);
77373 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77374 -static void rcu_process_callbacks(struct softirq_action *unused);
77375 +static void rcu_process_callbacks(void);
77376 static void __call_rcu(struct rcu_head *head,
77377 void (*func)(struct rcu_head *rcu),
77378 struct rcu_ctrlblk *rcp);
77379 @@ -310,7 +310,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77380 rcu_is_callbacks_kthread()));
77381 }
77382
77383 -static void rcu_process_callbacks(struct softirq_action *unused)
77384 +static void rcu_process_callbacks(void)
77385 {
77386 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77387 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77388 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77389 index f85016a..91cb03b 100644
77390 --- a/kernel/rcutiny_plugin.h
77391 +++ b/kernel/rcutiny_plugin.h
77392 @@ -896,7 +896,7 @@ static int rcu_kthread(void *arg)
77393 have_rcu_kthread_work = morework;
77394 local_irq_restore(flags);
77395 if (work)
77396 - rcu_process_callbacks(NULL);
77397 + rcu_process_callbacks();
77398 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77399 }
77400
77401 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77402 index 31dea01..ad91ffb 100644
77403 --- a/kernel/rcutorture.c
77404 +++ b/kernel/rcutorture.c
77405 @@ -163,12 +163,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77406 { 0 };
77407 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77408 { 0 };
77409 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77410 -static atomic_t n_rcu_torture_alloc;
77411 -static atomic_t n_rcu_torture_alloc_fail;
77412 -static atomic_t n_rcu_torture_free;
77413 -static atomic_t n_rcu_torture_mberror;
77414 -static atomic_t n_rcu_torture_error;
77415 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77416 +static atomic_unchecked_t n_rcu_torture_alloc;
77417 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77418 +static atomic_unchecked_t n_rcu_torture_free;
77419 +static atomic_unchecked_t n_rcu_torture_mberror;
77420 +static atomic_unchecked_t n_rcu_torture_error;
77421 static long n_rcu_torture_barrier_error;
77422 static long n_rcu_torture_boost_ktrerror;
77423 static long n_rcu_torture_boost_rterror;
77424 @@ -272,11 +272,11 @@ rcu_torture_alloc(void)
77425
77426 spin_lock_bh(&rcu_torture_lock);
77427 if (list_empty(&rcu_torture_freelist)) {
77428 - atomic_inc(&n_rcu_torture_alloc_fail);
77429 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77430 spin_unlock_bh(&rcu_torture_lock);
77431 return NULL;
77432 }
77433 - atomic_inc(&n_rcu_torture_alloc);
77434 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77435 p = rcu_torture_freelist.next;
77436 list_del_init(p);
77437 spin_unlock_bh(&rcu_torture_lock);
77438 @@ -289,7 +289,7 @@ rcu_torture_alloc(void)
77439 static void
77440 rcu_torture_free(struct rcu_torture *p)
77441 {
77442 - atomic_inc(&n_rcu_torture_free);
77443 + atomic_inc_unchecked(&n_rcu_torture_free);
77444 spin_lock_bh(&rcu_torture_lock);
77445 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77446 spin_unlock_bh(&rcu_torture_lock);
77447 @@ -409,7 +409,7 @@ rcu_torture_cb(struct rcu_head *p)
77448 i = rp->rtort_pipe_count;
77449 if (i > RCU_TORTURE_PIPE_LEN)
77450 i = RCU_TORTURE_PIPE_LEN;
77451 - atomic_inc(&rcu_torture_wcount[i]);
77452 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77453 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77454 rp->rtort_mbtest = 0;
77455 rcu_torture_free(rp);
77456 @@ -457,7 +457,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77457 i = rp->rtort_pipe_count;
77458 if (i > RCU_TORTURE_PIPE_LEN)
77459 i = RCU_TORTURE_PIPE_LEN;
77460 - atomic_inc(&rcu_torture_wcount[i]);
77461 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77462 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77463 rp->rtort_mbtest = 0;
77464 list_del(&rp->rtort_free);
77465 @@ -975,7 +975,7 @@ rcu_torture_writer(void *arg)
77466 i = old_rp->rtort_pipe_count;
77467 if (i > RCU_TORTURE_PIPE_LEN)
77468 i = RCU_TORTURE_PIPE_LEN;
77469 - atomic_inc(&rcu_torture_wcount[i]);
77470 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77471 old_rp->rtort_pipe_count++;
77472 cur_ops->deferred_free(old_rp);
77473 }
77474 @@ -1060,7 +1060,7 @@ static void rcu_torture_timer(unsigned long unused)
77475 }
77476 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77477 if (p->rtort_mbtest == 0)
77478 - atomic_inc(&n_rcu_torture_mberror);
77479 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77480 spin_lock(&rand_lock);
77481 cur_ops->read_delay(&rand);
77482 n_rcu_torture_timers++;
77483 @@ -1124,7 +1124,7 @@ rcu_torture_reader(void *arg)
77484 }
77485 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77486 if (p->rtort_mbtest == 0)
77487 - atomic_inc(&n_rcu_torture_mberror);
77488 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77489 cur_ops->read_delay(&rand);
77490 preempt_disable();
77491 pipe_count = p->rtort_pipe_count;
77492 @@ -1183,11 +1183,11 @@ rcu_torture_printk(char *page)
77493 rcu_torture_current,
77494 rcu_torture_current_version,
77495 list_empty(&rcu_torture_freelist),
77496 - atomic_read(&n_rcu_torture_alloc),
77497 - atomic_read(&n_rcu_torture_alloc_fail),
77498 - atomic_read(&n_rcu_torture_free));
77499 + atomic_read_unchecked(&n_rcu_torture_alloc),
77500 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77501 + atomic_read_unchecked(&n_rcu_torture_free));
77502 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77503 - atomic_read(&n_rcu_torture_mberror),
77504 + atomic_read_unchecked(&n_rcu_torture_mberror),
77505 n_rcu_torture_boost_ktrerror,
77506 n_rcu_torture_boost_rterror);
77507 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77508 @@ -1206,14 +1206,14 @@ rcu_torture_printk(char *page)
77509 n_barrier_attempts,
77510 n_rcu_torture_barrier_error);
77511 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77512 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77513 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77514 n_rcu_torture_barrier_error != 0 ||
77515 n_rcu_torture_boost_ktrerror != 0 ||
77516 n_rcu_torture_boost_rterror != 0 ||
77517 n_rcu_torture_boost_failure != 0 ||
77518 i > 1) {
77519 cnt += sprintf(&page[cnt], "!!! ");
77520 - atomic_inc(&n_rcu_torture_error);
77521 + atomic_inc_unchecked(&n_rcu_torture_error);
77522 WARN_ON_ONCE(1);
77523 }
77524 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77525 @@ -1227,7 +1227,7 @@ rcu_torture_printk(char *page)
77526 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77527 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77528 cnt += sprintf(&page[cnt], " %d",
77529 - atomic_read(&rcu_torture_wcount[i]));
77530 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77531 }
77532 cnt += sprintf(&page[cnt], "\n");
77533 if (cur_ops->stats)
77534 @@ -1920,7 +1920,7 @@ rcu_torture_cleanup(void)
77535
77536 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77537
77538 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77539 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77540 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77541 else if (n_online_successes != n_online_attempts ||
77542 n_offline_successes != n_offline_attempts)
77543 @@ -1989,18 +1989,18 @@ rcu_torture_init(void)
77544
77545 rcu_torture_current = NULL;
77546 rcu_torture_current_version = 0;
77547 - atomic_set(&n_rcu_torture_alloc, 0);
77548 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77549 - atomic_set(&n_rcu_torture_free, 0);
77550 - atomic_set(&n_rcu_torture_mberror, 0);
77551 - atomic_set(&n_rcu_torture_error, 0);
77552 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77553 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77554 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77555 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77556 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77557 n_rcu_torture_barrier_error = 0;
77558 n_rcu_torture_boost_ktrerror = 0;
77559 n_rcu_torture_boost_rterror = 0;
77560 n_rcu_torture_boost_failure = 0;
77561 n_rcu_torture_boosts = 0;
77562 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77563 - atomic_set(&rcu_torture_wcount[i], 0);
77564 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77565 for_each_possible_cpu(cpu) {
77566 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77567 per_cpu(rcu_torture_count, cpu)[i] = 0;
77568 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77569 index e441b77..dd54f17 100644
77570 --- a/kernel/rcutree.c
77571 +++ b/kernel/rcutree.c
77572 @@ -349,9 +349,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77573 rcu_prepare_for_idle(smp_processor_id());
77574 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77575 smp_mb__before_atomic_inc(); /* See above. */
77576 - atomic_inc(&rdtp->dynticks);
77577 + atomic_inc_unchecked(&rdtp->dynticks);
77578 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77579 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77580 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77581
77582 /*
77583 * It is illegal to enter an extended quiescent state while
77584 @@ -487,10 +487,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77585 int user)
77586 {
77587 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77588 - atomic_inc(&rdtp->dynticks);
77589 + atomic_inc_unchecked(&rdtp->dynticks);
77590 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77591 smp_mb__after_atomic_inc(); /* See above. */
77592 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77593 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77594 rcu_cleanup_after_idle(smp_processor_id());
77595 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77596 if (!user && !is_idle_task(current)) {
77597 @@ -629,14 +629,14 @@ void rcu_nmi_enter(void)
77598 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77599
77600 if (rdtp->dynticks_nmi_nesting == 0 &&
77601 - (atomic_read(&rdtp->dynticks) & 0x1))
77602 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77603 return;
77604 rdtp->dynticks_nmi_nesting++;
77605 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77606 - atomic_inc(&rdtp->dynticks);
77607 + atomic_inc_unchecked(&rdtp->dynticks);
77608 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77609 smp_mb__after_atomic_inc(); /* See above. */
77610 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77611 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77612 }
77613
77614 /**
77615 @@ -655,9 +655,9 @@ void rcu_nmi_exit(void)
77616 return;
77617 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77618 smp_mb__before_atomic_inc(); /* See above. */
77619 - atomic_inc(&rdtp->dynticks);
77620 + atomic_inc_unchecked(&rdtp->dynticks);
77621 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77622 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77623 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77624 }
77625
77626 /**
77627 @@ -671,7 +671,7 @@ int rcu_is_cpu_idle(void)
77628 int ret;
77629
77630 preempt_disable();
77631 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77632 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77633 preempt_enable();
77634 return ret;
77635 }
77636 @@ -739,7 +739,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
77637 */
77638 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77639 {
77640 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77641 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77642 return (rdp->dynticks_snap & 0x1) == 0;
77643 }
77644
77645 @@ -754,7 +754,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77646 unsigned int curr;
77647 unsigned int snap;
77648
77649 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77650 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77651 snap = (unsigned int)rdp->dynticks_snap;
77652
77653 /*
77654 @@ -802,10 +802,10 @@ static int jiffies_till_stall_check(void)
77655 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77656 */
77657 if (till_stall_check < 3) {
77658 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77659 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77660 till_stall_check = 3;
77661 } else if (till_stall_check > 300) {
77662 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77663 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77664 till_stall_check = 300;
77665 }
77666 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77667 @@ -1592,7 +1592,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77668 rsp->qlen += rdp->qlen;
77669 rdp->n_cbs_orphaned += rdp->qlen;
77670 rdp->qlen_lazy = 0;
77671 - ACCESS_ONCE(rdp->qlen) = 0;
77672 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77673 }
77674
77675 /*
77676 @@ -1838,7 +1838,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
77677 }
77678 smp_mb(); /* List handling before counting for rcu_barrier(). */
77679 rdp->qlen_lazy -= count_lazy;
77680 - ACCESS_ONCE(rdp->qlen) -= count;
77681 + ACCESS_ONCE_RW(rdp->qlen) -= count;
77682 rdp->n_cbs_invoked += count;
77683
77684 /* Reinstate batch limit if we have worked down the excess. */
77685 @@ -2031,7 +2031,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
77686 /*
77687 * Do RCU core processing for the current CPU.
77688 */
77689 -static void rcu_process_callbacks(struct softirq_action *unused)
77690 +static void rcu_process_callbacks(void)
77691 {
77692 struct rcu_state *rsp;
77693
77694 @@ -2154,7 +2154,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
77695 local_irq_restore(flags);
77696 return;
77697 }
77698 - ACCESS_ONCE(rdp->qlen)++;
77699 + ACCESS_ONCE_RW(rdp->qlen)++;
77700 if (lazy)
77701 rdp->qlen_lazy++;
77702 else
77703 @@ -2363,11 +2363,11 @@ void synchronize_sched_expedited(void)
77704 * counter wrap on a 32-bit system. Quite a few more CPUs would of
77705 * course be required on a 64-bit system.
77706 */
77707 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
77708 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
77709 (ulong)atomic_long_read(&rsp->expedited_done) +
77710 ULONG_MAX / 8)) {
77711 synchronize_sched();
77712 - atomic_long_inc(&rsp->expedited_wrap);
77713 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
77714 return;
77715 }
77716
77717 @@ -2375,7 +2375,7 @@ void synchronize_sched_expedited(void)
77718 * Take a ticket. Note that atomic_inc_return() implies a
77719 * full memory barrier.
77720 */
77721 - snap = atomic_long_inc_return(&rsp->expedited_start);
77722 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
77723 firstsnap = snap;
77724 get_online_cpus();
77725 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77726 @@ -2388,14 +2388,14 @@ void synchronize_sched_expedited(void)
77727 synchronize_sched_expedited_cpu_stop,
77728 NULL) == -EAGAIN) {
77729 put_online_cpus();
77730 - atomic_long_inc(&rsp->expedited_tryfail);
77731 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77732
77733 /* Check to see if someone else did our work for us. */
77734 s = atomic_long_read(&rsp->expedited_done);
77735 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77736 /* ensure test happens before caller kfree */
77737 smp_mb__before_atomic_inc(); /* ^^^ */
77738 - atomic_long_inc(&rsp->expedited_workdone1);
77739 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77740 return;
77741 }
77742
77743 @@ -2404,7 +2404,7 @@ void synchronize_sched_expedited(void)
77744 udelay(trycount * num_online_cpus());
77745 } else {
77746 wait_rcu_gp(call_rcu_sched);
77747 - atomic_long_inc(&rsp->expedited_normal);
77748 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77749 return;
77750 }
77751
77752 @@ -2413,7 +2413,7 @@ void synchronize_sched_expedited(void)
77753 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77754 /* ensure test happens before caller kfree */
77755 smp_mb__before_atomic_inc(); /* ^^^ */
77756 - atomic_long_inc(&rsp->expedited_workdone2);
77757 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77758 return;
77759 }
77760
77761 @@ -2425,10 +2425,10 @@ void synchronize_sched_expedited(void)
77762 * period works for us.
77763 */
77764 get_online_cpus();
77765 - snap = atomic_long_read(&rsp->expedited_start);
77766 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77767 smp_mb(); /* ensure read is before try_stop_cpus(). */
77768 }
77769 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77770 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77771
77772 /*
77773 * Everyone up to our most recent fetch is covered by our grace
77774 @@ -2437,16 +2437,16 @@ void synchronize_sched_expedited(void)
77775 * than we did already did their update.
77776 */
77777 do {
77778 - atomic_long_inc(&rsp->expedited_done_tries);
77779 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77780 s = atomic_long_read(&rsp->expedited_done);
77781 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77782 /* ensure test happens before caller kfree */
77783 smp_mb__before_atomic_inc(); /* ^^^ */
77784 - atomic_long_inc(&rsp->expedited_done_lost);
77785 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77786 break;
77787 }
77788 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77789 - atomic_long_inc(&rsp->expedited_done_exit);
77790 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77791
77792 put_online_cpus();
77793 }
77794 @@ -2620,7 +2620,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77795 * ACCESS_ONCE() to prevent the compiler from speculating
77796 * the increment to precede the early-exit check.
77797 */
77798 - ACCESS_ONCE(rsp->n_barrier_done)++;
77799 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77800 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
77801 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
77802 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
77803 @@ -2670,7 +2670,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77804
77805 /* Increment ->n_barrier_done to prevent duplicate work. */
77806 smp_mb(); /* Keep increment after above mechanism. */
77807 - ACCESS_ONCE(rsp->n_barrier_done)++;
77808 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77809 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
77810 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
77811 smp_mb(); /* Keep increment before caller's subsequent code. */
77812 @@ -2715,10 +2715,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
77813 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
77814 init_callback_list(rdp);
77815 rdp->qlen_lazy = 0;
77816 - ACCESS_ONCE(rdp->qlen) = 0;
77817 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77818 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
77819 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
77820 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
77821 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
77822 #ifdef CONFIG_RCU_USER_QS
77823 WARN_ON_ONCE(rdp->dynticks->in_user);
77824 #endif
77825 @@ -2754,8 +2754,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
77826 rdp->blimit = blimit;
77827 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
77828 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
77829 - atomic_set(&rdp->dynticks->dynticks,
77830 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
77831 + atomic_set_unchecked(&rdp->dynticks->dynticks,
77832 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
77833 rcu_prepare_for_idle_init(cpu);
77834 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
77835
77836 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
77837 index 4b69291..704c92e 100644
77838 --- a/kernel/rcutree.h
77839 +++ b/kernel/rcutree.h
77840 @@ -86,7 +86,7 @@ struct rcu_dynticks {
77841 long long dynticks_nesting; /* Track irq/process nesting level. */
77842 /* Process level is worth LLONG_MAX/2. */
77843 int dynticks_nmi_nesting; /* Track NMI nesting level. */
77844 - atomic_t dynticks; /* Even value for idle, else odd. */
77845 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
77846 #ifdef CONFIG_RCU_FAST_NO_HZ
77847 int dyntick_drain; /* Prepare-for-idle state variable. */
77848 unsigned long dyntick_holdoff;
77849 @@ -423,17 +423,17 @@ struct rcu_state {
77850 /* _rcu_barrier(). */
77851 /* End of fields guarded by barrier_mutex. */
77852
77853 - atomic_long_t expedited_start; /* Starting ticket. */
77854 - atomic_long_t expedited_done; /* Done ticket. */
77855 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
77856 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
77857 - atomic_long_t expedited_workdone1; /* # done by others #1. */
77858 - atomic_long_t expedited_workdone2; /* # done by others #2. */
77859 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
77860 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
77861 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
77862 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
77863 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
77864 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
77865 + atomic_long_t expedited_done; /* Done ticket. */
77866 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
77867 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
77868 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
77869 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
77870 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
77871 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
77872 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
77873 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
77874 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
77875
77876 unsigned long jiffies_force_qs; /* Time at which to invoke */
77877 /* force_quiescent_state(). */
77878 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
77879 index c1cc7e1..f62e436 100644
77880 --- a/kernel/rcutree_plugin.h
77881 +++ b/kernel/rcutree_plugin.h
77882 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
77883
77884 /* Clean up and exit. */
77885 smp_mb(); /* ensure expedited GP seen before counter increment. */
77886 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
77887 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
77888 unlock_mb_ret:
77889 mutex_unlock(&sync_rcu_preempt_exp_mutex);
77890 mb_ret:
77891 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
77892 free_cpumask_var(cm);
77893 }
77894
77895 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
77896 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
77897 .store = &rcu_cpu_kthread_task,
77898 .thread_should_run = rcu_cpu_kthread_should_run,
77899 .thread_fn = rcu_cpu_kthread,
77900 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
77901 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
77902 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
77903 cpu, ticks_value, ticks_title,
77904 - atomic_read(&rdtp->dynticks) & 0xfff,
77905 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
77906 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
77907 fast_no_hz);
77908 }
77909 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
77910
77911 /* Enqueue the callback on the nocb list and update counts. */
77912 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
77913 - ACCESS_ONCE(*old_rhpp) = rhp;
77914 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
77915 atomic_long_add(rhcount, &rdp->nocb_q_count);
77916 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
77917
77918 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
77919 * Extract queued callbacks, update counts, and wait
77920 * for a grace period to elapse.
77921 */
77922 - ACCESS_ONCE(rdp->nocb_head) = NULL;
77923 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
77924 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
77925 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
77926 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
77927 - ACCESS_ONCE(rdp->nocb_p_count) += c;
77928 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
77929 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
77930 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
77931 wait_rcu_gp(rdp->rsp->call_remote);
77932
77933 /* Each pass through the following loop invokes a callback. */
77934 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
77935 list = next;
77936 }
77937 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
77938 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
77939 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
77940 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
77941 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
77942 rdp->n_nocbs_invoked += c;
77943 }
77944 return 0;
77945 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
77946 rdp = per_cpu_ptr(rsp->rda, cpu);
77947 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
77948 BUG_ON(IS_ERR(t));
77949 - ACCESS_ONCE(rdp->nocb_kthread) = t;
77950 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
77951 }
77952 }
77953
77954 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
77955 index 0d095dc..1985b19 100644
77956 --- a/kernel/rcutree_trace.c
77957 +++ b/kernel/rcutree_trace.c
77958 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
77959 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
77960 rdp->passed_quiesce, rdp->qs_pending);
77961 seq_printf(m, " dt=%d/%llx/%d df=%lu",
77962 - atomic_read(&rdp->dynticks->dynticks),
77963 + atomic_read_unchecked(&rdp->dynticks->dynticks),
77964 rdp->dynticks->dynticks_nesting,
77965 rdp->dynticks->dynticks_nmi_nesting,
77966 rdp->dynticks_fqs);
77967 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
77968 struct rcu_state *rsp = (struct rcu_state *)m->private;
77969
77970 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",
77971 - atomic_long_read(&rsp->expedited_start),
77972 + atomic_long_read_unchecked(&rsp->expedited_start),
77973 atomic_long_read(&rsp->expedited_done),
77974 - atomic_long_read(&rsp->expedited_wrap),
77975 - atomic_long_read(&rsp->expedited_tryfail),
77976 - atomic_long_read(&rsp->expedited_workdone1),
77977 - atomic_long_read(&rsp->expedited_workdone2),
77978 - atomic_long_read(&rsp->expedited_normal),
77979 - atomic_long_read(&rsp->expedited_stoppedcpus),
77980 - atomic_long_read(&rsp->expedited_done_tries),
77981 - atomic_long_read(&rsp->expedited_done_lost),
77982 - atomic_long_read(&rsp->expedited_done_exit));
77983 + atomic_long_read_unchecked(&rsp->expedited_wrap),
77984 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
77985 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
77986 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
77987 + atomic_long_read_unchecked(&rsp->expedited_normal),
77988 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
77989 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
77990 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
77991 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
77992 return 0;
77993 }
77994
77995 diff --git a/kernel/resource.c b/kernel/resource.c
77996 index 73f35d4..4684fc4 100644
77997 --- a/kernel/resource.c
77998 +++ b/kernel/resource.c
77999 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
78000
78001 static int __init ioresources_init(void)
78002 {
78003 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78004 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78005 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78006 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78007 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78008 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78009 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78010 +#endif
78011 +#else
78012 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78013 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78014 +#endif
78015 return 0;
78016 }
78017 __initcall(ioresources_init);
78018 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78019 index 98ec494..4241d6d 100644
78020 --- a/kernel/rtmutex-tester.c
78021 +++ b/kernel/rtmutex-tester.c
78022 @@ -20,7 +20,7 @@
78023 #define MAX_RT_TEST_MUTEXES 8
78024
78025 static spinlock_t rttest_lock;
78026 -static atomic_t rttest_event;
78027 +static atomic_unchecked_t rttest_event;
78028
78029 struct test_thread_data {
78030 int opcode;
78031 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78032
78033 case RTTEST_LOCKCONT:
78034 td->mutexes[td->opdata] = 1;
78035 - td->event = atomic_add_return(1, &rttest_event);
78036 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78037 return 0;
78038
78039 case RTTEST_RESET:
78040 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78041 return 0;
78042
78043 case RTTEST_RESETEVENT:
78044 - atomic_set(&rttest_event, 0);
78045 + atomic_set_unchecked(&rttest_event, 0);
78046 return 0;
78047
78048 default:
78049 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78050 return ret;
78051
78052 td->mutexes[id] = 1;
78053 - td->event = atomic_add_return(1, &rttest_event);
78054 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78055 rt_mutex_lock(&mutexes[id]);
78056 - td->event = atomic_add_return(1, &rttest_event);
78057 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78058 td->mutexes[id] = 4;
78059 return 0;
78060
78061 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78062 return ret;
78063
78064 td->mutexes[id] = 1;
78065 - td->event = atomic_add_return(1, &rttest_event);
78066 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78067 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78068 - td->event = atomic_add_return(1, &rttest_event);
78069 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78070 td->mutexes[id] = ret ? 0 : 4;
78071 return ret ? -EINTR : 0;
78072
78073 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78074 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78075 return ret;
78076
78077 - td->event = atomic_add_return(1, &rttest_event);
78078 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78079 rt_mutex_unlock(&mutexes[id]);
78080 - td->event = atomic_add_return(1, &rttest_event);
78081 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78082 td->mutexes[id] = 0;
78083 return 0;
78084
78085 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78086 break;
78087
78088 td->mutexes[dat] = 2;
78089 - td->event = atomic_add_return(1, &rttest_event);
78090 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78091 break;
78092
78093 default:
78094 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78095 return;
78096
78097 td->mutexes[dat] = 3;
78098 - td->event = atomic_add_return(1, &rttest_event);
78099 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78100 break;
78101
78102 case RTTEST_LOCKNOWAIT:
78103 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78104 return;
78105
78106 td->mutexes[dat] = 1;
78107 - td->event = atomic_add_return(1, &rttest_event);
78108 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78109 return;
78110
78111 default:
78112 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78113 index 0984a21..939f183 100644
78114 --- a/kernel/sched/auto_group.c
78115 +++ b/kernel/sched/auto_group.c
78116 @@ -11,7 +11,7 @@
78117
78118 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78119 static struct autogroup autogroup_default;
78120 -static atomic_t autogroup_seq_nr;
78121 +static atomic_unchecked_t autogroup_seq_nr;
78122
78123 void __init autogroup_init(struct task_struct *init_task)
78124 {
78125 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
78126
78127 kref_init(&ag->kref);
78128 init_rwsem(&ag->lock);
78129 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78130 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78131 ag->tg = tg;
78132 #ifdef CONFIG_RT_GROUP_SCHED
78133 /*
78134 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78135 index 26058d0..e315889 100644
78136 --- a/kernel/sched/core.c
78137 +++ b/kernel/sched/core.c
78138 @@ -3367,7 +3367,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78139 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78140 * positive (at least 1, or number of jiffies left till timeout) if completed.
78141 */
78142 -long __sched
78143 +long __sched __intentional_overflow(-1)
78144 wait_for_completion_interruptible_timeout(struct completion *x,
78145 unsigned long timeout)
78146 {
78147 @@ -3384,7 +3384,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78148 *
78149 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78150 */
78151 -int __sched wait_for_completion_killable(struct completion *x)
78152 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78153 {
78154 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78155 if (t == -ERESTARTSYS)
78156 @@ -3405,7 +3405,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78157 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78158 * positive (at least 1, or number of jiffies left till timeout) if completed.
78159 */
78160 -long __sched
78161 +long __sched __intentional_overflow(-1)
78162 wait_for_completion_killable_timeout(struct completion *x,
78163 unsigned long timeout)
78164 {
78165 @@ -3631,6 +3631,8 @@ int can_nice(const struct task_struct *p, const int nice)
78166 /* convert nice value [19,-20] to rlimit style value [1,40] */
78167 int nice_rlim = 20 - nice;
78168
78169 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78170 +
78171 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78172 capable(CAP_SYS_NICE));
78173 }
78174 @@ -3664,7 +3666,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78175 if (nice > 19)
78176 nice = 19;
78177
78178 - if (increment < 0 && !can_nice(current, nice))
78179 + if (increment < 0 && (!can_nice(current, nice) ||
78180 + gr_handle_chroot_nice()))
78181 return -EPERM;
78182
78183 retval = security_task_setnice(current, nice);
78184 @@ -3818,6 +3821,7 @@ recheck:
78185 unsigned long rlim_rtprio =
78186 task_rlimit(p, RLIMIT_RTPRIO);
78187
78188 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78189 /* can't set/change the rt policy */
78190 if (policy != p->policy && !rlim_rtprio)
78191 return -EPERM;
78192 @@ -4901,7 +4905,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78193
78194 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78195
78196 -static struct ctl_table sd_ctl_dir[] = {
78197 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78198 {
78199 .procname = "sched_domain",
78200 .mode = 0555,
78201 @@ -4918,17 +4922,17 @@ static struct ctl_table sd_ctl_root[] = {
78202 {}
78203 };
78204
78205 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78206 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78207 {
78208 - struct ctl_table *entry =
78209 + ctl_table_no_const *entry =
78210 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78211
78212 return entry;
78213 }
78214
78215 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78216 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78217 {
78218 - struct ctl_table *entry;
78219 + ctl_table_no_const *entry;
78220
78221 /*
78222 * In the intermediate directories, both the child directory and
78223 @@ -4936,22 +4940,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78224 * will always be set. In the lowest directory the names are
78225 * static strings and all have proc handlers.
78226 */
78227 - for (entry = *tablep; entry->mode; entry++) {
78228 - if (entry->child)
78229 - sd_free_ctl_entry(&entry->child);
78230 + for (entry = tablep; entry->mode; entry++) {
78231 + if (entry->child) {
78232 + sd_free_ctl_entry(entry->child);
78233 + pax_open_kernel();
78234 + entry->child = NULL;
78235 + pax_close_kernel();
78236 + }
78237 if (entry->proc_handler == NULL)
78238 kfree(entry->procname);
78239 }
78240
78241 - kfree(*tablep);
78242 - *tablep = NULL;
78243 + kfree(tablep);
78244 }
78245
78246 static int min_load_idx = 0;
78247 static int max_load_idx = CPU_LOAD_IDX_MAX;
78248
78249 static void
78250 -set_table_entry(struct ctl_table *entry,
78251 +set_table_entry(ctl_table_no_const *entry,
78252 const char *procname, void *data, int maxlen,
78253 umode_t mode, proc_handler *proc_handler,
78254 bool load_idx)
78255 @@ -4971,7 +4978,7 @@ set_table_entry(struct ctl_table *entry,
78256 static struct ctl_table *
78257 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78258 {
78259 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78260 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78261
78262 if (table == NULL)
78263 return NULL;
78264 @@ -5006,9 +5013,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78265 return table;
78266 }
78267
78268 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78269 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78270 {
78271 - struct ctl_table *entry, *table;
78272 + ctl_table_no_const *entry, *table;
78273 struct sched_domain *sd;
78274 int domain_num = 0, i;
78275 char buf[32];
78276 @@ -5035,11 +5042,13 @@ static struct ctl_table_header *sd_sysctl_header;
78277 static void register_sched_domain_sysctl(void)
78278 {
78279 int i, cpu_num = num_possible_cpus();
78280 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78281 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78282 char buf[32];
78283
78284 WARN_ON(sd_ctl_dir[0].child);
78285 + pax_open_kernel();
78286 sd_ctl_dir[0].child = entry;
78287 + pax_close_kernel();
78288
78289 if (entry == NULL)
78290 return;
78291 @@ -5062,8 +5071,12 @@ static void unregister_sched_domain_sysctl(void)
78292 if (sd_sysctl_header)
78293 unregister_sysctl_table(sd_sysctl_header);
78294 sd_sysctl_header = NULL;
78295 - if (sd_ctl_dir[0].child)
78296 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78297 + if (sd_ctl_dir[0].child) {
78298 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78299 + pax_open_kernel();
78300 + sd_ctl_dir[0].child = NULL;
78301 + pax_close_kernel();
78302 + }
78303 }
78304 #else
78305 static void register_sched_domain_sysctl(void)
78306 @@ -5162,7 +5175,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78307 * happens before everything else. This has to be lower priority than
78308 * the notifier in the perf_event subsystem, though.
78309 */
78310 -static struct notifier_block __cpuinitdata migration_notifier = {
78311 +static struct notifier_block migration_notifier = {
78312 .notifier_call = migration_call,
78313 .priority = CPU_PRI_MIGRATION,
78314 };
78315 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78316 index 81fa536..6ccf96a 100644
78317 --- a/kernel/sched/fair.c
78318 +++ b/kernel/sched/fair.c
78319 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78320
78321 static void reset_ptenuma_scan(struct task_struct *p)
78322 {
78323 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78324 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78325 p->mm->numa_scan_offset = 0;
78326 }
78327
78328 @@ -3254,25 +3254,18 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
78329 */
78330 static int select_idle_sibling(struct task_struct *p, int target)
78331 {
78332 - int cpu = smp_processor_id();
78333 - int prev_cpu = task_cpu(p);
78334 struct sched_domain *sd;
78335 struct sched_group *sg;
78336 - int i;
78337 + int i = task_cpu(p);
78338
78339 - /*
78340 - * If the task is going to be woken-up on this cpu and if it is
78341 - * already idle, then it is the right target.
78342 - */
78343 - if (target == cpu && idle_cpu(cpu))
78344 - return cpu;
78345 + if (idle_cpu(target))
78346 + return target;
78347
78348 /*
78349 - * If the task is going to be woken-up on the cpu where it previously
78350 - * ran and if it is currently idle, then it the right target.
78351 + * If the prevous cpu is cache affine and idle, don't be stupid.
78352 */
78353 - if (target == prev_cpu && idle_cpu(prev_cpu))
78354 - return prev_cpu;
78355 + if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
78356 + return i;
78357
78358 /*
78359 * Otherwise, iterate the domains and find an elegible idle cpu.
78360 @@ -3286,7 +3279,7 @@ static int select_idle_sibling(struct task_struct *p, int target)
78361 goto next;
78362
78363 for_each_cpu(i, sched_group_cpus(sg)) {
78364 - if (!idle_cpu(i))
78365 + if (i == target || !idle_cpu(i))
78366 goto next;
78367 }
78368
78369 @@ -5663,7 +5656,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78370 * run_rebalance_domains is triggered when needed from the scheduler tick.
78371 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78372 */
78373 -static void run_rebalance_domains(struct softirq_action *h)
78374 +static void run_rebalance_domains(void)
78375 {
78376 int this_cpu = smp_processor_id();
78377 struct rq *this_rq = cpu_rq(this_cpu);
78378 diff --git a/kernel/signal.c b/kernel/signal.c
78379 index dec9c30..d1da15b 100644
78380 --- a/kernel/signal.c
78381 +++ b/kernel/signal.c
78382 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78383
78384 int print_fatal_signals __read_mostly;
78385
78386 -static void __user *sig_handler(struct task_struct *t, int sig)
78387 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78388 {
78389 return t->sighand->action[sig - 1].sa.sa_handler;
78390 }
78391
78392 -static int sig_handler_ignored(void __user *handler, int sig)
78393 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78394 {
78395 /* Is it explicitly or implicitly ignored? */
78396 return handler == SIG_IGN ||
78397 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78398
78399 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78400 {
78401 - void __user *handler;
78402 + __sighandler_t handler;
78403
78404 handler = sig_handler(t, sig);
78405
78406 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78407 atomic_inc(&user->sigpending);
78408 rcu_read_unlock();
78409
78410 + if (!override_rlimit)
78411 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78412 +
78413 if (override_rlimit ||
78414 atomic_read(&user->sigpending) <=
78415 task_rlimit(t, RLIMIT_SIGPENDING)) {
78416 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78417
78418 int unhandled_signal(struct task_struct *tsk, int sig)
78419 {
78420 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78421 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78422 if (is_global_init(tsk))
78423 return 1;
78424 if (handler != SIG_IGN && handler != SIG_DFL)
78425 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78426 }
78427 }
78428
78429 + /* allow glibc communication via tgkill to other threads in our
78430 + thread group */
78431 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78432 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78433 + && gr_handle_signal(t, sig))
78434 + return -EPERM;
78435 +
78436 return security_task_kill(t, info, sig, 0);
78437 }
78438
78439 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78440 return send_signal(sig, info, p, 1);
78441 }
78442
78443 -static int
78444 +int
78445 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78446 {
78447 return send_signal(sig, info, t, 0);
78448 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78449 unsigned long int flags;
78450 int ret, blocked, ignored;
78451 struct k_sigaction *action;
78452 + int is_unhandled = 0;
78453
78454 spin_lock_irqsave(&t->sighand->siglock, flags);
78455 action = &t->sighand->action[sig-1];
78456 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78457 }
78458 if (action->sa.sa_handler == SIG_DFL)
78459 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78460 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78461 + is_unhandled = 1;
78462 ret = specific_send_sig_info(sig, info, t);
78463 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78464
78465 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78466 + normal operation */
78467 + if (is_unhandled) {
78468 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78469 + gr_handle_crash(t, sig);
78470 + }
78471 +
78472 return ret;
78473 }
78474
78475 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78476 ret = check_kill_permission(sig, info, p);
78477 rcu_read_unlock();
78478
78479 - if (!ret && sig)
78480 + if (!ret && sig) {
78481 ret = do_send_sig_info(sig, info, p, true);
78482 + if (!ret)
78483 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78484 + }
78485
78486 return ret;
78487 }
78488 @@ -2855,7 +2878,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78489 int error = -ESRCH;
78490
78491 rcu_read_lock();
78492 - p = find_task_by_vpid(pid);
78493 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78494 + /* allow glibc communication via tgkill to other threads in our
78495 + thread group */
78496 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78497 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78498 + p = find_task_by_vpid_unrestricted(pid);
78499 + else
78500 +#endif
78501 + p = find_task_by_vpid(pid);
78502 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78503 error = check_kill_permission(sig, info, p);
78504 /*
78505 @@ -3138,8 +3169,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78506 }
78507 seg = get_fs();
78508 set_fs(KERNEL_DS);
78509 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78510 - (stack_t __force __user *) &uoss,
78511 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78512 + (stack_t __force_user *) &uoss,
78513 compat_user_stack_pointer());
78514 set_fs(seg);
78515 if (ret >= 0 && uoss_ptr) {
78516 diff --git a/kernel/smp.c b/kernel/smp.c
78517 index 69f38bd..77bbf12 100644
78518 --- a/kernel/smp.c
78519 +++ b/kernel/smp.c
78520 @@ -77,7 +77,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78521 return NOTIFY_OK;
78522 }
78523
78524 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78525 +static struct notifier_block hotplug_cfd_notifier = {
78526 .notifier_call = hotplug_cfd,
78527 };
78528
78529 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78530 index d6c5fc0..530560c 100644
78531 --- a/kernel/smpboot.c
78532 +++ b/kernel/smpboot.c
78533 @@ -275,7 +275,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78534 }
78535 smpboot_unpark_thread(plug_thread, cpu);
78536 }
78537 - list_add(&plug_thread->list, &hotplug_threads);
78538 + pax_list_add(&plug_thread->list, &hotplug_threads);
78539 out:
78540 mutex_unlock(&smpboot_threads_lock);
78541 return ret;
78542 @@ -292,7 +292,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78543 {
78544 get_online_cpus();
78545 mutex_lock(&smpboot_threads_lock);
78546 - list_del(&plug_thread->list);
78547 + pax_list_del(&plug_thread->list);
78548 smpboot_destroy_threads(plug_thread);
78549 mutex_unlock(&smpboot_threads_lock);
78550 put_online_cpus();
78551 diff --git a/kernel/softirq.c b/kernel/softirq.c
78552 index ed567ba..e71dabf 100644
78553 --- a/kernel/softirq.c
78554 +++ b/kernel/softirq.c
78555 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78556 EXPORT_SYMBOL(irq_stat);
78557 #endif
78558
78559 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78560 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78561
78562 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78563
78564 -char *softirq_to_name[NR_SOFTIRQS] = {
78565 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78566 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78567 "TASKLET", "SCHED", "HRTIMER", "RCU"
78568 };
78569 @@ -244,7 +244,7 @@ restart:
78570 kstat_incr_softirqs_this_cpu(vec_nr);
78571
78572 trace_softirq_entry(vec_nr);
78573 - h->action(h);
78574 + h->action();
78575 trace_softirq_exit(vec_nr);
78576 if (unlikely(prev_count != preempt_count())) {
78577 printk(KERN_ERR "huh, entered softirq %u %s %p"
78578 @@ -391,7 +391,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78579 or_softirq_pending(1UL << nr);
78580 }
78581
78582 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78583 +void __init open_softirq(int nr, void (*action)(void))
78584 {
78585 softirq_vec[nr].action = action;
78586 }
78587 @@ -447,7 +447,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78588
78589 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78590
78591 -static void tasklet_action(struct softirq_action *a)
78592 +static void tasklet_action(void)
78593 {
78594 struct tasklet_struct *list;
78595
78596 @@ -482,7 +482,7 @@ static void tasklet_action(struct softirq_action *a)
78597 }
78598 }
78599
78600 -static void tasklet_hi_action(struct softirq_action *a)
78601 +static void tasklet_hi_action(void)
78602 {
78603 struct tasklet_struct *list;
78604
78605 @@ -718,7 +718,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78606 return NOTIFY_OK;
78607 }
78608
78609 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78610 +static struct notifier_block remote_softirq_cpu_notifier = {
78611 .notifier_call = remote_softirq_cpu_notify,
78612 };
78613
78614 @@ -835,11 +835,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78615 return NOTIFY_OK;
78616 }
78617
78618 -static struct notifier_block __cpuinitdata cpu_nfb = {
78619 +static struct notifier_block cpu_nfb = {
78620 .notifier_call = cpu_callback
78621 };
78622
78623 -static struct smp_hotplug_thread softirq_threads = {
78624 +static struct smp_hotplug_thread softirq_threads __read_only = {
78625 .store = &ksoftirqd,
78626 .thread_should_run = ksoftirqd_should_run,
78627 .thread_fn = run_ksoftirqd,
78628 diff --git a/kernel/srcu.c b/kernel/srcu.c
78629 index 2b85982..d52ab26 100644
78630 --- a/kernel/srcu.c
78631 +++ b/kernel/srcu.c
78632 @@ -305,9 +305,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78633 preempt_disable();
78634 idx = rcu_dereference_index_check(sp->completed,
78635 rcu_read_lock_sched_held()) & 0x1;
78636 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78637 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78638 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78639 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78640 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78641 preempt_enable();
78642 return idx;
78643 }
78644 @@ -323,7 +323,7 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
78645 {
78646 preempt_disable();
78647 smp_mb(); /* C */ /* Avoid leaking the critical section. */
78648 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78649 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78650 preempt_enable();
78651 }
78652 EXPORT_SYMBOL_GPL(__srcu_read_unlock);
78653 diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
78654 index 2f194e9..2c05ea9 100644
78655 --- a/kernel/stop_machine.c
78656 +++ b/kernel/stop_machine.c
78657 @@ -362,7 +362,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
78658 * cpu notifiers. It currently shares the same priority as sched
78659 * migration_notifier.
78660 */
78661 -static struct notifier_block __cpuinitdata cpu_stop_cpu_notifier = {
78662 +static struct notifier_block cpu_stop_cpu_notifier = {
78663 .notifier_call = cpu_stop_cpu_callback,
78664 .priority = 10,
78665 };
78666 diff --git a/kernel/sys.c b/kernel/sys.c
78667 index 265b376..4e42ef5 100644
78668 --- a/kernel/sys.c
78669 +++ b/kernel/sys.c
78670 @@ -157,6 +157,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78671 error = -EACCES;
78672 goto out;
78673 }
78674 +
78675 + if (gr_handle_chroot_setpriority(p, niceval)) {
78676 + error = -EACCES;
78677 + goto out;
78678 + }
78679 +
78680 no_nice = security_task_setnice(p, niceval);
78681 if (no_nice) {
78682 error = no_nice;
78683 @@ -595,6 +601,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78684 goto error;
78685 }
78686
78687 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78688 + goto error;
78689 +
78690 if (rgid != (gid_t) -1 ||
78691 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78692 new->sgid = new->egid;
78693 @@ -630,6 +639,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78694 old = current_cred();
78695
78696 retval = -EPERM;
78697 +
78698 + if (gr_check_group_change(kgid, kgid, kgid))
78699 + goto error;
78700 +
78701 if (nsown_capable(CAP_SETGID))
78702 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78703 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78704 @@ -647,7 +660,7 @@ error:
78705 /*
78706 * change the user struct in a credentials set to match the new UID
78707 */
78708 -static int set_user(struct cred *new)
78709 +int set_user(struct cred *new)
78710 {
78711 struct user_struct *new_user;
78712
78713 @@ -727,6 +740,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78714 goto error;
78715 }
78716
78717 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78718 + goto error;
78719 +
78720 if (!uid_eq(new->uid, old->uid)) {
78721 retval = set_user(new);
78722 if (retval < 0)
78723 @@ -777,6 +793,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78724 old = current_cred();
78725
78726 retval = -EPERM;
78727 +
78728 + if (gr_check_crash_uid(kuid))
78729 + goto error;
78730 + if (gr_check_user_change(kuid, kuid, kuid))
78731 + goto error;
78732 +
78733 if (nsown_capable(CAP_SETUID)) {
78734 new->suid = new->uid = kuid;
78735 if (!uid_eq(kuid, old->uid)) {
78736 @@ -846,6 +868,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78737 goto error;
78738 }
78739
78740 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78741 + goto error;
78742 +
78743 if (ruid != (uid_t) -1) {
78744 new->uid = kruid;
78745 if (!uid_eq(kruid, old->uid)) {
78746 @@ -928,6 +953,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
78747 goto error;
78748 }
78749
78750 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
78751 + goto error;
78752 +
78753 if (rgid != (gid_t) -1)
78754 new->gid = krgid;
78755 if (egid != (gid_t) -1)
78756 @@ -981,6 +1009,9 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78757 if (!uid_valid(kuid))
78758 return old_fsuid;
78759
78760 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
78761 + goto error;
78762 +
78763 new = prepare_creds();
78764 if (!new)
78765 return old_fsuid;
78766 @@ -995,6 +1026,7 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78767 }
78768 }
78769
78770 +error:
78771 abort_creds(new);
78772 return old_fsuid;
78773
78774 @@ -1027,12 +1059,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
78775 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
78776 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
78777 nsown_capable(CAP_SETGID)) {
78778 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
78779 + goto error;
78780 +
78781 if (!gid_eq(kgid, old->fsgid)) {
78782 new->fsgid = kgid;
78783 goto change_okay;
78784 }
78785 }
78786
78787 +error:
78788 abort_creds(new);
78789 return old_fsgid;
78790
78791 @@ -1340,19 +1376,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78792 return -EFAULT;
78793
78794 down_read(&uts_sem);
78795 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78796 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78797 __OLD_UTS_LEN);
78798 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
78799 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
78800 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
78801 __OLD_UTS_LEN);
78802 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
78803 - error |= __copy_to_user(&name->release, &utsname()->release,
78804 + error |= __copy_to_user(name->release, &utsname()->release,
78805 __OLD_UTS_LEN);
78806 error |= __put_user(0, name->release + __OLD_UTS_LEN);
78807 - error |= __copy_to_user(&name->version, &utsname()->version,
78808 + error |= __copy_to_user(name->version, &utsname()->version,
78809 __OLD_UTS_LEN);
78810 error |= __put_user(0, name->version + __OLD_UTS_LEN);
78811 - error |= __copy_to_user(&name->machine, &utsname()->machine,
78812 + error |= __copy_to_user(name->machine, &utsname()->machine,
78813 __OLD_UTS_LEN);
78814 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
78815 up_read(&uts_sem);
78816 @@ -2026,7 +2062,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
78817 error = get_dumpable(me->mm);
78818 break;
78819 case PR_SET_DUMPABLE:
78820 - if (arg2 < 0 || arg2 > 1) {
78821 + if (arg2 > 1) {
78822 error = -EINVAL;
78823 break;
78824 }
78825 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
78826 index c88878d..e4fa5d1 100644
78827 --- a/kernel/sysctl.c
78828 +++ b/kernel/sysctl.c
78829 @@ -92,7 +92,6 @@
78830
78831
78832 #if defined(CONFIG_SYSCTL)
78833 -
78834 /* External variables not in a header file. */
78835 extern int sysctl_overcommit_memory;
78836 extern int sysctl_overcommit_ratio;
78837 @@ -172,10 +171,8 @@ static int proc_taint(struct ctl_table *table, int write,
78838 void __user *buffer, size_t *lenp, loff_t *ppos);
78839 #endif
78840
78841 -#ifdef CONFIG_PRINTK
78842 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78843 void __user *buffer, size_t *lenp, loff_t *ppos);
78844 -#endif
78845
78846 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
78847 void __user *buffer, size_t *lenp, loff_t *ppos);
78848 @@ -206,6 +203,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
78849
78850 #endif
78851
78852 +extern struct ctl_table grsecurity_table[];
78853 +
78854 static struct ctl_table kern_table[];
78855 static struct ctl_table vm_table[];
78856 static struct ctl_table fs_table[];
78857 @@ -220,6 +219,20 @@ extern struct ctl_table epoll_table[];
78858 int sysctl_legacy_va_layout;
78859 #endif
78860
78861 +#ifdef CONFIG_PAX_SOFTMODE
78862 +static ctl_table pax_table[] = {
78863 + {
78864 + .procname = "softmode",
78865 + .data = &pax_softmode,
78866 + .maxlen = sizeof(unsigned int),
78867 + .mode = 0600,
78868 + .proc_handler = &proc_dointvec,
78869 + },
78870 +
78871 + { }
78872 +};
78873 +#endif
78874 +
78875 /* The default sysctl tables: */
78876
78877 static struct ctl_table sysctl_base_table[] = {
78878 @@ -268,6 +281,22 @@ static int max_extfrag_threshold = 1000;
78879 #endif
78880
78881 static struct ctl_table kern_table[] = {
78882 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
78883 + {
78884 + .procname = "grsecurity",
78885 + .mode = 0500,
78886 + .child = grsecurity_table,
78887 + },
78888 +#endif
78889 +
78890 +#ifdef CONFIG_PAX_SOFTMODE
78891 + {
78892 + .procname = "pax",
78893 + .mode = 0500,
78894 + .child = pax_table,
78895 + },
78896 +#endif
78897 +
78898 {
78899 .procname = "sched_child_runs_first",
78900 .data = &sysctl_sched_child_runs_first,
78901 @@ -593,7 +622,7 @@ static struct ctl_table kern_table[] = {
78902 .data = &modprobe_path,
78903 .maxlen = KMOD_PATH_LEN,
78904 .mode = 0644,
78905 - .proc_handler = proc_dostring,
78906 + .proc_handler = proc_dostring_modpriv,
78907 },
78908 {
78909 .procname = "modules_disabled",
78910 @@ -760,16 +789,20 @@ static struct ctl_table kern_table[] = {
78911 .extra1 = &zero,
78912 .extra2 = &one,
78913 },
78914 +#endif
78915 {
78916 .procname = "kptr_restrict",
78917 .data = &kptr_restrict,
78918 .maxlen = sizeof(int),
78919 .mode = 0644,
78920 .proc_handler = proc_dointvec_minmax_sysadmin,
78921 +#ifdef CONFIG_GRKERNSEC_HIDESYM
78922 + .extra1 = &two,
78923 +#else
78924 .extra1 = &zero,
78925 +#endif
78926 .extra2 = &two,
78927 },
78928 -#endif
78929 {
78930 .procname = "ngroups_max",
78931 .data = &ngroups_max,
78932 @@ -1266,6 +1299,13 @@ static struct ctl_table vm_table[] = {
78933 .proc_handler = proc_dointvec_minmax,
78934 .extra1 = &zero,
78935 },
78936 + {
78937 + .procname = "heap_stack_gap",
78938 + .data = &sysctl_heap_stack_gap,
78939 + .maxlen = sizeof(sysctl_heap_stack_gap),
78940 + .mode = 0644,
78941 + .proc_handler = proc_doulongvec_minmax,
78942 + },
78943 #else
78944 {
78945 .procname = "nr_trim_pages",
78946 @@ -1716,6 +1756,16 @@ int proc_dostring(struct ctl_table *table, int write,
78947 buffer, lenp, ppos);
78948 }
78949
78950 +int proc_dostring_modpriv(struct ctl_table *table, int write,
78951 + void __user *buffer, size_t *lenp, loff_t *ppos)
78952 +{
78953 + if (write && !capable(CAP_SYS_MODULE))
78954 + return -EPERM;
78955 +
78956 + return _proc_do_string(table->data, table->maxlen, write,
78957 + buffer, lenp, ppos);
78958 +}
78959 +
78960 static size_t proc_skip_spaces(char **buf)
78961 {
78962 size_t ret;
78963 @@ -1821,6 +1871,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
78964 len = strlen(tmp);
78965 if (len > *size)
78966 len = *size;
78967 + if (len > sizeof(tmp))
78968 + len = sizeof(tmp);
78969 if (copy_to_user(*buf, tmp, len))
78970 return -EFAULT;
78971 *size -= len;
78972 @@ -1985,7 +2037,7 @@ int proc_dointvec(struct ctl_table *table, int write,
78973 static int proc_taint(struct ctl_table *table, int write,
78974 void __user *buffer, size_t *lenp, loff_t *ppos)
78975 {
78976 - struct ctl_table t;
78977 + ctl_table_no_const t;
78978 unsigned long tmptaint = get_taint();
78979 int err;
78980
78981 @@ -2013,7 +2065,6 @@ static int proc_taint(struct ctl_table *table, int write,
78982 return err;
78983 }
78984
78985 -#ifdef CONFIG_PRINTK
78986 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78987 void __user *buffer, size_t *lenp, loff_t *ppos)
78988 {
78989 @@ -2022,7 +2073,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78990
78991 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
78992 }
78993 -#endif
78994
78995 struct do_proc_dointvec_minmax_conv_param {
78996 int *min;
78997 @@ -2169,8 +2219,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
78998 *i = val;
78999 } else {
79000 val = convdiv * (*i) / convmul;
79001 - if (!first)
79002 + if (!first) {
79003 err = proc_put_char(&buffer, &left, '\t');
79004 + if (err)
79005 + break;
79006 + }
79007 err = proc_put_long(&buffer, &left, val, false);
79008 if (err)
79009 break;
79010 @@ -2562,6 +2615,12 @@ int proc_dostring(struct ctl_table *table, int write,
79011 return -ENOSYS;
79012 }
79013
79014 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79015 + void __user *buffer, size_t *lenp, loff_t *ppos)
79016 +{
79017 + return -ENOSYS;
79018 +}
79019 +
79020 int proc_dointvec(struct ctl_table *table, int write,
79021 void __user *buffer, size_t *lenp, loff_t *ppos)
79022 {
79023 @@ -2618,5 +2677,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79024 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79025 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79026 EXPORT_SYMBOL(proc_dostring);
79027 +EXPORT_SYMBOL(proc_dostring_modpriv);
79028 EXPORT_SYMBOL(proc_doulongvec_minmax);
79029 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79030 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
79031 index 0ddf3a0..a199f50 100644
79032 --- a/kernel/sysctl_binary.c
79033 +++ b/kernel/sysctl_binary.c
79034 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
79035 int i;
79036
79037 set_fs(KERNEL_DS);
79038 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79039 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79040 set_fs(old_fs);
79041 if (result < 0)
79042 goto out_kfree;
79043 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
79044 }
79045
79046 set_fs(KERNEL_DS);
79047 - result = vfs_write(file, buffer, str - buffer, &pos);
79048 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79049 set_fs(old_fs);
79050 if (result < 0)
79051 goto out_kfree;
79052 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
79053 int i;
79054
79055 set_fs(KERNEL_DS);
79056 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79057 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79058 set_fs(old_fs);
79059 if (result < 0)
79060 goto out_kfree;
79061 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
79062 }
79063
79064 set_fs(KERNEL_DS);
79065 - result = vfs_write(file, buffer, str - buffer, &pos);
79066 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79067 set_fs(old_fs);
79068 if (result < 0)
79069 goto out_kfree;
79070 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
79071 int i;
79072
79073 set_fs(KERNEL_DS);
79074 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79075 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79076 set_fs(old_fs);
79077 if (result < 0)
79078 goto out;
79079 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79080 __le16 dnaddr;
79081
79082 set_fs(KERNEL_DS);
79083 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79084 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79085 set_fs(old_fs);
79086 if (result < 0)
79087 goto out;
79088 @@ -1234,7 +1234,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79089 le16_to_cpu(dnaddr) & 0x3ff);
79090
79091 set_fs(KERNEL_DS);
79092 - result = vfs_write(file, buf, len, &pos);
79093 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
79094 set_fs(old_fs);
79095 if (result < 0)
79096 goto out;
79097 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79098 index 145bb4d..b2aa969 100644
79099 --- a/kernel/taskstats.c
79100 +++ b/kernel/taskstats.c
79101 @@ -28,9 +28,12 @@
79102 #include <linux/fs.h>
79103 #include <linux/file.h>
79104 #include <linux/pid_namespace.h>
79105 +#include <linux/grsecurity.h>
79106 #include <net/genetlink.h>
79107 #include <linux/atomic.h>
79108
79109 +extern int gr_is_taskstats_denied(int pid);
79110 +
79111 /*
79112 * Maximum length of a cpumask that can be specified in
79113 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79114 @@ -570,6 +573,9 @@ err:
79115
79116 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79117 {
79118 + if (gr_is_taskstats_denied(current->pid))
79119 + return -EACCES;
79120 +
79121 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79122 return cmd_attr_register_cpumask(info);
79123 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79124 diff --git a/kernel/time.c b/kernel/time.c
79125 index d226c6a..2f0d217 100644
79126 --- a/kernel/time.c
79127 +++ b/kernel/time.c
79128 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79129 return error;
79130
79131 if (tz) {
79132 + /* we log in do_settimeofday called below, so don't log twice
79133 + */
79134 + if (!tv)
79135 + gr_log_timechange();
79136 +
79137 sys_tz = *tz;
79138 update_vsyscall_tz();
79139 if (firsttime) {
79140 @@ -493,7 +498,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79141 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79142 * value to a scaled second value.
79143 */
79144 -unsigned long
79145 +unsigned long __intentional_overflow(-1)
79146 timespec_to_jiffies(const struct timespec *value)
79147 {
79148 unsigned long sec = value->tv_sec;
79149 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79150 index f11d83b..d016d91 100644
79151 --- a/kernel/time/alarmtimer.c
79152 +++ b/kernel/time/alarmtimer.c
79153 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79154 struct platform_device *pdev;
79155 int error = 0;
79156 int i;
79157 - struct k_clock alarm_clock = {
79158 + static struct k_clock alarm_clock = {
79159 .clock_getres = alarm_clock_getres,
79160 .clock_get = alarm_clock_get,
79161 .timer_create = alarm_timer_create,
79162 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79163 index a13987a..36cd791 100644
79164 --- a/kernel/time/tick-broadcast.c
79165 +++ b/kernel/time/tick-broadcast.c
79166 @@ -116,7 +116,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79167 * then clear the broadcast bit.
79168 */
79169 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79170 - int cpu = smp_processor_id();
79171 + cpu = smp_processor_id();
79172
79173 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
79174 tick_broadcast_clear_oneshot(cpu);
79175 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79176 index cbc6acb..3a77191 100644
79177 --- a/kernel/time/timekeeping.c
79178 +++ b/kernel/time/timekeeping.c
79179 @@ -15,6 +15,7 @@
79180 #include <linux/init.h>
79181 #include <linux/mm.h>
79182 #include <linux/sched.h>
79183 +#include <linux/grsecurity.h>
79184 #include <linux/syscore_ops.h>
79185 #include <linux/clocksource.h>
79186 #include <linux/jiffies.h>
79187 @@ -412,6 +413,8 @@ int do_settimeofday(const struct timespec *tv)
79188 if (!timespec_valid_strict(tv))
79189 return -EINVAL;
79190
79191 + gr_log_timechange();
79192 +
79193 write_seqlock_irqsave(&tk->lock, flags);
79194
79195 timekeeping_forward_now(tk);
79196 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79197 index af5a7e9..715611a 100644
79198 --- a/kernel/time/timer_list.c
79199 +++ b/kernel/time/timer_list.c
79200 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79201
79202 static void print_name_offset(struct seq_file *m, void *sym)
79203 {
79204 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79205 + SEQ_printf(m, "<%p>", NULL);
79206 +#else
79207 char symname[KSYM_NAME_LEN];
79208
79209 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79210 SEQ_printf(m, "<%pK>", sym);
79211 else
79212 SEQ_printf(m, "%s", symname);
79213 +#endif
79214 }
79215
79216 static void
79217 @@ -112,7 +116,11 @@ next_one:
79218 static void
79219 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79220 {
79221 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79222 + SEQ_printf(m, " .base: %p\n", NULL);
79223 +#else
79224 SEQ_printf(m, " .base: %pK\n", base);
79225 +#endif
79226 SEQ_printf(m, " .index: %d\n",
79227 base->index);
79228 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79229 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
79230 {
79231 struct proc_dir_entry *pe;
79232
79233 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79234 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79235 +#else
79236 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79237 +#endif
79238 if (!pe)
79239 return -ENOMEM;
79240 return 0;
79241 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79242 index 0b537f2..40d6c20 100644
79243 --- a/kernel/time/timer_stats.c
79244 +++ b/kernel/time/timer_stats.c
79245 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79246 static unsigned long nr_entries;
79247 static struct entry entries[MAX_ENTRIES];
79248
79249 -static atomic_t overflow_count;
79250 +static atomic_unchecked_t overflow_count;
79251
79252 /*
79253 * The entries are in a hash-table, for fast lookup:
79254 @@ -140,7 +140,7 @@ static void reset_entries(void)
79255 nr_entries = 0;
79256 memset(entries, 0, sizeof(entries));
79257 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79258 - atomic_set(&overflow_count, 0);
79259 + atomic_set_unchecked(&overflow_count, 0);
79260 }
79261
79262 static struct entry *alloc_entry(void)
79263 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79264 if (likely(entry))
79265 entry->count++;
79266 else
79267 - atomic_inc(&overflow_count);
79268 + atomic_inc_unchecked(&overflow_count);
79269
79270 out_unlock:
79271 raw_spin_unlock_irqrestore(lock, flags);
79272 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79273
79274 static void print_name_offset(struct seq_file *m, unsigned long addr)
79275 {
79276 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79277 + seq_printf(m, "<%p>", NULL);
79278 +#else
79279 char symname[KSYM_NAME_LEN];
79280
79281 if (lookup_symbol_name(addr, symname) < 0)
79282 - seq_printf(m, "<%p>", (void *)addr);
79283 + seq_printf(m, "<%pK>", (void *)addr);
79284 else
79285 seq_printf(m, "%s", symname);
79286 +#endif
79287 }
79288
79289 static int tstats_show(struct seq_file *m, void *v)
79290 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79291
79292 seq_puts(m, "Timer Stats Version: v0.2\n");
79293 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79294 - if (atomic_read(&overflow_count))
79295 + if (atomic_read_unchecked(&overflow_count))
79296 seq_printf(m, "Overflow: %d entries\n",
79297 - atomic_read(&overflow_count));
79298 + atomic_read_unchecked(&overflow_count));
79299
79300 for (i = 0; i < nr_entries; i++) {
79301 entry = entries + i;
79302 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79303 {
79304 struct proc_dir_entry *pe;
79305
79306 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79307 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79308 +#else
79309 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79310 +#endif
79311 if (!pe)
79312 return -ENOMEM;
79313 return 0;
79314 diff --git a/kernel/timer.c b/kernel/timer.c
79315 index 367d008..5dee98f 100644
79316 --- a/kernel/timer.c
79317 +++ b/kernel/timer.c
79318 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
79319 /*
79320 * This function runs timers and the timer-tq in bottom half context.
79321 */
79322 -static void run_timer_softirq(struct softirq_action *h)
79323 +static void run_timer_softirq(void)
79324 {
79325 struct tvec_base *base = __this_cpu_read(tvec_bases);
79326
79327 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
79328 *
79329 * In all cases the return value is guaranteed to be non-negative.
79330 */
79331 -signed long __sched schedule_timeout(signed long timeout)
79332 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79333 {
79334 struct timer_list timer;
79335 unsigned long expire;
79336 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79337 return NOTIFY_OK;
79338 }
79339
79340 -static struct notifier_block __cpuinitdata timers_nb = {
79341 +static struct notifier_block timers_nb = {
79342 .notifier_call = timer_cpu_notify,
79343 };
79344
79345 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79346 index c0bd030..62a1927 100644
79347 --- a/kernel/trace/blktrace.c
79348 +++ b/kernel/trace/blktrace.c
79349 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79350 struct blk_trace *bt = filp->private_data;
79351 char buf[16];
79352
79353 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79354 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79355
79356 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79357 }
79358 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79359 return 1;
79360
79361 bt = buf->chan->private_data;
79362 - atomic_inc(&bt->dropped);
79363 + atomic_inc_unchecked(&bt->dropped);
79364 return 0;
79365 }
79366
79367 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79368
79369 bt->dir = dir;
79370 bt->dev = dev;
79371 - atomic_set(&bt->dropped, 0);
79372 + atomic_set_unchecked(&bt->dropped, 0);
79373
79374 ret = -EIO;
79375 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79376 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79377 index 64bc5d8..1ed69e2 100644
79378 --- a/kernel/trace/ftrace.c
79379 +++ b/kernel/trace/ftrace.c
79380 @@ -668,7 +668,6 @@ int ftrace_profile_pages_init(struct ftrace_profile_stat *stat)
79381 free_page(tmp);
79382 }
79383
79384 - free_page((unsigned long)stat->pages);
79385 stat->pages = NULL;
79386 stat->start = NULL;
79387
79388 @@ -1874,12 +1873,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79389 if (unlikely(ftrace_disabled))
79390 return 0;
79391
79392 + ret = ftrace_arch_code_modify_prepare();
79393 + FTRACE_WARN_ON(ret);
79394 + if (ret)
79395 + return 0;
79396 +
79397 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79398 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79399 if (ret) {
79400 ftrace_bug(ret, ip);
79401 - return 0;
79402 }
79403 - return 1;
79404 + return ret ? 0 : 1;
79405 }
79406
79407 /*
79408 @@ -2965,7 +2969,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79409
79410 int
79411 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79412 - void *data)
79413 + void *data)
79414 {
79415 struct ftrace_func_probe *entry;
79416 struct ftrace_page *pg;
79417 @@ -3832,8 +3836,10 @@ static int ftrace_process_locs(struct module *mod,
79418 if (!count)
79419 return 0;
79420
79421 + pax_open_kernel();
79422 sort(start, count, sizeof(*start),
79423 ftrace_cmp_ips, ftrace_swap_ips);
79424 + pax_close_kernel();
79425
79426 start_pg = ftrace_allocate_pages(count);
79427 if (!start_pg)
79428 @@ -4555,8 +4561,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79429 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79430
79431 static int ftrace_graph_active;
79432 -static struct notifier_block ftrace_suspend_notifier;
79433 -
79434 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79435 {
79436 return 0;
79437 @@ -4700,6 +4704,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79438 return NOTIFY_DONE;
79439 }
79440
79441 +static struct notifier_block ftrace_suspend_notifier = {
79442 + .notifier_call = ftrace_suspend_notifier_call
79443 +};
79444 +
79445 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79446 trace_func_graph_ent_t entryfunc)
79447 {
79448 @@ -4713,7 +4721,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79449 goto out;
79450 }
79451
79452 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79453 register_pm_notifier(&ftrace_suspend_notifier);
79454
79455 ftrace_graph_active++;
79456 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79457 index ce8514f..8233573 100644
79458 --- a/kernel/trace/ring_buffer.c
79459 +++ b/kernel/trace/ring_buffer.c
79460 @@ -346,9 +346,9 @@ struct buffer_data_page {
79461 */
79462 struct buffer_page {
79463 struct list_head list; /* list of buffer pages */
79464 - local_t write; /* index for next write */
79465 + local_unchecked_t write; /* index for next write */
79466 unsigned read; /* index for next read */
79467 - local_t entries; /* entries on this page */
79468 + local_unchecked_t entries; /* entries on this page */
79469 unsigned long real_end; /* real end of data */
79470 struct buffer_data_page *page; /* Actual data page */
79471 };
79472 @@ -461,8 +461,8 @@ struct ring_buffer_per_cpu {
79473 unsigned long last_overrun;
79474 local_t entries_bytes;
79475 local_t entries;
79476 - local_t overrun;
79477 - local_t commit_overrun;
79478 + local_unchecked_t overrun;
79479 + local_unchecked_t commit_overrun;
79480 local_t dropped_events;
79481 local_t committing;
79482 local_t commits;
79483 @@ -861,8 +861,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79484 *
79485 * We add a counter to the write field to denote this.
79486 */
79487 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79488 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79489 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79490 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79491
79492 /*
79493 * Just make sure we have seen our old_write and synchronize
79494 @@ -890,8 +890,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79495 * cmpxchg to only update if an interrupt did not already
79496 * do it for us. If the cmpxchg fails, we don't care.
79497 */
79498 - (void)local_cmpxchg(&next_page->write, old_write, val);
79499 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79500 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79501 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79502
79503 /*
79504 * No need to worry about races with clearing out the commit.
79505 @@ -1250,12 +1250,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79506
79507 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79508 {
79509 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79510 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79511 }
79512
79513 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79514 {
79515 - return local_read(&bpage->write) & RB_WRITE_MASK;
79516 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79517 }
79518
79519 static int
79520 @@ -1350,7 +1350,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79521 * bytes consumed in ring buffer from here.
79522 * Increment overrun to account for the lost events.
79523 */
79524 - local_add(page_entries, &cpu_buffer->overrun);
79525 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79526 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79527 }
79528
79529 @@ -1906,7 +1906,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79530 * it is our responsibility to update
79531 * the counters.
79532 */
79533 - local_add(entries, &cpu_buffer->overrun);
79534 + local_add_unchecked(entries, &cpu_buffer->overrun);
79535 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79536
79537 /*
79538 @@ -2056,7 +2056,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79539 if (tail == BUF_PAGE_SIZE)
79540 tail_page->real_end = 0;
79541
79542 - local_sub(length, &tail_page->write);
79543 + local_sub_unchecked(length, &tail_page->write);
79544 return;
79545 }
79546
79547 @@ -2091,7 +2091,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79548 rb_event_set_padding(event);
79549
79550 /* Set the write back to the previous setting */
79551 - local_sub(length, &tail_page->write);
79552 + local_sub_unchecked(length, &tail_page->write);
79553 return;
79554 }
79555
79556 @@ -2103,7 +2103,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79557
79558 /* Set write to end of buffer */
79559 length = (tail + length) - BUF_PAGE_SIZE;
79560 - local_sub(length, &tail_page->write);
79561 + local_sub_unchecked(length, &tail_page->write);
79562 }
79563
79564 /*
79565 @@ -2129,7 +2129,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79566 * about it.
79567 */
79568 if (unlikely(next_page == commit_page)) {
79569 - local_inc(&cpu_buffer->commit_overrun);
79570 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79571 goto out_reset;
79572 }
79573
79574 @@ -2185,7 +2185,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79575 cpu_buffer->tail_page) &&
79576 (cpu_buffer->commit_page ==
79577 cpu_buffer->reader_page))) {
79578 - local_inc(&cpu_buffer->commit_overrun);
79579 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79580 goto out_reset;
79581 }
79582 }
79583 @@ -2233,7 +2233,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79584 length += RB_LEN_TIME_EXTEND;
79585
79586 tail_page = cpu_buffer->tail_page;
79587 - write = local_add_return(length, &tail_page->write);
79588 + write = local_add_return_unchecked(length, &tail_page->write);
79589
79590 /* set write to only the index of the write */
79591 write &= RB_WRITE_MASK;
79592 @@ -2250,7 +2250,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79593 kmemcheck_annotate_bitfield(event, bitfield);
79594 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79595
79596 - local_inc(&tail_page->entries);
79597 + local_inc_unchecked(&tail_page->entries);
79598
79599 /*
79600 * If this is the first commit on the page, then update
79601 @@ -2283,7 +2283,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79602
79603 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79604 unsigned long write_mask =
79605 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79606 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79607 unsigned long event_length = rb_event_length(event);
79608 /*
79609 * This is on the tail page. It is possible that
79610 @@ -2293,7 +2293,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79611 */
79612 old_index += write_mask;
79613 new_index += write_mask;
79614 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79615 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79616 if (index == old_index) {
79617 /* update counters */
79618 local_sub(event_length, &cpu_buffer->entries_bytes);
79619 @@ -2632,7 +2632,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79620
79621 /* Do the likely case first */
79622 if (likely(bpage->page == (void *)addr)) {
79623 - local_dec(&bpage->entries);
79624 + local_dec_unchecked(&bpage->entries);
79625 return;
79626 }
79627
79628 @@ -2644,7 +2644,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79629 start = bpage;
79630 do {
79631 if (bpage->page == (void *)addr) {
79632 - local_dec(&bpage->entries);
79633 + local_dec_unchecked(&bpage->entries);
79634 return;
79635 }
79636 rb_inc_page(cpu_buffer, &bpage);
79637 @@ -2926,7 +2926,7 @@ static inline unsigned long
79638 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79639 {
79640 return local_read(&cpu_buffer->entries) -
79641 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79642 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79643 }
79644
79645 /**
79646 @@ -3015,7 +3015,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79647 return 0;
79648
79649 cpu_buffer = buffer->buffers[cpu];
79650 - ret = local_read(&cpu_buffer->overrun);
79651 + ret = local_read_unchecked(&cpu_buffer->overrun);
79652
79653 return ret;
79654 }
79655 @@ -3038,7 +3038,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79656 return 0;
79657
79658 cpu_buffer = buffer->buffers[cpu];
79659 - ret = local_read(&cpu_buffer->commit_overrun);
79660 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79661
79662 return ret;
79663 }
79664 @@ -3105,7 +3105,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79665 /* if you care about this being correct, lock the buffer */
79666 for_each_buffer_cpu(buffer, cpu) {
79667 cpu_buffer = buffer->buffers[cpu];
79668 - overruns += local_read(&cpu_buffer->overrun);
79669 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79670 }
79671
79672 return overruns;
79673 @@ -3281,8 +3281,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79674 /*
79675 * Reset the reader page to size zero.
79676 */
79677 - local_set(&cpu_buffer->reader_page->write, 0);
79678 - local_set(&cpu_buffer->reader_page->entries, 0);
79679 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79680 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79681 local_set(&cpu_buffer->reader_page->page->commit, 0);
79682 cpu_buffer->reader_page->real_end = 0;
79683
79684 @@ -3316,7 +3316,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79685 * want to compare with the last_overrun.
79686 */
79687 smp_mb();
79688 - overwrite = local_read(&(cpu_buffer->overrun));
79689 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79690
79691 /*
79692 * Here's the tricky part.
79693 @@ -3886,8 +3886,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79694
79695 cpu_buffer->head_page
79696 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79697 - local_set(&cpu_buffer->head_page->write, 0);
79698 - local_set(&cpu_buffer->head_page->entries, 0);
79699 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79700 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79701 local_set(&cpu_buffer->head_page->page->commit, 0);
79702
79703 cpu_buffer->head_page->read = 0;
79704 @@ -3897,14 +3897,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79705
79706 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79707 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79708 - local_set(&cpu_buffer->reader_page->write, 0);
79709 - local_set(&cpu_buffer->reader_page->entries, 0);
79710 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79711 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79712 local_set(&cpu_buffer->reader_page->page->commit, 0);
79713 cpu_buffer->reader_page->read = 0;
79714
79715 local_set(&cpu_buffer->entries_bytes, 0);
79716 - local_set(&cpu_buffer->overrun, 0);
79717 - local_set(&cpu_buffer->commit_overrun, 0);
79718 + local_set_unchecked(&cpu_buffer->overrun, 0);
79719 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79720 local_set(&cpu_buffer->dropped_events, 0);
79721 local_set(&cpu_buffer->entries, 0);
79722 local_set(&cpu_buffer->committing, 0);
79723 @@ -4308,8 +4308,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79724 rb_init_page(bpage);
79725 bpage = reader->page;
79726 reader->page = *data_page;
79727 - local_set(&reader->write, 0);
79728 - local_set(&reader->entries, 0);
79729 + local_set_unchecked(&reader->write, 0);
79730 + local_set_unchecked(&reader->entries, 0);
79731 reader->read = 0;
79732 *data_page = bpage;
79733
79734 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79735 index fe1d581..43a0f38 100644
79736 --- a/kernel/trace/trace.c
79737 +++ b/kernel/trace/trace.c
79738 @@ -4494,10 +4494,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79739 };
79740 #endif
79741
79742 -static struct dentry *d_tracer;
79743 -
79744 struct dentry *tracing_init_dentry(void)
79745 {
79746 + static struct dentry *d_tracer;
79747 static int once;
79748
79749 if (d_tracer)
79750 @@ -4517,10 +4516,9 @@ struct dentry *tracing_init_dentry(void)
79751 return d_tracer;
79752 }
79753
79754 -static struct dentry *d_percpu;
79755 -
79756 struct dentry *tracing_dentry_percpu(void)
79757 {
79758 + static struct dentry *d_percpu;
79759 static int once;
79760 struct dentry *d_tracer;
79761
79762 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
79763 index 880073d..42db7c3 100644
79764 --- a/kernel/trace/trace_events.c
79765 +++ b/kernel/trace/trace_events.c
79766 @@ -1330,10 +1330,6 @@ static LIST_HEAD(ftrace_module_file_list);
79767 struct ftrace_module_file_ops {
79768 struct list_head list;
79769 struct module *mod;
79770 - struct file_operations id;
79771 - struct file_operations enable;
79772 - struct file_operations format;
79773 - struct file_operations filter;
79774 };
79775
79776 static struct ftrace_module_file_ops *
79777 @@ -1354,17 +1350,12 @@ trace_create_file_ops(struct module *mod)
79778
79779 file_ops->mod = mod;
79780
79781 - file_ops->id = ftrace_event_id_fops;
79782 - file_ops->id.owner = mod;
79783 -
79784 - file_ops->enable = ftrace_enable_fops;
79785 - file_ops->enable.owner = mod;
79786 -
79787 - file_ops->filter = ftrace_event_filter_fops;
79788 - file_ops->filter.owner = mod;
79789 -
79790 - file_ops->format = ftrace_event_format_fops;
79791 - file_ops->format.owner = mod;
79792 + pax_open_kernel();
79793 + mod->trace_id.owner = mod;
79794 + mod->trace_enable.owner = mod;
79795 + mod->trace_filter.owner = mod;
79796 + mod->trace_format.owner = mod;
79797 + pax_close_kernel();
79798
79799 list_add(&file_ops->list, &ftrace_module_file_list);
79800
79801 @@ -1388,8 +1379,8 @@ static void trace_module_add_events(struct module *mod)
79802
79803 for_each_event(call, start, end) {
79804 __trace_add_event_call(*call, mod,
79805 - &file_ops->id, &file_ops->enable,
79806 - &file_ops->filter, &file_ops->format);
79807 + &mod->trace_id, &mod->trace_enable,
79808 + &mod->trace_filter, &mod->trace_format);
79809 }
79810 }
79811
79812 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
79813 index fd3c8aa..5f324a6 100644
79814 --- a/kernel/trace/trace_mmiotrace.c
79815 +++ b/kernel/trace/trace_mmiotrace.c
79816 @@ -24,7 +24,7 @@ struct header_iter {
79817 static struct trace_array *mmio_trace_array;
79818 static bool overrun_detected;
79819 static unsigned long prev_overruns;
79820 -static atomic_t dropped_count;
79821 +static atomic_unchecked_t dropped_count;
79822
79823 static void mmio_reset_data(struct trace_array *tr)
79824 {
79825 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
79826
79827 static unsigned long count_overruns(struct trace_iterator *iter)
79828 {
79829 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
79830 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
79831 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
79832
79833 if (over > prev_overruns)
79834 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
79835 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
79836 sizeof(*entry), 0, pc);
79837 if (!event) {
79838 - atomic_inc(&dropped_count);
79839 + atomic_inc_unchecked(&dropped_count);
79840 return;
79841 }
79842 entry = ring_buffer_event_data(event);
79843 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
79844 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
79845 sizeof(*entry), 0, pc);
79846 if (!event) {
79847 - atomic_inc(&dropped_count);
79848 + atomic_inc_unchecked(&dropped_count);
79849 return;
79850 }
79851 entry = ring_buffer_event_data(event);
79852 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
79853 index 194d796..76edb8f 100644
79854 --- a/kernel/trace/trace_output.c
79855 +++ b/kernel/trace/trace_output.c
79856 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
79857
79858 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
79859 if (!IS_ERR(p)) {
79860 - p = mangle_path(s->buffer + s->len, p, "\n");
79861 + p = mangle_path(s->buffer + s->len, p, "\n\\");
79862 if (p) {
79863 s->len = p - s->buffer;
79864 return 1;
79865 @@ -852,14 +852,16 @@ int register_ftrace_event(struct trace_event *event)
79866 goto out;
79867 }
79868
79869 + pax_open_kernel();
79870 if (event->funcs->trace == NULL)
79871 - event->funcs->trace = trace_nop_print;
79872 + *(void **)&event->funcs->trace = trace_nop_print;
79873 if (event->funcs->raw == NULL)
79874 - event->funcs->raw = trace_nop_print;
79875 + *(void **)&event->funcs->raw = trace_nop_print;
79876 if (event->funcs->hex == NULL)
79877 - event->funcs->hex = trace_nop_print;
79878 + *(void **)&event->funcs->hex = trace_nop_print;
79879 if (event->funcs->binary == NULL)
79880 - event->funcs->binary = trace_nop_print;
79881 + *(void **)&event->funcs->binary = trace_nop_print;
79882 + pax_close_kernel();
79883
79884 key = event->type & (EVENT_HASHSIZE - 1);
79885
79886 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
79887 index 42ca822..cdcacc6 100644
79888 --- a/kernel/trace/trace_stack.c
79889 +++ b/kernel/trace/trace_stack.c
79890 @@ -52,7 +52,7 @@ static inline void check_stack(void)
79891 return;
79892
79893 /* we do not handle interrupt stacks yet */
79894 - if (!object_is_on_stack(&this_size))
79895 + if (!object_starts_on_stack(&this_size))
79896 return;
79897
79898 local_irq_save(flags);
79899 diff --git a/kernel/user.c b/kernel/user.c
79900 index 7f6ff2b..1ac8f18 100644
79901 --- a/kernel/user.c
79902 +++ b/kernel/user.c
79903 @@ -47,9 +47,7 @@ struct user_namespace init_user_ns = {
79904 .count = 4294967295U,
79905 },
79906 },
79907 - .kref = {
79908 - .refcount = ATOMIC_INIT(3),
79909 - },
79910 + .count = ATOMIC_INIT(3),
79911 .owner = GLOBAL_ROOT_UID,
79912 .group = GLOBAL_ROOT_GID,
79913 .proc_inum = PROC_USER_INIT_INO,
79914 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
79915 index f45e128..a5a5fb6 100644
79916 --- a/kernel/user_namespace.c
79917 +++ b/kernel/user_namespace.c
79918 @@ -88,7 +88,7 @@ int create_user_ns(struct cred *new)
79919 return ret;
79920 }
79921
79922 - kref_init(&ns->kref);
79923 + atomic_set(&ns->count, 1);
79924 /* Leave the new->user_ns reference with the new user namespace. */
79925 ns->parent = parent_ns;
79926 ns->owner = owner;
79927 @@ -116,15 +116,16 @@ int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
79928 return create_user_ns(cred);
79929 }
79930
79931 -void free_user_ns(struct kref *kref)
79932 +void free_user_ns(struct user_namespace *ns)
79933 {
79934 - struct user_namespace *parent, *ns =
79935 - container_of(kref, struct user_namespace, kref);
79936 + struct user_namespace *parent;
79937
79938 - parent = ns->parent;
79939 - proc_free_inum(ns->proc_inum);
79940 - kmem_cache_free(user_ns_cachep, ns);
79941 - put_user_ns(parent);
79942 + do {
79943 + parent = ns->parent;
79944 + proc_free_inum(ns->proc_inum);
79945 + kmem_cache_free(user_ns_cachep, ns);
79946 + ns = parent;
79947 + } while (atomic_dec_and_test(&parent->count));
79948 }
79949 EXPORT_SYMBOL(free_user_ns);
79950
79951 @@ -815,7 +816,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
79952 if (atomic_read(&current->mm->mm_users) > 1)
79953 return -EINVAL;
79954
79955 - if (current->fs->users != 1)
79956 + if (atomic_read(&current->fs->users) != 1)
79957 return -EINVAL;
79958
79959 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
79960 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
79961 index 63da38c..639904e 100644
79962 --- a/kernel/utsname_sysctl.c
79963 +++ b/kernel/utsname_sysctl.c
79964 @@ -46,7 +46,7 @@ static void put_uts(ctl_table *table, int write, void *which)
79965 static int proc_do_uts_string(ctl_table *table, int write,
79966 void __user *buffer, size_t *lenp, loff_t *ppos)
79967 {
79968 - struct ctl_table uts_table;
79969 + ctl_table_no_const uts_table;
79970 int r;
79971 memcpy(&uts_table, table, sizeof(uts_table));
79972 uts_table.data = get_uts(table, write);
79973 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
79974 index 75a2ab3..5961da7 100644
79975 --- a/kernel/watchdog.c
79976 +++ b/kernel/watchdog.c
79977 @@ -527,7 +527,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
79978 }
79979 #endif /* CONFIG_SYSCTL */
79980
79981 -static struct smp_hotplug_thread watchdog_threads = {
79982 +static struct smp_hotplug_thread watchdog_threads __read_only = {
79983 .store = &softlockup_watchdog,
79984 .thread_should_run = watchdog_should_run,
79985 .thread_fn = watchdog,
79986 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
79987 index 67604e5..fe94fb1 100644
79988 --- a/lib/Kconfig.debug
79989 +++ b/lib/Kconfig.debug
79990 @@ -550,7 +550,7 @@ config DEBUG_MUTEXES
79991
79992 config DEBUG_LOCK_ALLOC
79993 bool "Lock debugging: detect incorrect freeing of live locks"
79994 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
79995 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
79996 select DEBUG_SPINLOCK
79997 select DEBUG_MUTEXES
79998 select LOCKDEP
79999 @@ -564,7 +564,7 @@ config DEBUG_LOCK_ALLOC
80000
80001 config PROVE_LOCKING
80002 bool "Lock debugging: prove locking correctness"
80003 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80004 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80005 select LOCKDEP
80006 select DEBUG_SPINLOCK
80007 select DEBUG_MUTEXES
80008 @@ -670,7 +670,7 @@ config LOCKDEP
80009
80010 config LOCK_STAT
80011 bool "Lock usage statistics"
80012 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80013 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80014 select LOCKDEP
80015 select DEBUG_SPINLOCK
80016 select DEBUG_MUTEXES
80017 @@ -1278,6 +1278,7 @@ config LATENCYTOP
80018 depends on DEBUG_KERNEL
80019 depends on STACKTRACE_SUPPORT
80020 depends on PROC_FS
80021 + depends on !GRKERNSEC_HIDESYM
80022 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
80023 select KALLSYMS
80024 select KALLSYMS_ALL
80025 @@ -1306,7 +1307,7 @@ config INTERVAL_TREE_TEST
80026
80027 config PROVIDE_OHCI1394_DMA_INIT
80028 bool "Remote debugging over FireWire early on boot"
80029 - depends on PCI && X86
80030 + depends on PCI && X86 && !GRKERNSEC
80031 help
80032 If you want to debug problems which hang or crash the kernel early
80033 on boot and the crashing machine has a FireWire port, you can use
80034 @@ -1335,7 +1336,7 @@ config PROVIDE_OHCI1394_DMA_INIT
80035
80036 config FIREWIRE_OHCI_REMOTE_DMA
80037 bool "Remote debugging over FireWire with firewire-ohci"
80038 - depends on FIREWIRE_OHCI
80039 + depends on FIREWIRE_OHCI && !GRKERNSEC
80040 help
80041 This option lets you use the FireWire bus for remote debugging
80042 with help of the firewire-ohci driver. It enables unfiltered
80043 diff --git a/lib/Makefile b/lib/Makefile
80044 index 02ed6c0..bd243da 100644
80045 --- a/lib/Makefile
80046 +++ b/lib/Makefile
80047 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
80048
80049 obj-$(CONFIG_BTREE) += btree.o
80050 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
80051 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80052 +obj-y += list_debug.o
80053 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80054
80055 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80056 diff --git a/lib/bitmap.c b/lib/bitmap.c
80057 index 06f7e4f..f3cf2b0 100644
80058 --- a/lib/bitmap.c
80059 +++ b/lib/bitmap.c
80060 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80061 {
80062 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80063 u32 chunk;
80064 - const char __user __force *ubuf = (const char __user __force *)buf;
80065 + const char __user *ubuf = (const char __force_user *)buf;
80066
80067 bitmap_zero(maskp, nmaskbits);
80068
80069 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80070 {
80071 if (!access_ok(VERIFY_READ, ubuf, ulen))
80072 return -EFAULT;
80073 - return __bitmap_parse((const char __force *)ubuf,
80074 + return __bitmap_parse((const char __force_kernel *)ubuf,
80075 ulen, 1, maskp, nmaskbits);
80076
80077 }
80078 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80079 {
80080 unsigned a, b;
80081 int c, old_c, totaldigits;
80082 - const char __user __force *ubuf = (const char __user __force *)buf;
80083 + const char __user *ubuf = (const char __force_user *)buf;
80084 int exp_digit, in_range;
80085
80086 totaldigits = c = 0;
80087 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80088 {
80089 if (!access_ok(VERIFY_READ, ubuf, ulen))
80090 return -EFAULT;
80091 - return __bitmap_parselist((const char __force *)ubuf,
80092 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80093 ulen, 1, maskp, nmaskbits);
80094 }
80095 EXPORT_SYMBOL(bitmap_parselist_user);
80096 diff --git a/lib/bug.c b/lib/bug.c
80097 index d0cdf14..4d07bd2 100644
80098 --- a/lib/bug.c
80099 +++ b/lib/bug.c
80100 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80101 return BUG_TRAP_TYPE_NONE;
80102
80103 bug = find_bug(bugaddr);
80104 + if (!bug)
80105 + return BUG_TRAP_TYPE_NONE;
80106
80107 file = NULL;
80108 line = 0;
80109 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80110 index d11808c..dc2d6f8 100644
80111 --- a/lib/debugobjects.c
80112 +++ b/lib/debugobjects.c
80113 @@ -287,7 +287,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80114 if (limit > 4)
80115 return;
80116
80117 - is_on_stack = object_is_on_stack(addr);
80118 + is_on_stack = object_starts_on_stack(addr);
80119 if (is_on_stack == onstack)
80120 return;
80121
80122 diff --git a/lib/devres.c b/lib/devres.c
80123 index 80b9c76..9e32279 100644
80124 --- a/lib/devres.c
80125 +++ b/lib/devres.c
80126 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80127 void devm_iounmap(struct device *dev, void __iomem *addr)
80128 {
80129 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80130 - (void *)addr));
80131 + (void __force *)addr));
80132 iounmap(addr);
80133 }
80134 EXPORT_SYMBOL(devm_iounmap);
80135 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80136 {
80137 ioport_unmap(addr);
80138 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80139 - devm_ioport_map_match, (void *)addr));
80140 + devm_ioport_map_match, (void __force *)addr));
80141 }
80142 EXPORT_SYMBOL(devm_ioport_unmap);
80143
80144 diff --git a/lib/div64.c b/lib/div64.c
80145 index a163b6c..9618fa5 100644
80146 --- a/lib/div64.c
80147 +++ b/lib/div64.c
80148 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80149 EXPORT_SYMBOL(__div64_32);
80150
80151 #ifndef div_s64_rem
80152 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80153 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80154 {
80155 u64 quotient;
80156
80157 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80158 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80159 */
80160 #ifndef div64_u64
80161 -u64 div64_u64(u64 dividend, u64 divisor)
80162 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80163 {
80164 u32 high = divisor >> 32;
80165 u64 quot;
80166 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80167 index 5e396ac..58d5de1 100644
80168 --- a/lib/dma-debug.c
80169 +++ b/lib/dma-debug.c
80170 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80171
80172 void dma_debug_add_bus(struct bus_type *bus)
80173 {
80174 - struct notifier_block *nb;
80175 + notifier_block_no_const *nb;
80176
80177 if (global_disable)
80178 return;
80179 @@ -942,7 +942,7 @@ out:
80180
80181 static void check_for_stack(struct device *dev, void *addr)
80182 {
80183 - if (object_is_on_stack(addr))
80184 + if (object_starts_on_stack(addr))
80185 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80186 "stack [addr=%p]\n", addr);
80187 }
80188 diff --git a/lib/inflate.c b/lib/inflate.c
80189 index 013a761..c28f3fc 100644
80190 --- a/lib/inflate.c
80191 +++ b/lib/inflate.c
80192 @@ -269,7 +269,7 @@ static void free(void *where)
80193 malloc_ptr = free_mem_ptr;
80194 }
80195 #else
80196 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80197 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80198 #define free(a) kfree(a)
80199 #endif
80200
80201 diff --git a/lib/ioremap.c b/lib/ioremap.c
80202 index 0c9216c..863bd89 100644
80203 --- a/lib/ioremap.c
80204 +++ b/lib/ioremap.c
80205 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80206 unsigned long next;
80207
80208 phys_addr -= addr;
80209 - pmd = pmd_alloc(&init_mm, pud, addr);
80210 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80211 if (!pmd)
80212 return -ENOMEM;
80213 do {
80214 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80215 unsigned long next;
80216
80217 phys_addr -= addr;
80218 - pud = pud_alloc(&init_mm, pgd, addr);
80219 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80220 if (!pud)
80221 return -ENOMEM;
80222 do {
80223 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80224 index bd2bea9..6b3c95e 100644
80225 --- a/lib/is_single_threaded.c
80226 +++ b/lib/is_single_threaded.c
80227 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80228 struct task_struct *p, *t;
80229 bool ret;
80230
80231 + if (!mm)
80232 + return true;
80233 +
80234 if (atomic_read(&task->signal->live) != 1)
80235 return false;
80236
80237 diff --git a/lib/kobject.c b/lib/kobject.c
80238 index e07ee1f..998489d 100644
80239 --- a/lib/kobject.c
80240 +++ b/lib/kobject.c
80241 @@ -852,9 +852,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80242
80243
80244 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80245 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80246 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80247
80248 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80249 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80250 {
80251 enum kobj_ns_type type = ops->type;
80252 int error;
80253 diff --git a/lib/list_debug.c b/lib/list_debug.c
80254 index c24c2f7..06e070b 100644
80255 --- a/lib/list_debug.c
80256 +++ b/lib/list_debug.c
80257 @@ -11,7 +11,9 @@
80258 #include <linux/bug.h>
80259 #include <linux/kernel.h>
80260 #include <linux/rculist.h>
80261 +#include <linux/mm.h>
80262
80263 +#ifdef CONFIG_DEBUG_LIST
80264 /*
80265 * Insert a new entry between two known consecutive entries.
80266 *
80267 @@ -19,21 +21,32 @@
80268 * the prev/next entries already!
80269 */
80270
80271 -void __list_add(struct list_head *new,
80272 - struct list_head *prev,
80273 - struct list_head *next)
80274 +static bool __list_add_debug(struct list_head *new,
80275 + struct list_head *prev,
80276 + struct list_head *next)
80277 {
80278 - WARN(next->prev != prev,
80279 + if (WARN(next->prev != prev,
80280 "list_add corruption. next->prev should be "
80281 "prev (%p), but was %p. (next=%p).\n",
80282 - prev, next->prev, next);
80283 - WARN(prev->next != next,
80284 + prev, next->prev, next) ||
80285 + WARN(prev->next != next,
80286 "list_add corruption. prev->next should be "
80287 "next (%p), but was %p. (prev=%p).\n",
80288 - next, prev->next, prev);
80289 - WARN(new == prev || new == next,
80290 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80291 - new, prev, next);
80292 + next, prev->next, prev) ||
80293 + WARN(new == prev || new == next,
80294 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80295 + new, prev, next))
80296 + return false;
80297 + return true;
80298 +}
80299 +
80300 +void __list_add(struct list_head *new,
80301 + struct list_head *prev,
80302 + struct list_head *next)
80303 +{
80304 + if (!__list_add_debug(new, prev, next))
80305 + return;
80306 +
80307 next->prev = new;
80308 new->next = next;
80309 new->prev = prev;
80310 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80311 }
80312 EXPORT_SYMBOL(__list_add);
80313
80314 -void __list_del_entry(struct list_head *entry)
80315 +static bool __list_del_entry_debug(struct list_head *entry)
80316 {
80317 struct list_head *prev, *next;
80318
80319 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80320 WARN(next->prev != entry,
80321 "list_del corruption. next->prev should be %p, "
80322 "but was %p\n", entry, next->prev))
80323 + return false;
80324 + return true;
80325 +}
80326 +
80327 +void __list_del_entry(struct list_head *entry)
80328 +{
80329 + if (!__list_del_entry_debug(entry))
80330 return;
80331
80332 - __list_del(prev, next);
80333 + __list_del(entry->prev, entry->next);
80334 }
80335 EXPORT_SYMBOL(__list_del_entry);
80336
80337 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80338 void __list_add_rcu(struct list_head *new,
80339 struct list_head *prev, struct list_head *next)
80340 {
80341 - WARN(next->prev != prev,
80342 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80343 - prev, next->prev, next);
80344 - WARN(prev->next != next,
80345 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80346 - next, prev->next, prev);
80347 + if (!__list_add_debug(new, prev, next))
80348 + return;
80349 +
80350 new->next = next;
80351 new->prev = prev;
80352 rcu_assign_pointer(list_next_rcu(prev), new);
80353 next->prev = new;
80354 }
80355 EXPORT_SYMBOL(__list_add_rcu);
80356 +#endif
80357 +
80358 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80359 +{
80360 +#ifdef CONFIG_DEBUG_LIST
80361 + if (!__list_add_debug(new, prev, next))
80362 + return;
80363 +#endif
80364 +
80365 + pax_open_kernel();
80366 + next->prev = new;
80367 + new->next = next;
80368 + new->prev = prev;
80369 + prev->next = new;
80370 + pax_close_kernel();
80371 +}
80372 +EXPORT_SYMBOL(__pax_list_add);
80373 +
80374 +void pax_list_del(struct list_head *entry)
80375 +{
80376 +#ifdef CONFIG_DEBUG_LIST
80377 + if (!__list_del_entry_debug(entry))
80378 + return;
80379 +#endif
80380 +
80381 + pax_open_kernel();
80382 + __list_del(entry->prev, entry->next);
80383 + entry->next = LIST_POISON1;
80384 + entry->prev = LIST_POISON2;
80385 + pax_close_kernel();
80386 +}
80387 +EXPORT_SYMBOL(pax_list_del);
80388 +
80389 +void pax_list_del_init(struct list_head *entry)
80390 +{
80391 + pax_open_kernel();
80392 + __list_del(entry->prev, entry->next);
80393 + INIT_LIST_HEAD(entry);
80394 + pax_close_kernel();
80395 +}
80396 +EXPORT_SYMBOL(pax_list_del_init);
80397 +
80398 +void __pax_list_add_rcu(struct list_head *new,
80399 + struct list_head *prev, struct list_head *next)
80400 +{
80401 +#ifdef CONFIG_DEBUG_LIST
80402 + if (!__list_add_debug(new, prev, next))
80403 + return;
80404 +#endif
80405 +
80406 + pax_open_kernel();
80407 + new->next = next;
80408 + new->prev = prev;
80409 + rcu_assign_pointer(list_next_rcu(prev), new);
80410 + next->prev = new;
80411 + pax_close_kernel();
80412 +}
80413 +EXPORT_SYMBOL(__pax_list_add_rcu);
80414 +
80415 +void pax_list_del_rcu(struct list_head *entry)
80416 +{
80417 +#ifdef CONFIG_DEBUG_LIST
80418 + if (!__list_del_entry_debug(entry))
80419 + return;
80420 +#endif
80421 +
80422 + pax_open_kernel();
80423 + __list_del(entry->prev, entry->next);
80424 + entry->next = LIST_POISON1;
80425 + entry->prev = LIST_POISON2;
80426 + pax_close_kernel();
80427 +}
80428 +EXPORT_SYMBOL(pax_list_del_rcu);
80429 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80430 index e796429..6e38f9f 100644
80431 --- a/lib/radix-tree.c
80432 +++ b/lib/radix-tree.c
80433 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80434 int nr;
80435 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80436 };
80437 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80438 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80439
80440 static inline void *ptr_to_indirect(void *ptr)
80441 {
80442 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80443 index bb2b201..46abaf9 100644
80444 --- a/lib/strncpy_from_user.c
80445 +++ b/lib/strncpy_from_user.c
80446 @@ -21,7 +21,7 @@
80447 */
80448 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80449 {
80450 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80451 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80452 long res = 0;
80453
80454 /*
80455 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80456 index a28df52..3d55877 100644
80457 --- a/lib/strnlen_user.c
80458 +++ b/lib/strnlen_user.c
80459 @@ -26,7 +26,7 @@
80460 */
80461 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80462 {
80463 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80464 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80465 long align, res = 0;
80466 unsigned long c;
80467
80468 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80469 index 196b069..358f342 100644
80470 --- a/lib/swiotlb.c
80471 +++ b/lib/swiotlb.c
80472 @@ -642,7 +642,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80473
80474 void
80475 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80476 - dma_addr_t dev_addr)
80477 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80478 {
80479 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80480
80481 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80482 index fab33a9..3b5fe68 100644
80483 --- a/lib/vsprintf.c
80484 +++ b/lib/vsprintf.c
80485 @@ -16,6 +16,9 @@
80486 * - scnprintf and vscnprintf
80487 */
80488
80489 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80490 +#define __INCLUDED_BY_HIDESYM 1
80491 +#endif
80492 #include <stdarg.h>
80493 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80494 #include <linux/types.h>
80495 @@ -541,7 +544,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
80496 char sym[KSYM_SYMBOL_LEN];
80497 if (ext == 'B')
80498 sprint_backtrace(sym, value);
80499 - else if (ext != 'f' && ext != 's')
80500 + else if (ext != 'f' && ext != 's' && ext != 'a')
80501 sprint_symbol(sym, value);
80502 else
80503 sprint_symbol_no_offset(sym, value);
80504 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80505 return number(buf, end, *(const netdev_features_t *)addr, spec);
80506 }
80507
80508 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80509 +int kptr_restrict __read_mostly = 2;
80510 +#else
80511 int kptr_restrict __read_mostly;
80512 +#endif
80513
80514 /*
80515 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80516 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80517 * - 'S' For symbolic direct pointers with offset
80518 * - 's' For symbolic direct pointers without offset
80519 * - 'B' For backtraced symbolic direct pointers with offset
80520 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80521 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80522 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80523 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80524 * - 'M' For a 6-byte MAC address, it prints the address in the
80525 @@ -1043,12 +1052,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80526
80527 if (!ptr && *fmt != 'K') {
80528 /*
80529 - * Print (null) with the same width as a pointer so it makes
80530 + * Print (nil) with the same width as a pointer so it makes
80531 * tabular output look nice.
80532 */
80533 if (spec.field_width == -1)
80534 spec.field_width = default_width;
80535 - return string(buf, end, "(null)", spec);
80536 + return string(buf, end, "(nil)", spec);
80537 }
80538
80539 switch (*fmt) {
80540 @@ -1058,6 +1067,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80541 /* Fallthrough */
80542 case 'S':
80543 case 's':
80544 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80545 + break;
80546 +#else
80547 + return symbol_string(buf, end, ptr, spec, *fmt);
80548 +#endif
80549 + case 'A':
80550 + case 'a':
80551 case 'B':
80552 return symbol_string(buf, end, ptr, spec, *fmt);
80553 case 'R':
80554 @@ -1098,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80555 va_end(va);
80556 return buf;
80557 }
80558 + case 'P':
80559 + break;
80560 case 'K':
80561 /*
80562 * %pK cannot be used in IRQ context because its test
80563 @@ -1121,6 +1139,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80564 }
80565 break;
80566 }
80567 +
80568 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80569 + /* 'P' = approved pointers to copy to userland,
80570 + as in the /proc/kallsyms case, as we make it display nothing
80571 + for non-root users, and the real contents for root users
80572 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80573 + above
80574 + */
80575 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80576 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80577 + dump_stack();
80578 + ptr = NULL;
80579 + }
80580 +#endif
80581 +
80582 spec.flags |= SMALL;
80583 if (spec.field_width == -1) {
80584 spec.field_width = default_width;
80585 @@ -1842,11 +1875,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80586 typeof(type) value; \
80587 if (sizeof(type) == 8) { \
80588 args = PTR_ALIGN(args, sizeof(u32)); \
80589 - *(u32 *)&value = *(u32 *)args; \
80590 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80591 + *(u32 *)&value = *(const u32 *)args; \
80592 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80593 } else { \
80594 args = PTR_ALIGN(args, sizeof(type)); \
80595 - value = *(typeof(type) *)args; \
80596 + value = *(const typeof(type) *)args; \
80597 } \
80598 args += sizeof(type); \
80599 value; \
80600 @@ -1909,7 +1942,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80601 case FORMAT_TYPE_STR: {
80602 const char *str_arg = args;
80603 args += strlen(str_arg) + 1;
80604 - str = string(str, end, (char *)str_arg, spec);
80605 + str = string(str, end, str_arg, spec);
80606 break;
80607 }
80608
80609 diff --git a/localversion-grsec b/localversion-grsec
80610 new file mode 100644
80611 index 0000000..7cd6065
80612 --- /dev/null
80613 +++ b/localversion-grsec
80614 @@ -0,0 +1 @@
80615 +-grsec
80616 diff --git a/mm/Kconfig b/mm/Kconfig
80617 index 278e3ab..87c384d 100644
80618 --- a/mm/Kconfig
80619 +++ b/mm/Kconfig
80620 @@ -286,10 +286,10 @@ config KSM
80621 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80622
80623 config DEFAULT_MMAP_MIN_ADDR
80624 - int "Low address space to protect from user allocation"
80625 + int "Low address space to protect from user allocation"
80626 depends on MMU
80627 - default 4096
80628 - help
80629 + default 65536
80630 + help
80631 This is the portion of low virtual memory which should be protected
80632 from userspace allocation. Keeping a user from writing to low pages
80633 can help reduce the impact of kernel NULL pointer bugs.
80634 @@ -320,7 +320,7 @@ config MEMORY_FAILURE
80635
80636 config HWPOISON_INJECT
80637 tristate "HWPoison pages injector"
80638 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80639 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80640 select PROC_PAGE_MONITOR
80641
80642 config NOMMU_INITIAL_TRIM_EXCESS
80643 diff --git a/mm/filemap.c b/mm/filemap.c
80644 index 83efee7..3f99381 100644
80645 --- a/mm/filemap.c
80646 +++ b/mm/filemap.c
80647 @@ -1747,7 +1747,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80648 struct address_space *mapping = file->f_mapping;
80649
80650 if (!mapping->a_ops->readpage)
80651 - return -ENOEXEC;
80652 + return -ENODEV;
80653 file_accessed(file);
80654 vma->vm_ops = &generic_file_vm_ops;
80655 return 0;
80656 @@ -2087,6 +2087,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80657 *pos = i_size_read(inode);
80658
80659 if (limit != RLIM_INFINITY) {
80660 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80661 if (*pos >= limit) {
80662 send_sig(SIGXFSZ, current, 0);
80663 return -EFBIG;
80664 diff --git a/mm/fremap.c b/mm/fremap.c
80665 index a0aaf0e..20325c3 100644
80666 --- a/mm/fremap.c
80667 +++ b/mm/fremap.c
80668 @@ -157,6 +157,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80669 retry:
80670 vma = find_vma(mm, start);
80671
80672 +#ifdef CONFIG_PAX_SEGMEXEC
80673 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80674 + goto out;
80675 +#endif
80676 +
80677 /*
80678 * Make sure the vma is shared, that it supports prefaulting,
80679 * and that the remapped range is valid and fully within
80680 diff --git a/mm/highmem.c b/mm/highmem.c
80681 index b32b70c..e512eb0 100644
80682 --- a/mm/highmem.c
80683 +++ b/mm/highmem.c
80684 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80685 * So no dangers, even with speculative execution.
80686 */
80687 page = pte_page(pkmap_page_table[i]);
80688 + pax_open_kernel();
80689 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80690 -
80691 + pax_close_kernel();
80692 set_page_address(page, NULL);
80693 need_flush = 1;
80694 }
80695 @@ -198,9 +199,11 @@ start:
80696 }
80697 }
80698 vaddr = PKMAP_ADDR(last_pkmap_nr);
80699 +
80700 + pax_open_kernel();
80701 set_pte_at(&init_mm, vaddr,
80702 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80703 -
80704 + pax_close_kernel();
80705 pkmap_count[last_pkmap_nr] = 1;
80706 set_page_address(page, (void *)vaddr);
80707
80708 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80709 index d7cec92..b05cc33 100644
80710 --- a/mm/hugetlb.c
80711 +++ b/mm/hugetlb.c
80712 @@ -2008,15 +2008,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80713 struct hstate *h = &default_hstate;
80714 unsigned long tmp;
80715 int ret;
80716 + ctl_table_no_const hugetlb_table;
80717
80718 tmp = h->max_huge_pages;
80719
80720 if (write && h->order >= MAX_ORDER)
80721 return -EINVAL;
80722
80723 - table->data = &tmp;
80724 - table->maxlen = sizeof(unsigned long);
80725 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80726 + hugetlb_table = *table;
80727 + hugetlb_table.data = &tmp;
80728 + hugetlb_table.maxlen = sizeof(unsigned long);
80729 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80730 if (ret)
80731 goto out;
80732
80733 @@ -2073,15 +2075,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80734 struct hstate *h = &default_hstate;
80735 unsigned long tmp;
80736 int ret;
80737 + ctl_table_no_const hugetlb_table;
80738
80739 tmp = h->nr_overcommit_huge_pages;
80740
80741 if (write && h->order >= MAX_ORDER)
80742 return -EINVAL;
80743
80744 - table->data = &tmp;
80745 - table->maxlen = sizeof(unsigned long);
80746 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80747 + hugetlb_table = *table;
80748 + hugetlb_table.data = &tmp;
80749 + hugetlb_table.maxlen = sizeof(unsigned long);
80750 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80751 if (ret)
80752 goto out;
80753
80754 @@ -2515,6 +2519,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80755 return 1;
80756 }
80757
80758 +#ifdef CONFIG_PAX_SEGMEXEC
80759 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80760 +{
80761 + struct mm_struct *mm = vma->vm_mm;
80762 + struct vm_area_struct *vma_m;
80763 + unsigned long address_m;
80764 + pte_t *ptep_m;
80765 +
80766 + vma_m = pax_find_mirror_vma(vma);
80767 + if (!vma_m)
80768 + return;
80769 +
80770 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80771 + address_m = address + SEGMEXEC_TASK_SIZE;
80772 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80773 + get_page(page_m);
80774 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
80775 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
80776 +}
80777 +#endif
80778 +
80779 /*
80780 * Hugetlb_cow() should be called with page lock of the original hugepage held.
80781 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
80782 @@ -2633,6 +2658,11 @@ retry_avoidcopy:
80783 make_huge_pte(vma, new_page, 1));
80784 page_remove_rmap(old_page);
80785 hugepage_add_new_anon_rmap(new_page, vma, address);
80786 +
80787 +#ifdef CONFIG_PAX_SEGMEXEC
80788 + pax_mirror_huge_pte(vma, address, new_page);
80789 +#endif
80790 +
80791 /* Make the old page be freed below */
80792 new_page = old_page;
80793 }
80794 @@ -2792,6 +2822,10 @@ retry:
80795 && (vma->vm_flags & VM_SHARED)));
80796 set_huge_pte_at(mm, address, ptep, new_pte);
80797
80798 +#ifdef CONFIG_PAX_SEGMEXEC
80799 + pax_mirror_huge_pte(vma, address, page);
80800 +#endif
80801 +
80802 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
80803 /* Optimization, do the COW without a second fault */
80804 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
80805 @@ -2821,6 +2855,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80806 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
80807 struct hstate *h = hstate_vma(vma);
80808
80809 +#ifdef CONFIG_PAX_SEGMEXEC
80810 + struct vm_area_struct *vma_m;
80811 +#endif
80812 +
80813 address &= huge_page_mask(h);
80814
80815 ptep = huge_pte_offset(mm, address);
80816 @@ -2834,6 +2872,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80817 VM_FAULT_SET_HINDEX(hstate_index(h));
80818 }
80819
80820 +#ifdef CONFIG_PAX_SEGMEXEC
80821 + vma_m = pax_find_mirror_vma(vma);
80822 + if (vma_m) {
80823 + unsigned long address_m;
80824 +
80825 + if (vma->vm_start > vma_m->vm_start) {
80826 + address_m = address;
80827 + address -= SEGMEXEC_TASK_SIZE;
80828 + vma = vma_m;
80829 + h = hstate_vma(vma);
80830 + } else
80831 + address_m = address + SEGMEXEC_TASK_SIZE;
80832 +
80833 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
80834 + return VM_FAULT_OOM;
80835 + address_m &= HPAGE_MASK;
80836 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
80837 + }
80838 +#endif
80839 +
80840 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
80841 if (!ptep)
80842 return VM_FAULT_OOM;
80843 diff --git a/mm/internal.h b/mm/internal.h
80844 index 9ba2110..eaf0674 100644
80845 --- a/mm/internal.h
80846 +++ b/mm/internal.h
80847 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
80848 * in mm/page_alloc.c
80849 */
80850 extern void __free_pages_bootmem(struct page *page, unsigned int order);
80851 +extern void free_compound_page(struct page *page);
80852 extern void prep_compound_page(struct page *page, unsigned long order);
80853 #ifdef CONFIG_MEMORY_FAILURE
80854 extern bool is_free_buddy_page(struct page *page);
80855 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
80856 index 752a705..6c3102e 100644
80857 --- a/mm/kmemleak.c
80858 +++ b/mm/kmemleak.c
80859 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
80860
80861 for (i = 0; i < object->trace_len; i++) {
80862 void *ptr = (void *)object->trace[i];
80863 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
80864 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
80865 }
80866 }
80867
80868 @@ -1853,7 +1853,7 @@ static int __init kmemleak_late_init(void)
80869 return -ENOMEM;
80870 }
80871
80872 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
80873 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
80874 &kmemleak_fops);
80875 if (!dentry)
80876 pr_warning("Failed to create the debugfs kmemleak file\n");
80877 diff --git a/mm/maccess.c b/mm/maccess.c
80878 index d53adf9..03a24bf 100644
80879 --- a/mm/maccess.c
80880 +++ b/mm/maccess.c
80881 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
80882 set_fs(KERNEL_DS);
80883 pagefault_disable();
80884 ret = __copy_from_user_inatomic(dst,
80885 - (__force const void __user *)src, size);
80886 + (const void __force_user *)src, size);
80887 pagefault_enable();
80888 set_fs(old_fs);
80889
80890 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
80891
80892 set_fs(KERNEL_DS);
80893 pagefault_disable();
80894 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
80895 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
80896 pagefault_enable();
80897 set_fs(old_fs);
80898
80899 diff --git a/mm/madvise.c b/mm/madvise.c
80900 index 03dfa5c..b032917 100644
80901 --- a/mm/madvise.c
80902 +++ b/mm/madvise.c
80903 @@ -48,6 +48,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
80904 pgoff_t pgoff;
80905 unsigned long new_flags = vma->vm_flags;
80906
80907 +#ifdef CONFIG_PAX_SEGMEXEC
80908 + struct vm_area_struct *vma_m;
80909 +#endif
80910 +
80911 switch (behavior) {
80912 case MADV_NORMAL:
80913 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
80914 @@ -123,6 +127,13 @@ success:
80915 /*
80916 * vm_flags is protected by the mmap_sem held in write mode.
80917 */
80918 +
80919 +#ifdef CONFIG_PAX_SEGMEXEC
80920 + vma_m = pax_find_mirror_vma(vma);
80921 + if (vma_m)
80922 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
80923 +#endif
80924 +
80925 vma->vm_flags = new_flags;
80926
80927 out:
80928 @@ -181,6 +192,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80929 struct vm_area_struct ** prev,
80930 unsigned long start, unsigned long end)
80931 {
80932 +
80933 +#ifdef CONFIG_PAX_SEGMEXEC
80934 + struct vm_area_struct *vma_m;
80935 +#endif
80936 +
80937 *prev = vma;
80938 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
80939 return -EINVAL;
80940 @@ -193,6 +209,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
80941 zap_page_range(vma, start, end - start, &details);
80942 } else
80943 zap_page_range(vma, start, end - start, NULL);
80944 +
80945 +#ifdef CONFIG_PAX_SEGMEXEC
80946 + vma_m = pax_find_mirror_vma(vma);
80947 + if (vma_m) {
80948 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
80949 + struct zap_details details = {
80950 + .nonlinear_vma = vma_m,
80951 + .last_index = ULONG_MAX,
80952 + };
80953 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
80954 + } else
80955 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
80956 + }
80957 +#endif
80958 +
80959 return 0;
80960 }
80961
80962 @@ -397,6 +428,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
80963 if (end < start)
80964 goto out;
80965
80966 +#ifdef CONFIG_PAX_SEGMEXEC
80967 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
80968 + if (end > SEGMEXEC_TASK_SIZE)
80969 + goto out;
80970 + } else
80971 +#endif
80972 +
80973 + if (end > TASK_SIZE)
80974 + goto out;
80975 +
80976 error = 0;
80977 if (end == start)
80978 goto out;
80979 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
80980 index c6e4dd3..1f41988 100644
80981 --- a/mm/memory-failure.c
80982 +++ b/mm/memory-failure.c
80983 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
80984
80985 int sysctl_memory_failure_recovery __read_mostly = 1;
80986
80987 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
80988 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
80989
80990 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
80991
80992 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
80993 pfn, t->comm, t->pid);
80994 si.si_signo = SIGBUS;
80995 si.si_errno = 0;
80996 - si.si_addr = (void *)addr;
80997 + si.si_addr = (void __user *)addr;
80998 #ifdef __ARCH_SI_TRAPNO
80999 si.si_trapno = trapno;
81000 #endif
81001 @@ -760,7 +760,7 @@ static struct page_state {
81002 unsigned long res;
81003 char *msg;
81004 int (*action)(struct page *p, unsigned long pfn);
81005 -} error_states[] = {
81006 +} __do_const error_states[] = {
81007 { reserved, reserved, "reserved kernel", me_kernel },
81008 /*
81009 * free pages are specially detected outside this table:
81010 @@ -1040,7 +1040,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81011 }
81012
81013 nr_pages = 1 << compound_trans_order(hpage);
81014 - atomic_long_add(nr_pages, &mce_bad_pages);
81015 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
81016
81017 /*
81018 * We need/can do nothing about count=0 pages.
81019 @@ -1070,7 +1070,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81020 if (!PageHWPoison(hpage)
81021 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
81022 || (p != hpage && TestSetPageHWPoison(hpage))) {
81023 - atomic_long_sub(nr_pages, &mce_bad_pages);
81024 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81025 return 0;
81026 }
81027 set_page_hwpoison_huge_page(hpage);
81028 @@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81029 }
81030 if (hwpoison_filter(p)) {
81031 if (TestClearPageHWPoison(p))
81032 - atomic_long_sub(nr_pages, &mce_bad_pages);
81033 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81034 unlock_page(hpage);
81035 put_page(hpage);
81036 return 0;
81037 @@ -1323,7 +1323,7 @@ int unpoison_memory(unsigned long pfn)
81038 return 0;
81039 }
81040 if (TestClearPageHWPoison(p))
81041 - atomic_long_sub(nr_pages, &mce_bad_pages);
81042 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81043 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81044 return 0;
81045 }
81046 @@ -1337,7 +1337,7 @@ int unpoison_memory(unsigned long pfn)
81047 */
81048 if (TestClearPageHWPoison(page)) {
81049 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81050 - atomic_long_sub(nr_pages, &mce_bad_pages);
81051 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81052 freeit = 1;
81053 if (PageHuge(page))
81054 clear_page_hwpoison_huge_page(page);
81055 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81056 }
81057 done:
81058 if (!PageHWPoison(hpage))
81059 - atomic_long_add(1 << compound_trans_order(hpage),
81060 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81061 &mce_bad_pages);
81062 set_page_hwpoison_huge_page(hpage);
81063 dequeue_hwpoisoned_huge_page(hpage);
81064 @@ -1583,7 +1583,7 @@ int soft_offline_page(struct page *page, int flags)
81065 return ret;
81066
81067 done:
81068 - atomic_long_add(1, &mce_bad_pages);
81069 + atomic_long_add_unchecked(1, &mce_bad_pages);
81070 SetPageHWPoison(page);
81071 /* keep elevated page count for bad page */
81072 return ret;
81073 diff --git a/mm/memory.c b/mm/memory.c
81074 index bb1369f..b9631d2 100644
81075 --- a/mm/memory.c
81076 +++ b/mm/memory.c
81077 @@ -433,6 +433,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81078 free_pte_range(tlb, pmd, addr);
81079 } while (pmd++, addr = next, addr != end);
81080
81081 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81082 start &= PUD_MASK;
81083 if (start < floor)
81084 return;
81085 @@ -447,6 +448,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81086 pmd = pmd_offset(pud, start);
81087 pud_clear(pud);
81088 pmd_free_tlb(tlb, pmd, start);
81089 +#endif
81090 +
81091 }
81092
81093 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81094 @@ -466,6 +469,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81095 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81096 } while (pud++, addr = next, addr != end);
81097
81098 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81099 start &= PGDIR_MASK;
81100 if (start < floor)
81101 return;
81102 @@ -480,6 +484,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81103 pud = pud_offset(pgd, start);
81104 pgd_clear(pgd);
81105 pud_free_tlb(tlb, pud, start);
81106 +#endif
81107 +
81108 }
81109
81110 /*
81111 @@ -1618,12 +1624,6 @@ no_page_table:
81112 return page;
81113 }
81114
81115 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81116 -{
81117 - return stack_guard_page_start(vma, addr) ||
81118 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81119 -}
81120 -
81121 /**
81122 * __get_user_pages() - pin user pages in memory
81123 * @tsk: task_struct of target task
81124 @@ -1709,10 +1709,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81125
81126 i = 0;
81127
81128 - do {
81129 + while (nr_pages) {
81130 struct vm_area_struct *vma;
81131
81132 - vma = find_extend_vma(mm, start);
81133 + vma = find_vma(mm, start);
81134 if (!vma && in_gate_area(mm, start)) {
81135 unsigned long pg = start & PAGE_MASK;
81136 pgd_t *pgd;
81137 @@ -1760,7 +1760,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81138 goto next_page;
81139 }
81140
81141 - if (!vma ||
81142 + if (!vma || start < vma->vm_start ||
81143 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81144 !(vm_flags & vma->vm_flags))
81145 return i ? : -EFAULT;
81146 @@ -1787,11 +1787,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81147 int ret;
81148 unsigned int fault_flags = 0;
81149
81150 - /* For mlock, just skip the stack guard page. */
81151 - if (foll_flags & FOLL_MLOCK) {
81152 - if (stack_guard_page(vma, start))
81153 - goto next_page;
81154 - }
81155 if (foll_flags & FOLL_WRITE)
81156 fault_flags |= FAULT_FLAG_WRITE;
81157 if (nonblocking)
81158 @@ -1865,7 +1860,7 @@ next_page:
81159 start += PAGE_SIZE;
81160 nr_pages--;
81161 } while (nr_pages && start < vma->vm_end);
81162 - } while (nr_pages);
81163 + }
81164 return i;
81165 }
81166 EXPORT_SYMBOL(__get_user_pages);
81167 @@ -2072,6 +2067,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81168 page_add_file_rmap(page);
81169 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81170
81171 +#ifdef CONFIG_PAX_SEGMEXEC
81172 + pax_mirror_file_pte(vma, addr, page, ptl);
81173 +#endif
81174 +
81175 retval = 0;
81176 pte_unmap_unlock(pte, ptl);
81177 return retval;
81178 @@ -2116,9 +2115,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81179 if (!page_count(page))
81180 return -EINVAL;
81181 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81182 +
81183 +#ifdef CONFIG_PAX_SEGMEXEC
81184 + struct vm_area_struct *vma_m;
81185 +#endif
81186 +
81187 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81188 BUG_ON(vma->vm_flags & VM_PFNMAP);
81189 vma->vm_flags |= VM_MIXEDMAP;
81190 +
81191 +#ifdef CONFIG_PAX_SEGMEXEC
81192 + vma_m = pax_find_mirror_vma(vma);
81193 + if (vma_m)
81194 + vma_m->vm_flags |= VM_MIXEDMAP;
81195 +#endif
81196 +
81197 }
81198 return insert_page(vma, addr, page, vma->vm_page_prot);
81199 }
81200 @@ -2201,6 +2212,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81201 unsigned long pfn)
81202 {
81203 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81204 + BUG_ON(vma->vm_mirror);
81205
81206 if (addr < vma->vm_start || addr >= vma->vm_end)
81207 return -EFAULT;
81208 @@ -2401,7 +2413,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81209
81210 BUG_ON(pud_huge(*pud));
81211
81212 - pmd = pmd_alloc(mm, pud, addr);
81213 + pmd = (mm == &init_mm) ?
81214 + pmd_alloc_kernel(mm, pud, addr) :
81215 + pmd_alloc(mm, pud, addr);
81216 if (!pmd)
81217 return -ENOMEM;
81218 do {
81219 @@ -2421,7 +2435,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81220 unsigned long next;
81221 int err;
81222
81223 - pud = pud_alloc(mm, pgd, addr);
81224 + pud = (mm == &init_mm) ?
81225 + pud_alloc_kernel(mm, pgd, addr) :
81226 + pud_alloc(mm, pgd, addr);
81227 if (!pud)
81228 return -ENOMEM;
81229 do {
81230 @@ -2509,6 +2525,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81231 copy_user_highpage(dst, src, va, vma);
81232 }
81233
81234 +#ifdef CONFIG_PAX_SEGMEXEC
81235 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81236 +{
81237 + struct mm_struct *mm = vma->vm_mm;
81238 + spinlock_t *ptl;
81239 + pte_t *pte, entry;
81240 +
81241 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81242 + entry = *pte;
81243 + if (!pte_present(entry)) {
81244 + if (!pte_none(entry)) {
81245 + BUG_ON(pte_file(entry));
81246 + free_swap_and_cache(pte_to_swp_entry(entry));
81247 + pte_clear_not_present_full(mm, address, pte, 0);
81248 + }
81249 + } else {
81250 + struct page *page;
81251 +
81252 + flush_cache_page(vma, address, pte_pfn(entry));
81253 + entry = ptep_clear_flush(vma, address, pte);
81254 + BUG_ON(pte_dirty(entry));
81255 + page = vm_normal_page(vma, address, entry);
81256 + if (page) {
81257 + update_hiwater_rss(mm);
81258 + if (PageAnon(page))
81259 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81260 + else
81261 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81262 + page_remove_rmap(page);
81263 + page_cache_release(page);
81264 + }
81265 + }
81266 + pte_unmap_unlock(pte, ptl);
81267 +}
81268 +
81269 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81270 + *
81271 + * the ptl of the lower mapped page is held on entry and is not released on exit
81272 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81273 + */
81274 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81275 +{
81276 + struct mm_struct *mm = vma->vm_mm;
81277 + unsigned long address_m;
81278 + spinlock_t *ptl_m;
81279 + struct vm_area_struct *vma_m;
81280 + pmd_t *pmd_m;
81281 + pte_t *pte_m, entry_m;
81282 +
81283 + BUG_ON(!page_m || !PageAnon(page_m));
81284 +
81285 + vma_m = pax_find_mirror_vma(vma);
81286 + if (!vma_m)
81287 + return;
81288 +
81289 + BUG_ON(!PageLocked(page_m));
81290 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81291 + address_m = address + SEGMEXEC_TASK_SIZE;
81292 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81293 + pte_m = pte_offset_map(pmd_m, address_m);
81294 + ptl_m = pte_lockptr(mm, pmd_m);
81295 + if (ptl != ptl_m) {
81296 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81297 + if (!pte_none(*pte_m))
81298 + goto out;
81299 + }
81300 +
81301 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81302 + page_cache_get(page_m);
81303 + page_add_anon_rmap(page_m, vma_m, address_m);
81304 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81305 + set_pte_at(mm, address_m, pte_m, entry_m);
81306 + update_mmu_cache(vma_m, address_m, entry_m);
81307 +out:
81308 + if (ptl != ptl_m)
81309 + spin_unlock(ptl_m);
81310 + pte_unmap(pte_m);
81311 + unlock_page(page_m);
81312 +}
81313 +
81314 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81315 +{
81316 + struct mm_struct *mm = vma->vm_mm;
81317 + unsigned long address_m;
81318 + spinlock_t *ptl_m;
81319 + struct vm_area_struct *vma_m;
81320 + pmd_t *pmd_m;
81321 + pte_t *pte_m, entry_m;
81322 +
81323 + BUG_ON(!page_m || PageAnon(page_m));
81324 +
81325 + vma_m = pax_find_mirror_vma(vma);
81326 + if (!vma_m)
81327 + return;
81328 +
81329 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81330 + address_m = address + SEGMEXEC_TASK_SIZE;
81331 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81332 + pte_m = pte_offset_map(pmd_m, address_m);
81333 + ptl_m = pte_lockptr(mm, pmd_m);
81334 + if (ptl != ptl_m) {
81335 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81336 + if (!pte_none(*pte_m))
81337 + goto out;
81338 + }
81339 +
81340 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81341 + page_cache_get(page_m);
81342 + page_add_file_rmap(page_m);
81343 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81344 + set_pte_at(mm, address_m, pte_m, entry_m);
81345 + update_mmu_cache(vma_m, address_m, entry_m);
81346 +out:
81347 + if (ptl != ptl_m)
81348 + spin_unlock(ptl_m);
81349 + pte_unmap(pte_m);
81350 +}
81351 +
81352 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81353 +{
81354 + struct mm_struct *mm = vma->vm_mm;
81355 + unsigned long address_m;
81356 + spinlock_t *ptl_m;
81357 + struct vm_area_struct *vma_m;
81358 + pmd_t *pmd_m;
81359 + pte_t *pte_m, entry_m;
81360 +
81361 + vma_m = pax_find_mirror_vma(vma);
81362 + if (!vma_m)
81363 + return;
81364 +
81365 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81366 + address_m = address + SEGMEXEC_TASK_SIZE;
81367 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81368 + pte_m = pte_offset_map(pmd_m, address_m);
81369 + ptl_m = pte_lockptr(mm, pmd_m);
81370 + if (ptl != ptl_m) {
81371 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81372 + if (!pte_none(*pte_m))
81373 + goto out;
81374 + }
81375 +
81376 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81377 + set_pte_at(mm, address_m, pte_m, entry_m);
81378 +out:
81379 + if (ptl != ptl_m)
81380 + spin_unlock(ptl_m);
81381 + pte_unmap(pte_m);
81382 +}
81383 +
81384 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81385 +{
81386 + struct page *page_m;
81387 + pte_t entry;
81388 +
81389 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81390 + goto out;
81391 +
81392 + entry = *pte;
81393 + page_m = vm_normal_page(vma, address, entry);
81394 + if (!page_m)
81395 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81396 + else if (PageAnon(page_m)) {
81397 + if (pax_find_mirror_vma(vma)) {
81398 + pte_unmap_unlock(pte, ptl);
81399 + lock_page(page_m);
81400 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81401 + if (pte_same(entry, *pte))
81402 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81403 + else
81404 + unlock_page(page_m);
81405 + }
81406 + } else
81407 + pax_mirror_file_pte(vma, address, page_m, ptl);
81408 +
81409 +out:
81410 + pte_unmap_unlock(pte, ptl);
81411 +}
81412 +#endif
81413 +
81414 /*
81415 * This routine handles present pages, when users try to write
81416 * to a shared page. It is done by copying the page to a new address
81417 @@ -2725,6 +2921,12 @@ gotten:
81418 */
81419 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81420 if (likely(pte_same(*page_table, orig_pte))) {
81421 +
81422 +#ifdef CONFIG_PAX_SEGMEXEC
81423 + if (pax_find_mirror_vma(vma))
81424 + BUG_ON(!trylock_page(new_page));
81425 +#endif
81426 +
81427 if (old_page) {
81428 if (!PageAnon(old_page)) {
81429 dec_mm_counter_fast(mm, MM_FILEPAGES);
81430 @@ -2776,6 +2978,10 @@ gotten:
81431 page_remove_rmap(old_page);
81432 }
81433
81434 +#ifdef CONFIG_PAX_SEGMEXEC
81435 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81436 +#endif
81437 +
81438 /* Free the old page.. */
81439 new_page = old_page;
81440 ret |= VM_FAULT_WRITE;
81441 @@ -3051,6 +3257,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81442 swap_free(entry);
81443 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81444 try_to_free_swap(page);
81445 +
81446 +#ifdef CONFIG_PAX_SEGMEXEC
81447 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81448 +#endif
81449 +
81450 unlock_page(page);
81451 if (swapcache) {
81452 /*
81453 @@ -3074,6 +3285,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81454
81455 /* No need to invalidate - it was non-present before */
81456 update_mmu_cache(vma, address, page_table);
81457 +
81458 +#ifdef CONFIG_PAX_SEGMEXEC
81459 + pax_mirror_anon_pte(vma, address, page, ptl);
81460 +#endif
81461 +
81462 unlock:
81463 pte_unmap_unlock(page_table, ptl);
81464 out:
81465 @@ -3093,40 +3309,6 @@ out_release:
81466 }
81467
81468 /*
81469 - * This is like a special single-page "expand_{down|up}wards()",
81470 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81471 - * doesn't hit another vma.
81472 - */
81473 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81474 -{
81475 - address &= PAGE_MASK;
81476 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81477 - struct vm_area_struct *prev = vma->vm_prev;
81478 -
81479 - /*
81480 - * Is there a mapping abutting this one below?
81481 - *
81482 - * That's only ok if it's the same stack mapping
81483 - * that has gotten split..
81484 - */
81485 - if (prev && prev->vm_end == address)
81486 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81487 -
81488 - expand_downwards(vma, address - PAGE_SIZE);
81489 - }
81490 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81491 - struct vm_area_struct *next = vma->vm_next;
81492 -
81493 - /* As VM_GROWSDOWN but s/below/above/ */
81494 - if (next && next->vm_start == address + PAGE_SIZE)
81495 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81496 -
81497 - expand_upwards(vma, address + PAGE_SIZE);
81498 - }
81499 - return 0;
81500 -}
81501 -
81502 -/*
81503 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81504 * but allow concurrent faults), and pte mapped but not yet locked.
81505 * We return with mmap_sem still held, but pte unmapped and unlocked.
81506 @@ -3135,27 +3317,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81507 unsigned long address, pte_t *page_table, pmd_t *pmd,
81508 unsigned int flags)
81509 {
81510 - struct page *page;
81511 + struct page *page = NULL;
81512 spinlock_t *ptl;
81513 pte_t entry;
81514
81515 - pte_unmap(page_table);
81516 -
81517 - /* Check if we need to add a guard page to the stack */
81518 - if (check_stack_guard_page(vma, address) < 0)
81519 - return VM_FAULT_SIGBUS;
81520 -
81521 - /* Use the zero-page for reads */
81522 if (!(flags & FAULT_FLAG_WRITE)) {
81523 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81524 vma->vm_page_prot));
81525 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81526 + ptl = pte_lockptr(mm, pmd);
81527 + spin_lock(ptl);
81528 if (!pte_none(*page_table))
81529 goto unlock;
81530 goto setpte;
81531 }
81532
81533 /* Allocate our own private page. */
81534 + pte_unmap(page_table);
81535 +
81536 if (unlikely(anon_vma_prepare(vma)))
81537 goto oom;
81538 page = alloc_zeroed_user_highpage_movable(vma, address);
81539 @@ -3174,6 +3352,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81540 if (!pte_none(*page_table))
81541 goto release;
81542
81543 +#ifdef CONFIG_PAX_SEGMEXEC
81544 + if (pax_find_mirror_vma(vma))
81545 + BUG_ON(!trylock_page(page));
81546 +#endif
81547 +
81548 inc_mm_counter_fast(mm, MM_ANONPAGES);
81549 page_add_new_anon_rmap(page, vma, address);
81550 setpte:
81551 @@ -3181,6 +3364,12 @@ setpte:
81552
81553 /* No need to invalidate - it was non-present before */
81554 update_mmu_cache(vma, address, page_table);
81555 +
81556 +#ifdef CONFIG_PAX_SEGMEXEC
81557 + if (page)
81558 + pax_mirror_anon_pte(vma, address, page, ptl);
81559 +#endif
81560 +
81561 unlock:
81562 pte_unmap_unlock(page_table, ptl);
81563 return 0;
81564 @@ -3324,6 +3513,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81565 */
81566 /* Only go through if we didn't race with anybody else... */
81567 if (likely(pte_same(*page_table, orig_pte))) {
81568 +
81569 +#ifdef CONFIG_PAX_SEGMEXEC
81570 + if (anon && pax_find_mirror_vma(vma))
81571 + BUG_ON(!trylock_page(page));
81572 +#endif
81573 +
81574 flush_icache_page(vma, page);
81575 entry = mk_pte(page, vma->vm_page_prot);
81576 if (flags & FAULT_FLAG_WRITE)
81577 @@ -3343,6 +3538,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81578
81579 /* no need to invalidate: a not-present page won't be cached */
81580 update_mmu_cache(vma, address, page_table);
81581 +
81582 +#ifdef CONFIG_PAX_SEGMEXEC
81583 + if (anon)
81584 + pax_mirror_anon_pte(vma, address, page, ptl);
81585 + else
81586 + pax_mirror_file_pte(vma, address, page, ptl);
81587 +#endif
81588 +
81589 } else {
81590 if (cow_page)
81591 mem_cgroup_uncharge_page(cow_page);
81592 @@ -3664,6 +3867,12 @@ int handle_pte_fault(struct mm_struct *mm,
81593 if (flags & FAULT_FLAG_WRITE)
81594 flush_tlb_fix_spurious_fault(vma, address);
81595 }
81596 +
81597 +#ifdef CONFIG_PAX_SEGMEXEC
81598 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81599 + return 0;
81600 +#endif
81601 +
81602 unlock:
81603 pte_unmap_unlock(pte, ptl);
81604 return 0;
81605 @@ -3680,6 +3889,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81606 pmd_t *pmd;
81607 pte_t *pte;
81608
81609 +#ifdef CONFIG_PAX_SEGMEXEC
81610 + struct vm_area_struct *vma_m;
81611 +#endif
81612 +
81613 __set_current_state(TASK_RUNNING);
81614
81615 count_vm_event(PGFAULT);
81616 @@ -3691,6 +3904,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81617 if (unlikely(is_vm_hugetlb_page(vma)))
81618 return hugetlb_fault(mm, vma, address, flags);
81619
81620 +#ifdef CONFIG_PAX_SEGMEXEC
81621 + vma_m = pax_find_mirror_vma(vma);
81622 + if (vma_m) {
81623 + unsigned long address_m;
81624 + pgd_t *pgd_m;
81625 + pud_t *pud_m;
81626 + pmd_t *pmd_m;
81627 +
81628 + if (vma->vm_start > vma_m->vm_start) {
81629 + address_m = address;
81630 + address -= SEGMEXEC_TASK_SIZE;
81631 + vma = vma_m;
81632 + } else
81633 + address_m = address + SEGMEXEC_TASK_SIZE;
81634 +
81635 + pgd_m = pgd_offset(mm, address_m);
81636 + pud_m = pud_alloc(mm, pgd_m, address_m);
81637 + if (!pud_m)
81638 + return VM_FAULT_OOM;
81639 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81640 + if (!pmd_m)
81641 + return VM_FAULT_OOM;
81642 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81643 + return VM_FAULT_OOM;
81644 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81645 + }
81646 +#endif
81647 +
81648 retry:
81649 pgd = pgd_offset(mm, address);
81650 pud = pud_alloc(mm, pgd, address);
81651 @@ -3789,6 +4030,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81652 spin_unlock(&mm->page_table_lock);
81653 return 0;
81654 }
81655 +
81656 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81657 +{
81658 + pud_t *new = pud_alloc_one(mm, address);
81659 + if (!new)
81660 + return -ENOMEM;
81661 +
81662 + smp_wmb(); /* See comment in __pte_alloc */
81663 +
81664 + spin_lock(&mm->page_table_lock);
81665 + if (pgd_present(*pgd)) /* Another has populated it */
81666 + pud_free(mm, new);
81667 + else
81668 + pgd_populate_kernel(mm, pgd, new);
81669 + spin_unlock(&mm->page_table_lock);
81670 + return 0;
81671 +}
81672 #endif /* __PAGETABLE_PUD_FOLDED */
81673
81674 #ifndef __PAGETABLE_PMD_FOLDED
81675 @@ -3819,11 +4077,35 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81676 spin_unlock(&mm->page_table_lock);
81677 return 0;
81678 }
81679 +
81680 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81681 +{
81682 + pmd_t *new = pmd_alloc_one(mm, address);
81683 + if (!new)
81684 + return -ENOMEM;
81685 +
81686 + smp_wmb(); /* See comment in __pte_alloc */
81687 +
81688 + spin_lock(&mm->page_table_lock);
81689 +#ifndef __ARCH_HAS_4LEVEL_HACK
81690 + if (pud_present(*pud)) /* Another has populated it */
81691 + pmd_free(mm, new);
81692 + else
81693 + pud_populate_kernel(mm, pud, new);
81694 +#else
81695 + if (pgd_present(*pud)) /* Another has populated it */
81696 + pmd_free(mm, new);
81697 + else
81698 + pgd_populate_kernel(mm, pud, new);
81699 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81700 + spin_unlock(&mm->page_table_lock);
81701 + return 0;
81702 +}
81703 #endif /* __PAGETABLE_PMD_FOLDED */
81704
81705 -int make_pages_present(unsigned long addr, unsigned long end)
81706 +ssize_t make_pages_present(unsigned long addr, unsigned long end)
81707 {
81708 - int ret, len, write;
81709 + ssize_t ret, len, write;
81710 struct vm_area_struct * vma;
81711
81712 vma = find_vma(current->mm, addr);
81713 @@ -3856,7 +4138,7 @@ static int __init gate_vma_init(void)
81714 gate_vma.vm_start = FIXADDR_USER_START;
81715 gate_vma.vm_end = FIXADDR_USER_END;
81716 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81717 - gate_vma.vm_page_prot = __P101;
81718 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81719
81720 return 0;
81721 }
81722 @@ -3990,8 +4272,8 @@ out:
81723 return ret;
81724 }
81725
81726 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81727 - void *buf, int len, int write)
81728 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81729 + void *buf, size_t len, int write)
81730 {
81731 resource_size_t phys_addr;
81732 unsigned long prot = 0;
81733 @@ -4016,8 +4298,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81734 * Access another process' address space as given in mm. If non-NULL, use the
81735 * given task for page fault accounting.
81736 */
81737 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81738 - unsigned long addr, void *buf, int len, int write)
81739 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81740 + unsigned long addr, void *buf, size_t len, int write)
81741 {
81742 struct vm_area_struct *vma;
81743 void *old_buf = buf;
81744 @@ -4025,7 +4307,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81745 down_read(&mm->mmap_sem);
81746 /* ignore errors, just check how much was successfully transferred */
81747 while (len) {
81748 - int bytes, ret, offset;
81749 + ssize_t bytes, ret, offset;
81750 void *maddr;
81751 struct page *page = NULL;
81752
81753 @@ -4084,8 +4366,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81754 *
81755 * The caller must hold a reference on @mm.
81756 */
81757 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81758 - void *buf, int len, int write)
81759 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
81760 + void *buf, size_t len, int write)
81761 {
81762 return __access_remote_vm(NULL, mm, addr, buf, len, write);
81763 }
81764 @@ -4095,11 +4377,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81765 * Source/target buffer must be kernel space,
81766 * Do not walk the page table directly, use get_user_pages
81767 */
81768 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
81769 - void *buf, int len, int write)
81770 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
81771 + void *buf, size_t len, int write)
81772 {
81773 struct mm_struct *mm;
81774 - int ret;
81775 + ssize_t ret;
81776
81777 mm = get_task_mm(tsk);
81778 if (!mm)
81779 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
81780 index 3df6d12..a11056a 100644
81781 --- a/mm/mempolicy.c
81782 +++ b/mm/mempolicy.c
81783 @@ -721,6 +721,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81784 unsigned long vmstart;
81785 unsigned long vmend;
81786
81787 +#ifdef CONFIG_PAX_SEGMEXEC
81788 + struct vm_area_struct *vma_m;
81789 +#endif
81790 +
81791 vma = find_vma(mm, start);
81792 if (!vma || vma->vm_start > start)
81793 return -EFAULT;
81794 @@ -757,9 +761,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81795 if (err)
81796 goto out;
81797 }
81798 +
81799 err = vma_replace_policy(vma, new_pol);
81800 if (err)
81801 goto out;
81802 +
81803 +#ifdef CONFIG_PAX_SEGMEXEC
81804 + vma_m = pax_find_mirror_vma(vma);
81805 + if (vma_m) {
81806 + err = vma_replace_policy(vma_m, new_pol);
81807 + if (err)
81808 + goto out;
81809 + }
81810 +#endif
81811 +
81812 }
81813
81814 out:
81815 @@ -1216,6 +1231,17 @@ static long do_mbind(unsigned long start, unsigned long len,
81816
81817 if (end < start)
81818 return -EINVAL;
81819 +
81820 +#ifdef CONFIG_PAX_SEGMEXEC
81821 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81822 + if (end > SEGMEXEC_TASK_SIZE)
81823 + return -EINVAL;
81824 + } else
81825 +#endif
81826 +
81827 + if (end > TASK_SIZE)
81828 + return -EINVAL;
81829 +
81830 if (end == start)
81831 return 0;
81832
81833 @@ -1445,8 +1471,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81834 */
81835 tcred = __task_cred(task);
81836 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81837 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81838 - !capable(CAP_SYS_NICE)) {
81839 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81840 rcu_read_unlock();
81841 err = -EPERM;
81842 goto out_put;
81843 @@ -1477,6 +1502,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81844 goto out;
81845 }
81846
81847 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81848 + if (mm != current->mm &&
81849 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
81850 + mmput(mm);
81851 + err = -EPERM;
81852 + goto out;
81853 + }
81854 +#endif
81855 +
81856 err = do_migrate_pages(mm, old, new,
81857 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
81858
81859 diff --git a/mm/migrate.c b/mm/migrate.c
81860 index 2fd8b4a..d70358f 100644
81861 --- a/mm/migrate.c
81862 +++ b/mm/migrate.c
81863 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
81864 */
81865 tcred = __task_cred(task);
81866 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81867 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81868 - !capable(CAP_SYS_NICE)) {
81869 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81870 rcu_read_unlock();
81871 err = -EPERM;
81872 goto out;
81873 diff --git a/mm/mlock.c b/mm/mlock.c
81874 index c9bd528..da8d069 100644
81875 --- a/mm/mlock.c
81876 +++ b/mm/mlock.c
81877 @@ -13,6 +13,7 @@
81878 #include <linux/pagemap.h>
81879 #include <linux/mempolicy.h>
81880 #include <linux/syscalls.h>
81881 +#include <linux/security.h>
81882 #include <linux/sched.h>
81883 #include <linux/export.h>
81884 #include <linux/rmap.h>
81885 @@ -369,7 +370,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
81886 {
81887 unsigned long nstart, end, tmp;
81888 struct vm_area_struct * vma, * prev;
81889 - int error;
81890 + int error = 0;
81891
81892 VM_BUG_ON(start & ~PAGE_MASK);
81893 VM_BUG_ON(len != PAGE_ALIGN(len));
81894 @@ -378,6 +379,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
81895 return -EINVAL;
81896 if (end == start)
81897 return 0;
81898 + if (end > TASK_SIZE)
81899 + return -EINVAL;
81900 +
81901 vma = find_vma(current->mm, start);
81902 if (!vma || vma->vm_start > start)
81903 return -ENOMEM;
81904 @@ -389,6 +393,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
81905 for (nstart = start ; ; ) {
81906 vm_flags_t newflags;
81907
81908 +#ifdef CONFIG_PAX_SEGMEXEC
81909 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81910 + break;
81911 +#endif
81912 +
81913 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
81914
81915 newflags = vma->vm_flags | VM_LOCKED;
81916 @@ -494,6 +503,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
81917 lock_limit >>= PAGE_SHIFT;
81918
81919 /* check against resource limits */
81920 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
81921 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
81922 error = do_mlock(start, len, 1);
81923 up_write(&current->mm->mmap_sem);
81924 @@ -528,6 +538,12 @@ static int do_mlockall(int flags)
81925 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
81926 vm_flags_t newflags;
81927
81928 +#ifdef CONFIG_PAX_SEGMEXEC
81929 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
81930 + break;
81931 +#endif
81932 +
81933 + BUG_ON(vma->vm_end > TASK_SIZE);
81934 newflags = vma->vm_flags | VM_LOCKED;
81935 if (!(flags & MCL_CURRENT))
81936 newflags &= ~VM_LOCKED;
81937 @@ -560,6 +576,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
81938 lock_limit >>= PAGE_SHIFT;
81939
81940 ret = -ENOMEM;
81941 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
81942 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
81943 capable(CAP_IPC_LOCK))
81944 ret = do_mlockall(flags);
81945 diff --git a/mm/mmap.c b/mm/mmap.c
81946 index 90db251..04240d1 100644
81947 --- a/mm/mmap.c
81948 +++ b/mm/mmap.c
81949 @@ -32,6 +32,7 @@
81950 #include <linux/khugepaged.h>
81951 #include <linux/uprobes.h>
81952 #include <linux/rbtree_augmented.h>
81953 +#include <linux/random.h>
81954
81955 #include <asm/uaccess.h>
81956 #include <asm/cacheflush.h>
81957 @@ -48,6 +49,16 @@
81958 #define arch_rebalance_pgtables(addr, len) (addr)
81959 #endif
81960
81961 +static inline void verify_mm_writelocked(struct mm_struct *mm)
81962 +{
81963 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
81964 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
81965 + up_read(&mm->mmap_sem);
81966 + BUG();
81967 + }
81968 +#endif
81969 +}
81970 +
81971 static void unmap_region(struct mm_struct *mm,
81972 struct vm_area_struct *vma, struct vm_area_struct *prev,
81973 unsigned long start, unsigned long end);
81974 @@ -67,22 +78,32 @@ static void unmap_region(struct mm_struct *mm,
81975 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
81976 *
81977 */
81978 -pgprot_t protection_map[16] = {
81979 +pgprot_t protection_map[16] __read_only = {
81980 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
81981 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
81982 };
81983
81984 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
81985 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
81986 {
81987 - return __pgprot(pgprot_val(protection_map[vm_flags &
81988 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
81989 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
81990 pgprot_val(arch_vm_get_page_prot(vm_flags)));
81991 +
81992 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
81993 + if (!(__supported_pte_mask & _PAGE_NX) &&
81994 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
81995 + (vm_flags & (VM_READ | VM_WRITE)))
81996 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
81997 +#endif
81998 +
81999 + return prot;
82000 }
82001 EXPORT_SYMBOL(vm_get_page_prot);
82002
82003 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
82004 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
82005 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
82006 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
82007 /*
82008 * Make sure vm_committed_as in one cacheline and not cacheline shared with
82009 * other variables. It can be updated by several CPUs frequently.
82010 @@ -238,6 +259,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
82011 struct vm_area_struct *next = vma->vm_next;
82012
82013 might_sleep();
82014 + BUG_ON(vma->vm_mirror);
82015 if (vma->vm_ops && vma->vm_ops->close)
82016 vma->vm_ops->close(vma);
82017 if (vma->vm_file)
82018 @@ -281,6 +303,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
82019 * not page aligned -Ram Gupta
82020 */
82021 rlim = rlimit(RLIMIT_DATA);
82022 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
82023 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
82024 (mm->end_data - mm->start_data) > rlim)
82025 goto out;
82026 @@ -888,6 +911,12 @@ static int
82027 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
82028 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82029 {
82030 +
82031 +#ifdef CONFIG_PAX_SEGMEXEC
82032 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82033 + return 0;
82034 +#endif
82035 +
82036 if (is_mergeable_vma(vma, file, vm_flags) &&
82037 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82038 if (vma->vm_pgoff == vm_pgoff)
82039 @@ -907,6 +936,12 @@ static int
82040 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82041 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82042 {
82043 +
82044 +#ifdef CONFIG_PAX_SEGMEXEC
82045 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82046 + return 0;
82047 +#endif
82048 +
82049 if (is_mergeable_vma(vma, file, vm_flags) &&
82050 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82051 pgoff_t vm_pglen;
82052 @@ -949,13 +984,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82053 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82054 struct vm_area_struct *prev, unsigned long addr,
82055 unsigned long end, unsigned long vm_flags,
82056 - struct anon_vma *anon_vma, struct file *file,
82057 + struct anon_vma *anon_vma, struct file *file,
82058 pgoff_t pgoff, struct mempolicy *policy)
82059 {
82060 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82061 struct vm_area_struct *area, *next;
82062 int err;
82063
82064 +#ifdef CONFIG_PAX_SEGMEXEC
82065 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82066 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82067 +
82068 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82069 +#endif
82070 +
82071 /*
82072 * We later require that vma->vm_flags == vm_flags,
82073 * so this tests vma->vm_flags & VM_SPECIAL, too.
82074 @@ -971,6 +1013,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82075 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82076 next = next->vm_next;
82077
82078 +#ifdef CONFIG_PAX_SEGMEXEC
82079 + if (prev)
82080 + prev_m = pax_find_mirror_vma(prev);
82081 + if (area)
82082 + area_m = pax_find_mirror_vma(area);
82083 + if (next)
82084 + next_m = pax_find_mirror_vma(next);
82085 +#endif
82086 +
82087 /*
82088 * Can it merge with the predecessor?
82089 */
82090 @@ -990,9 +1041,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82091 /* cases 1, 6 */
82092 err = vma_adjust(prev, prev->vm_start,
82093 next->vm_end, prev->vm_pgoff, NULL);
82094 - } else /* cases 2, 5, 7 */
82095 +
82096 +#ifdef CONFIG_PAX_SEGMEXEC
82097 + if (!err && prev_m)
82098 + err = vma_adjust(prev_m, prev_m->vm_start,
82099 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82100 +#endif
82101 +
82102 + } else { /* cases 2, 5, 7 */
82103 err = vma_adjust(prev, prev->vm_start,
82104 end, prev->vm_pgoff, NULL);
82105 +
82106 +#ifdef CONFIG_PAX_SEGMEXEC
82107 + if (!err && prev_m)
82108 + err = vma_adjust(prev_m, prev_m->vm_start,
82109 + end_m, prev_m->vm_pgoff, NULL);
82110 +#endif
82111 +
82112 + }
82113 if (err)
82114 return NULL;
82115 khugepaged_enter_vma_merge(prev);
82116 @@ -1006,12 +1072,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82117 mpol_equal(policy, vma_policy(next)) &&
82118 can_vma_merge_before(next, vm_flags,
82119 anon_vma, file, pgoff+pglen)) {
82120 - if (prev && addr < prev->vm_end) /* case 4 */
82121 + if (prev && addr < prev->vm_end) { /* case 4 */
82122 err = vma_adjust(prev, prev->vm_start,
82123 addr, prev->vm_pgoff, NULL);
82124 - else /* cases 3, 8 */
82125 +
82126 +#ifdef CONFIG_PAX_SEGMEXEC
82127 + if (!err && prev_m)
82128 + err = vma_adjust(prev_m, prev_m->vm_start,
82129 + addr_m, prev_m->vm_pgoff, NULL);
82130 +#endif
82131 +
82132 + } else { /* cases 3, 8 */
82133 err = vma_adjust(area, addr, next->vm_end,
82134 next->vm_pgoff - pglen, NULL);
82135 +
82136 +#ifdef CONFIG_PAX_SEGMEXEC
82137 + if (!err && area_m)
82138 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82139 + next_m->vm_pgoff - pglen, NULL);
82140 +#endif
82141 +
82142 + }
82143 if (err)
82144 return NULL;
82145 khugepaged_enter_vma_merge(area);
82146 @@ -1120,8 +1201,10 @@ none:
82147 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82148 struct file *file, long pages)
82149 {
82150 - const unsigned long stack_flags
82151 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82152 +
82153 +#ifdef CONFIG_PAX_RANDMMAP
82154 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82155 +#endif
82156
82157 mm->total_vm += pages;
82158
82159 @@ -1129,7 +1212,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82160 mm->shared_vm += pages;
82161 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82162 mm->exec_vm += pages;
82163 - } else if (flags & stack_flags)
82164 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82165 mm->stack_vm += pages;
82166 }
82167 #endif /* CONFIG_PROC_FS */
82168 @@ -1165,7 +1248,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82169 * (the exception is when the underlying filesystem is noexec
82170 * mounted, in which case we dont add PROT_EXEC.)
82171 */
82172 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82173 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82174 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82175 prot |= PROT_EXEC;
82176
82177 @@ -1191,7 +1274,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82178 /* Obtain the address to map to. we verify (or select) it and ensure
82179 * that it represents a valid section of the address space.
82180 */
82181 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82182 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82183 if (addr & ~PAGE_MASK)
82184 return addr;
82185
82186 @@ -1202,6 +1285,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82187 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82188 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82189
82190 +#ifdef CONFIG_PAX_MPROTECT
82191 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82192 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82193 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82194 + gr_log_rwxmmap(file);
82195 +
82196 +#ifdef CONFIG_PAX_EMUPLT
82197 + vm_flags &= ~VM_EXEC;
82198 +#else
82199 + return -EPERM;
82200 +#endif
82201 +
82202 + }
82203 +
82204 + if (!(vm_flags & VM_EXEC))
82205 + vm_flags &= ~VM_MAYEXEC;
82206 +#else
82207 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82208 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82209 +#endif
82210 + else
82211 + vm_flags &= ~VM_MAYWRITE;
82212 + }
82213 +#endif
82214 +
82215 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82216 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82217 + vm_flags &= ~VM_PAGEEXEC;
82218 +#endif
82219 +
82220 if (flags & MAP_LOCKED)
82221 if (!can_do_mlock())
82222 return -EPERM;
82223 @@ -1213,6 +1326,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82224 locked += mm->locked_vm;
82225 lock_limit = rlimit(RLIMIT_MEMLOCK);
82226 lock_limit >>= PAGE_SHIFT;
82227 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82228 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82229 return -EAGAIN;
82230 }
82231 @@ -1279,6 +1393,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82232 }
82233 }
82234
82235 + if (!gr_acl_handle_mmap(file, prot))
82236 + return -EACCES;
82237 +
82238 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
82239 }
82240
82241 @@ -1356,7 +1473,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82242 vm_flags_t vm_flags = vma->vm_flags;
82243
82244 /* If it was private or non-writable, the write bit is already clear */
82245 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82246 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82247 return 0;
82248
82249 /* The backer wishes to know when pages are first written to? */
82250 @@ -1405,16 +1522,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82251 unsigned long charged = 0;
82252 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
82253
82254 +#ifdef CONFIG_PAX_SEGMEXEC
82255 + struct vm_area_struct *vma_m = NULL;
82256 +#endif
82257 +
82258 + /*
82259 + * mm->mmap_sem is required to protect against another thread
82260 + * changing the mappings in case we sleep.
82261 + */
82262 + verify_mm_writelocked(mm);
82263 +
82264 /* Clear old maps */
82265 error = -ENOMEM;
82266 -munmap_back:
82267 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82268 if (do_munmap(mm, addr, len))
82269 return -ENOMEM;
82270 - goto munmap_back;
82271 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82272 }
82273
82274 /* Check against address space limit. */
82275 +
82276 +#ifdef CONFIG_PAX_RANDMMAP
82277 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82278 +#endif
82279 +
82280 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82281 return -ENOMEM;
82282
82283 @@ -1460,6 +1591,16 @@ munmap_back:
82284 goto unacct_error;
82285 }
82286
82287 +#ifdef CONFIG_PAX_SEGMEXEC
82288 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82289 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82290 + if (!vma_m) {
82291 + error = -ENOMEM;
82292 + goto free_vma;
82293 + }
82294 + }
82295 +#endif
82296 +
82297 vma->vm_mm = mm;
82298 vma->vm_start = addr;
82299 vma->vm_end = addr + len;
82300 @@ -1484,6 +1625,13 @@ munmap_back:
82301 if (error)
82302 goto unmap_and_free_vma;
82303
82304 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82305 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82306 + vma->vm_flags |= VM_PAGEEXEC;
82307 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82308 + }
82309 +#endif
82310 +
82311 /* Can addr have changed??
82312 *
82313 * Answer: Yes, several device drivers can do it in their
82314 @@ -1522,6 +1670,11 @@ munmap_back:
82315 vma_link(mm, vma, prev, rb_link, rb_parent);
82316 file = vma->vm_file;
82317
82318 +#ifdef CONFIG_PAX_SEGMEXEC
82319 + if (vma_m)
82320 + BUG_ON(pax_mirror_vma(vma_m, vma));
82321 +#endif
82322 +
82323 /* Once vma denies write, undo our temporary denial count */
82324 if (correct_wcount)
82325 atomic_inc(&inode->i_writecount);
82326 @@ -1529,6 +1682,7 @@ out:
82327 perf_event_mmap(vma);
82328
82329 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82330 + track_exec_limit(mm, addr, addr + len, vm_flags);
82331 if (vm_flags & VM_LOCKED) {
82332 if (!mlock_vma_pages_range(vma, addr, addr + len))
82333 mm->locked_vm += (len >> PAGE_SHIFT);
82334 @@ -1550,6 +1704,12 @@ unmap_and_free_vma:
82335 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82336 charged = 0;
82337 free_vma:
82338 +
82339 +#ifdef CONFIG_PAX_SEGMEXEC
82340 + if (vma_m)
82341 + kmem_cache_free(vm_area_cachep, vma_m);
82342 +#endif
82343 +
82344 kmem_cache_free(vm_area_cachep, vma);
82345 unacct_error:
82346 if (charged)
82347 @@ -1557,6 +1717,62 @@ unacct_error:
82348 return error;
82349 }
82350
82351 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82352 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82353 +{
82354 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82355 + return (random32() & 0xFF) << PAGE_SHIFT;
82356 +
82357 + return 0;
82358 +}
82359 +#endif
82360 +
82361 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82362 +{
82363 + if (!vma) {
82364 +#ifdef CONFIG_STACK_GROWSUP
82365 + if (addr > sysctl_heap_stack_gap)
82366 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82367 + else
82368 + vma = find_vma(current->mm, 0);
82369 + if (vma && (vma->vm_flags & VM_GROWSUP))
82370 + return false;
82371 +#endif
82372 + return true;
82373 + }
82374 +
82375 + if (addr + len > vma->vm_start)
82376 + return false;
82377 +
82378 + if (vma->vm_flags & VM_GROWSDOWN)
82379 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82380 +#ifdef CONFIG_STACK_GROWSUP
82381 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82382 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82383 +#endif
82384 + else if (offset)
82385 + return offset <= vma->vm_start - addr - len;
82386 +
82387 + return true;
82388 +}
82389 +
82390 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82391 +{
82392 + if (vma->vm_start < len)
82393 + return -ENOMEM;
82394 +
82395 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82396 + if (offset <= vma->vm_start - len)
82397 + return vma->vm_start - len - offset;
82398 + else
82399 + return -ENOMEM;
82400 + }
82401 +
82402 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82403 + return vma->vm_start - len - sysctl_heap_stack_gap;
82404 + return -ENOMEM;
82405 +}
82406 +
82407 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82408 {
82409 /*
82410 @@ -1776,6 +1992,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82411 struct mm_struct *mm = current->mm;
82412 struct vm_area_struct *vma;
82413 struct vm_unmapped_area_info info;
82414 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82415
82416 if (len > TASK_SIZE)
82417 return -ENOMEM;
82418 @@ -1783,17 +2000,26 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82419 if (flags & MAP_FIXED)
82420 return addr;
82421
82422 +#ifdef CONFIG_PAX_RANDMMAP
82423 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82424 +#endif
82425 +
82426 if (addr) {
82427 addr = PAGE_ALIGN(addr);
82428 vma = find_vma(mm, addr);
82429 - if (TASK_SIZE - len >= addr &&
82430 - (!vma || addr + len <= vma->vm_start))
82431 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82432 return addr;
82433 }
82434
82435 info.flags = 0;
82436 info.length = len;
82437 info.low_limit = TASK_UNMAPPED_BASE;
82438 +
82439 +#ifdef CONFIG_PAX_RANDMMAP
82440 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82441 + info.low_limit += mm->delta_mmap;
82442 +#endif
82443 +
82444 info.high_limit = TASK_SIZE;
82445 info.align_mask = 0;
82446 return vm_unmapped_area(&info);
82447 @@ -1802,10 +2028,16 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82448
82449 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82450 {
82451 +
82452 +#ifdef CONFIG_PAX_SEGMEXEC
82453 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82454 + return;
82455 +#endif
82456 +
82457 /*
82458 * Is this a new hole at the lowest possible address?
82459 */
82460 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82461 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82462 mm->free_area_cache = addr;
82463 }
82464
82465 @@ -1823,6 +2055,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82466 struct mm_struct *mm = current->mm;
82467 unsigned long addr = addr0;
82468 struct vm_unmapped_area_info info;
82469 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82470
82471 /* requested length too big for entire address space */
82472 if (len > TASK_SIZE)
82473 @@ -1831,12 +2064,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82474 if (flags & MAP_FIXED)
82475 return addr;
82476
82477 +#ifdef CONFIG_PAX_RANDMMAP
82478 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82479 +#endif
82480 +
82481 /* requesting a specific address */
82482 if (addr) {
82483 addr = PAGE_ALIGN(addr);
82484 vma = find_vma(mm, addr);
82485 - if (TASK_SIZE - len >= addr &&
82486 - (!vma || addr + len <= vma->vm_start))
82487 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82488 return addr;
82489 }
82490
82491 @@ -1857,6 +2093,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82492 VM_BUG_ON(addr != -ENOMEM);
82493 info.flags = 0;
82494 info.low_limit = TASK_UNMAPPED_BASE;
82495 +
82496 +#ifdef CONFIG_PAX_RANDMMAP
82497 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82498 + info.low_limit += mm->delta_mmap;
82499 +#endif
82500 +
82501 info.high_limit = TASK_SIZE;
82502 addr = vm_unmapped_area(&info);
82503 }
82504 @@ -1867,6 +2109,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82505
82506 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82507 {
82508 +
82509 +#ifdef CONFIG_PAX_SEGMEXEC
82510 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82511 + return;
82512 +#endif
82513 +
82514 /*
82515 * Is this a new hole at the highest possible address?
82516 */
82517 @@ -1874,8 +2122,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82518 mm->free_area_cache = addr;
82519
82520 /* dont allow allocations above current base */
82521 - if (mm->free_area_cache > mm->mmap_base)
82522 + if (mm->free_area_cache > mm->mmap_base) {
82523 mm->free_area_cache = mm->mmap_base;
82524 + mm->cached_hole_size = ~0UL;
82525 + }
82526 }
82527
82528 unsigned long
82529 @@ -1974,6 +2224,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82530 return vma;
82531 }
82532
82533 +#ifdef CONFIG_PAX_SEGMEXEC
82534 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82535 +{
82536 + struct vm_area_struct *vma_m;
82537 +
82538 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82539 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82540 + BUG_ON(vma->vm_mirror);
82541 + return NULL;
82542 + }
82543 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82544 + vma_m = vma->vm_mirror;
82545 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82546 + BUG_ON(vma->vm_file != vma_m->vm_file);
82547 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82548 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82549 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82550 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82551 + return vma_m;
82552 +}
82553 +#endif
82554 +
82555 /*
82556 * Verify that the stack growth is acceptable and
82557 * update accounting. This is shared with both the
82558 @@ -1990,6 +2262,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82559 return -ENOMEM;
82560
82561 /* Stack limit test */
82562 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82563 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82564 return -ENOMEM;
82565
82566 @@ -2000,6 +2273,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82567 locked = mm->locked_vm + grow;
82568 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82569 limit >>= PAGE_SHIFT;
82570 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82571 if (locked > limit && !capable(CAP_IPC_LOCK))
82572 return -ENOMEM;
82573 }
82574 @@ -2029,37 +2303,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82575 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82576 * vma is the last one with address > vma->vm_end. Have to extend vma.
82577 */
82578 +#ifndef CONFIG_IA64
82579 +static
82580 +#endif
82581 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82582 {
82583 int error;
82584 + bool locknext;
82585
82586 if (!(vma->vm_flags & VM_GROWSUP))
82587 return -EFAULT;
82588
82589 + /* Also guard against wrapping around to address 0. */
82590 + if (address < PAGE_ALIGN(address+1))
82591 + address = PAGE_ALIGN(address+1);
82592 + else
82593 + return -ENOMEM;
82594 +
82595 /*
82596 * We must make sure the anon_vma is allocated
82597 * so that the anon_vma locking is not a noop.
82598 */
82599 if (unlikely(anon_vma_prepare(vma)))
82600 return -ENOMEM;
82601 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82602 + if (locknext && anon_vma_prepare(vma->vm_next))
82603 + return -ENOMEM;
82604 vma_lock_anon_vma(vma);
82605 + if (locknext)
82606 + vma_lock_anon_vma(vma->vm_next);
82607
82608 /*
82609 * vma->vm_start/vm_end cannot change under us because the caller
82610 * is required to hold the mmap_sem in read mode. We need the
82611 - * anon_vma lock to serialize against concurrent expand_stacks.
82612 - * Also guard against wrapping around to address 0.
82613 + * anon_vma locks to serialize against concurrent expand_stacks
82614 + * and expand_upwards.
82615 */
82616 - if (address < PAGE_ALIGN(address+4))
82617 - address = PAGE_ALIGN(address+4);
82618 - else {
82619 - vma_unlock_anon_vma(vma);
82620 - return -ENOMEM;
82621 - }
82622 error = 0;
82623
82624 /* Somebody else might have raced and expanded it already */
82625 - if (address > vma->vm_end) {
82626 + 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)
82627 + error = -ENOMEM;
82628 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82629 unsigned long size, grow;
82630
82631 size = address - vma->vm_start;
82632 @@ -2094,6 +2379,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82633 }
82634 }
82635 }
82636 + if (locknext)
82637 + vma_unlock_anon_vma(vma->vm_next);
82638 vma_unlock_anon_vma(vma);
82639 khugepaged_enter_vma_merge(vma);
82640 validate_mm(vma->vm_mm);
82641 @@ -2108,6 +2395,8 @@ int expand_downwards(struct vm_area_struct *vma,
82642 unsigned long address)
82643 {
82644 int error;
82645 + bool lockprev = false;
82646 + struct vm_area_struct *prev;
82647
82648 /*
82649 * We must make sure the anon_vma is allocated
82650 @@ -2121,6 +2410,15 @@ int expand_downwards(struct vm_area_struct *vma,
82651 if (error)
82652 return error;
82653
82654 + prev = vma->vm_prev;
82655 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82656 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82657 +#endif
82658 + if (lockprev && anon_vma_prepare(prev))
82659 + return -ENOMEM;
82660 + if (lockprev)
82661 + vma_lock_anon_vma(prev);
82662 +
82663 vma_lock_anon_vma(vma);
82664
82665 /*
82666 @@ -2130,9 +2428,17 @@ int expand_downwards(struct vm_area_struct *vma,
82667 */
82668
82669 /* Somebody else might have raced and expanded it already */
82670 - if (address < vma->vm_start) {
82671 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
82672 + error = -ENOMEM;
82673 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
82674 unsigned long size, grow;
82675
82676 +#ifdef CONFIG_PAX_SEGMEXEC
82677 + struct vm_area_struct *vma_m;
82678 +
82679 + vma_m = pax_find_mirror_vma(vma);
82680 +#endif
82681 +
82682 size = vma->vm_end - address;
82683 grow = (vma->vm_start - address) >> PAGE_SHIFT;
82684
82685 @@ -2157,6 +2463,18 @@ int expand_downwards(struct vm_area_struct *vma,
82686 vma->vm_pgoff -= grow;
82687 anon_vma_interval_tree_post_update_vma(vma);
82688 vma_gap_update(vma);
82689 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
82690 +
82691 +#ifdef CONFIG_PAX_SEGMEXEC
82692 + if (vma_m) {
82693 + anon_vma_interval_tree_pre_update_vma(vma_m);
82694 + vma_m->vm_start -= grow << PAGE_SHIFT;
82695 + vma_m->vm_pgoff -= grow;
82696 + anon_vma_interval_tree_post_update_vma(vma_m);
82697 + vma_gap_update(vma_m);
82698 + }
82699 +#endif
82700 +
82701 spin_unlock(&vma->vm_mm->page_table_lock);
82702
82703 perf_event_mmap(vma);
82704 @@ -2263,6 +2581,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
82705 do {
82706 long nrpages = vma_pages(vma);
82707
82708 +#ifdef CONFIG_PAX_SEGMEXEC
82709 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
82710 + vma = remove_vma(vma);
82711 + continue;
82712 + }
82713 +#endif
82714 +
82715 if (vma->vm_flags & VM_ACCOUNT)
82716 nr_accounted += nrpages;
82717 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
82718 @@ -2308,6 +2633,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
82719 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
82720 vma->vm_prev = NULL;
82721 do {
82722 +
82723 +#ifdef CONFIG_PAX_SEGMEXEC
82724 + if (vma->vm_mirror) {
82725 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
82726 + vma->vm_mirror->vm_mirror = NULL;
82727 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
82728 + vma->vm_mirror = NULL;
82729 + }
82730 +#endif
82731 +
82732 vma_rb_erase(vma, &mm->mm_rb);
82733 mm->map_count--;
82734 tail_vma = vma;
82735 @@ -2339,14 +2674,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82736 struct vm_area_struct *new;
82737 int err = -ENOMEM;
82738
82739 +#ifdef CONFIG_PAX_SEGMEXEC
82740 + struct vm_area_struct *vma_m, *new_m = NULL;
82741 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
82742 +#endif
82743 +
82744 if (is_vm_hugetlb_page(vma) && (addr &
82745 ~(huge_page_mask(hstate_vma(vma)))))
82746 return -EINVAL;
82747
82748 +#ifdef CONFIG_PAX_SEGMEXEC
82749 + vma_m = pax_find_mirror_vma(vma);
82750 +#endif
82751 +
82752 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82753 if (!new)
82754 goto out_err;
82755
82756 +#ifdef CONFIG_PAX_SEGMEXEC
82757 + if (vma_m) {
82758 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82759 + if (!new_m) {
82760 + kmem_cache_free(vm_area_cachep, new);
82761 + goto out_err;
82762 + }
82763 + }
82764 +#endif
82765 +
82766 /* most fields are the same, copy all, and then fixup */
82767 *new = *vma;
82768
82769 @@ -2359,6 +2713,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82770 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
82771 }
82772
82773 +#ifdef CONFIG_PAX_SEGMEXEC
82774 + if (vma_m) {
82775 + *new_m = *vma_m;
82776 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
82777 + new_m->vm_mirror = new;
82778 + new->vm_mirror = new_m;
82779 +
82780 + if (new_below)
82781 + new_m->vm_end = addr_m;
82782 + else {
82783 + new_m->vm_start = addr_m;
82784 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
82785 + }
82786 + }
82787 +#endif
82788 +
82789 pol = mpol_dup(vma_policy(vma));
82790 if (IS_ERR(pol)) {
82791 err = PTR_ERR(pol);
82792 @@ -2381,6 +2751,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82793 else
82794 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
82795
82796 +#ifdef CONFIG_PAX_SEGMEXEC
82797 + if (!err && vma_m) {
82798 + if (anon_vma_clone(new_m, vma_m))
82799 + goto out_free_mpol;
82800 +
82801 + mpol_get(pol);
82802 + vma_set_policy(new_m, pol);
82803 +
82804 + if (new_m->vm_file)
82805 + get_file(new_m->vm_file);
82806 +
82807 + if (new_m->vm_ops && new_m->vm_ops->open)
82808 + new_m->vm_ops->open(new_m);
82809 +
82810 + if (new_below)
82811 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
82812 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
82813 + else
82814 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
82815 +
82816 + if (err) {
82817 + if (new_m->vm_ops && new_m->vm_ops->close)
82818 + new_m->vm_ops->close(new_m);
82819 + if (new_m->vm_file)
82820 + fput(new_m->vm_file);
82821 + mpol_put(pol);
82822 + }
82823 + }
82824 +#endif
82825 +
82826 /* Success. */
82827 if (!err)
82828 return 0;
82829 @@ -2390,10 +2790,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82830 new->vm_ops->close(new);
82831 if (new->vm_file)
82832 fput(new->vm_file);
82833 - unlink_anon_vmas(new);
82834 out_free_mpol:
82835 mpol_put(pol);
82836 out_free_vma:
82837 +
82838 +#ifdef CONFIG_PAX_SEGMEXEC
82839 + if (new_m) {
82840 + unlink_anon_vmas(new_m);
82841 + kmem_cache_free(vm_area_cachep, new_m);
82842 + }
82843 +#endif
82844 +
82845 + unlink_anon_vmas(new);
82846 kmem_cache_free(vm_area_cachep, new);
82847 out_err:
82848 return err;
82849 @@ -2406,6 +2814,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82850 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82851 unsigned long addr, int new_below)
82852 {
82853 +
82854 +#ifdef CONFIG_PAX_SEGMEXEC
82855 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82856 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
82857 + if (mm->map_count >= sysctl_max_map_count-1)
82858 + return -ENOMEM;
82859 + } else
82860 +#endif
82861 +
82862 if (mm->map_count >= sysctl_max_map_count)
82863 return -ENOMEM;
82864
82865 @@ -2417,11 +2834,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82866 * work. This now handles partial unmappings.
82867 * Jeremy Fitzhardinge <jeremy@goop.org>
82868 */
82869 +#ifdef CONFIG_PAX_SEGMEXEC
82870 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82871 {
82872 + int ret = __do_munmap(mm, start, len);
82873 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
82874 + return ret;
82875 +
82876 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
82877 +}
82878 +
82879 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82880 +#else
82881 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82882 +#endif
82883 +{
82884 unsigned long end;
82885 struct vm_area_struct *vma, *prev, *last;
82886
82887 + /*
82888 + * mm->mmap_sem is required to protect against another thread
82889 + * changing the mappings in case we sleep.
82890 + */
82891 + verify_mm_writelocked(mm);
82892 +
82893 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
82894 return -EINVAL;
82895
82896 @@ -2496,6 +2932,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82897 /* Fix up all other VM information */
82898 remove_vma_list(mm, vma);
82899
82900 + track_exec_limit(mm, start, end, 0UL);
82901 +
82902 return 0;
82903 }
82904
82905 @@ -2504,6 +2942,13 @@ int vm_munmap(unsigned long start, size_t len)
82906 int ret;
82907 struct mm_struct *mm = current->mm;
82908
82909 +
82910 +#ifdef CONFIG_PAX_SEGMEXEC
82911 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
82912 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
82913 + return -EINVAL;
82914 +#endif
82915 +
82916 down_write(&mm->mmap_sem);
82917 ret = do_munmap(mm, start, len);
82918 up_write(&mm->mmap_sem);
82919 @@ -2517,16 +2962,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
82920 return vm_munmap(addr, len);
82921 }
82922
82923 -static inline void verify_mm_writelocked(struct mm_struct *mm)
82924 -{
82925 -#ifdef CONFIG_DEBUG_VM
82926 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82927 - WARN_ON(1);
82928 - up_read(&mm->mmap_sem);
82929 - }
82930 -#endif
82931 -}
82932 -
82933 /*
82934 * this is really a simplified "do_mmap". it only handles
82935 * anonymous maps. eventually we may be able to do some
82936 @@ -2540,6 +2975,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82937 struct rb_node ** rb_link, * rb_parent;
82938 pgoff_t pgoff = addr >> PAGE_SHIFT;
82939 int error;
82940 + unsigned long charged;
82941
82942 len = PAGE_ALIGN(len);
82943 if (!len)
82944 @@ -2547,16 +2983,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82945
82946 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
82947
82948 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
82949 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
82950 + flags &= ~VM_EXEC;
82951 +
82952 +#ifdef CONFIG_PAX_MPROTECT
82953 + if (mm->pax_flags & MF_PAX_MPROTECT)
82954 + flags &= ~VM_MAYEXEC;
82955 +#endif
82956 +
82957 + }
82958 +#endif
82959 +
82960 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
82961 if (error & ~PAGE_MASK)
82962 return error;
82963
82964 + charged = len >> PAGE_SHIFT;
82965 +
82966 /*
82967 * mlock MCL_FUTURE?
82968 */
82969 if (mm->def_flags & VM_LOCKED) {
82970 unsigned long locked, lock_limit;
82971 - locked = len >> PAGE_SHIFT;
82972 + locked = charged;
82973 locked += mm->locked_vm;
82974 lock_limit = rlimit(RLIMIT_MEMLOCK);
82975 lock_limit >>= PAGE_SHIFT;
82976 @@ -2573,21 +3023,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
82977 /*
82978 * Clear old maps. this also does some error checking for us
82979 */
82980 - munmap_back:
82981 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82982 if (do_munmap(mm, addr, len))
82983 return -ENOMEM;
82984 - goto munmap_back;
82985 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82986 }
82987
82988 /* Check against address space limits *after* clearing old maps... */
82989 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82990 + if (!may_expand_vm(mm, charged))
82991 return -ENOMEM;
82992
82993 if (mm->map_count > sysctl_max_map_count)
82994 return -ENOMEM;
82995
82996 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
82997 + if (security_vm_enough_memory_mm(mm, charged))
82998 return -ENOMEM;
82999
83000 /* Can we just expand an old private anonymous mapping? */
83001 @@ -2601,7 +3050,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83002 */
83003 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83004 if (!vma) {
83005 - vm_unacct_memory(len >> PAGE_SHIFT);
83006 + vm_unacct_memory(charged);
83007 return -ENOMEM;
83008 }
83009
83010 @@ -2615,11 +3064,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83011 vma_link(mm, vma, prev, rb_link, rb_parent);
83012 out:
83013 perf_event_mmap(vma);
83014 - mm->total_vm += len >> PAGE_SHIFT;
83015 + mm->total_vm += charged;
83016 if (flags & VM_LOCKED) {
83017 if (!mlock_vma_pages_range(vma, addr, addr + len))
83018 - mm->locked_vm += (len >> PAGE_SHIFT);
83019 + mm->locked_vm += charged;
83020 }
83021 + track_exec_limit(mm, addr, addr + len, flags);
83022 return addr;
83023 }
83024
83025 @@ -2677,6 +3127,7 @@ void exit_mmap(struct mm_struct *mm)
83026 while (vma) {
83027 if (vma->vm_flags & VM_ACCOUNT)
83028 nr_accounted += vma_pages(vma);
83029 + vma->vm_mirror = NULL;
83030 vma = remove_vma(vma);
83031 }
83032 vm_unacct_memory(nr_accounted);
83033 @@ -2693,6 +3144,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83034 struct vm_area_struct *prev;
83035 struct rb_node **rb_link, *rb_parent;
83036
83037 +#ifdef CONFIG_PAX_SEGMEXEC
83038 + struct vm_area_struct *vma_m = NULL;
83039 +#endif
83040 +
83041 + if (security_mmap_addr(vma->vm_start))
83042 + return -EPERM;
83043 +
83044 /*
83045 * The vm_pgoff of a purely anonymous vma should be irrelevant
83046 * until its first write fault, when page's anon_vma and index
83047 @@ -2716,7 +3174,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83048 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83049 return -ENOMEM;
83050
83051 +#ifdef CONFIG_PAX_SEGMEXEC
83052 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83053 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83054 + if (!vma_m)
83055 + return -ENOMEM;
83056 + }
83057 +#endif
83058 +
83059 vma_link(mm, vma, prev, rb_link, rb_parent);
83060 +
83061 +#ifdef CONFIG_PAX_SEGMEXEC
83062 + if (vma_m)
83063 + BUG_ON(pax_mirror_vma(vma_m, vma));
83064 +#endif
83065 +
83066 return 0;
83067 }
83068
83069 @@ -2736,6 +3208,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83070 struct mempolicy *pol;
83071 bool faulted_in_anon_vma = true;
83072
83073 + BUG_ON(vma->vm_mirror);
83074 +
83075 /*
83076 * If anonymous vma has not yet been faulted, update new pgoff
83077 * to match new location, to increase its chance of merging.
83078 @@ -2802,6 +3276,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83079 return NULL;
83080 }
83081
83082 +#ifdef CONFIG_PAX_SEGMEXEC
83083 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83084 +{
83085 + struct vm_area_struct *prev_m;
83086 + struct rb_node **rb_link_m, *rb_parent_m;
83087 + struct mempolicy *pol_m;
83088 +
83089 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83090 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83091 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83092 + *vma_m = *vma;
83093 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83094 + if (anon_vma_clone(vma_m, vma))
83095 + return -ENOMEM;
83096 + pol_m = vma_policy(vma_m);
83097 + mpol_get(pol_m);
83098 + vma_set_policy(vma_m, pol_m);
83099 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83100 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83101 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83102 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83103 + if (vma_m->vm_file)
83104 + get_file(vma_m->vm_file);
83105 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83106 + vma_m->vm_ops->open(vma_m);
83107 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83108 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83109 + vma_m->vm_mirror = vma;
83110 + vma->vm_mirror = vma_m;
83111 + return 0;
83112 +}
83113 +#endif
83114 +
83115 /*
83116 * Return true if the calling process may expand its vm space by the passed
83117 * number of pages
83118 @@ -2813,6 +3320,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83119
83120 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83121
83122 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83123 if (cur + npages > lim)
83124 return 0;
83125 return 1;
83126 @@ -2883,6 +3391,22 @@ int install_special_mapping(struct mm_struct *mm,
83127 vma->vm_start = addr;
83128 vma->vm_end = addr + len;
83129
83130 +#ifdef CONFIG_PAX_MPROTECT
83131 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83132 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83133 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83134 + return -EPERM;
83135 + if (!(vm_flags & VM_EXEC))
83136 + vm_flags &= ~VM_MAYEXEC;
83137 +#else
83138 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83139 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83140 +#endif
83141 + else
83142 + vm_flags &= ~VM_MAYWRITE;
83143 + }
83144 +#endif
83145 +
83146 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83147 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83148
83149 diff --git a/mm/mprotect.c b/mm/mprotect.c
83150 index 94722a4..9837984 100644
83151 --- a/mm/mprotect.c
83152 +++ b/mm/mprotect.c
83153 @@ -23,10 +23,17 @@
83154 #include <linux/mmu_notifier.h>
83155 #include <linux/migrate.h>
83156 #include <linux/perf_event.h>
83157 +
83158 +#ifdef CONFIG_PAX_MPROTECT
83159 +#include <linux/elf.h>
83160 +#include <linux/binfmts.h>
83161 +#endif
83162 +
83163 #include <asm/uaccess.h>
83164 #include <asm/pgtable.h>
83165 #include <asm/cacheflush.h>
83166 #include <asm/tlbflush.h>
83167 +#include <asm/mmu_context.h>
83168
83169 #ifndef pgprot_modify
83170 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83171 @@ -233,6 +240,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83172 return pages;
83173 }
83174
83175 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83176 +/* called while holding the mmap semaphor for writing except stack expansion */
83177 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83178 +{
83179 + unsigned long oldlimit, newlimit = 0UL;
83180 +
83181 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83182 + return;
83183 +
83184 + spin_lock(&mm->page_table_lock);
83185 + oldlimit = mm->context.user_cs_limit;
83186 + if ((prot & VM_EXEC) && oldlimit < end)
83187 + /* USER_CS limit moved up */
83188 + newlimit = end;
83189 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83190 + /* USER_CS limit moved down */
83191 + newlimit = start;
83192 +
83193 + if (newlimit) {
83194 + mm->context.user_cs_limit = newlimit;
83195 +
83196 +#ifdef CONFIG_SMP
83197 + wmb();
83198 + cpus_clear(mm->context.cpu_user_cs_mask);
83199 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83200 +#endif
83201 +
83202 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83203 + }
83204 + spin_unlock(&mm->page_table_lock);
83205 + if (newlimit == end) {
83206 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83207 +
83208 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83209 + if (is_vm_hugetlb_page(vma))
83210 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83211 + else
83212 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83213 + }
83214 +}
83215 +#endif
83216 +
83217 int
83218 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83219 unsigned long start, unsigned long end, unsigned long newflags)
83220 @@ -245,11 +294,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83221 int error;
83222 int dirty_accountable = 0;
83223
83224 +#ifdef CONFIG_PAX_SEGMEXEC
83225 + struct vm_area_struct *vma_m = NULL;
83226 + unsigned long start_m, end_m;
83227 +
83228 + start_m = start + SEGMEXEC_TASK_SIZE;
83229 + end_m = end + SEGMEXEC_TASK_SIZE;
83230 +#endif
83231 +
83232 if (newflags == oldflags) {
83233 *pprev = vma;
83234 return 0;
83235 }
83236
83237 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83238 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83239 +
83240 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83241 + return -ENOMEM;
83242 +
83243 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83244 + return -ENOMEM;
83245 + }
83246 +
83247 /*
83248 * If we make a private mapping writable we increase our commit;
83249 * but (without finer accounting) cannot reduce our commit if we
83250 @@ -266,6 +333,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83251 }
83252 }
83253
83254 +#ifdef CONFIG_PAX_SEGMEXEC
83255 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83256 + if (start != vma->vm_start) {
83257 + error = split_vma(mm, vma, start, 1);
83258 + if (error)
83259 + goto fail;
83260 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83261 + *pprev = (*pprev)->vm_next;
83262 + }
83263 +
83264 + if (end != vma->vm_end) {
83265 + error = split_vma(mm, vma, end, 0);
83266 + if (error)
83267 + goto fail;
83268 + }
83269 +
83270 + if (pax_find_mirror_vma(vma)) {
83271 + error = __do_munmap(mm, start_m, end_m - start_m);
83272 + if (error)
83273 + goto fail;
83274 + } else {
83275 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83276 + if (!vma_m) {
83277 + error = -ENOMEM;
83278 + goto fail;
83279 + }
83280 + vma->vm_flags = newflags;
83281 + error = pax_mirror_vma(vma_m, vma);
83282 + if (error) {
83283 + vma->vm_flags = oldflags;
83284 + goto fail;
83285 + }
83286 + }
83287 + }
83288 +#endif
83289 +
83290 /*
83291 * First try to merge with previous and/or next vma.
83292 */
83293 @@ -296,9 +399,21 @@ success:
83294 * vm_flags and vm_page_prot are protected by the mmap_sem
83295 * held in write mode.
83296 */
83297 +
83298 +#ifdef CONFIG_PAX_SEGMEXEC
83299 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83300 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83301 +#endif
83302 +
83303 vma->vm_flags = newflags;
83304 +
83305 +#ifdef CONFIG_PAX_MPROTECT
83306 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83307 + mm->binfmt->handle_mprotect(vma, newflags);
83308 +#endif
83309 +
83310 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83311 - vm_get_page_prot(newflags));
83312 + vm_get_page_prot(vma->vm_flags));
83313
83314 if (vma_wants_writenotify(vma)) {
83315 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83316 @@ -337,6 +452,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83317 end = start + len;
83318 if (end <= start)
83319 return -ENOMEM;
83320 +
83321 +#ifdef CONFIG_PAX_SEGMEXEC
83322 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83323 + if (end > SEGMEXEC_TASK_SIZE)
83324 + return -EINVAL;
83325 + } else
83326 +#endif
83327 +
83328 + if (end > TASK_SIZE)
83329 + return -EINVAL;
83330 +
83331 if (!arch_validate_prot(prot))
83332 return -EINVAL;
83333
83334 @@ -344,7 +470,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83335 /*
83336 * Does the application expect PROT_READ to imply PROT_EXEC:
83337 */
83338 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83339 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83340 prot |= PROT_EXEC;
83341
83342 vm_flags = calc_vm_prot_bits(prot);
83343 @@ -376,6 +502,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83344 if (start > vma->vm_start)
83345 prev = vma;
83346
83347 +#ifdef CONFIG_PAX_MPROTECT
83348 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83349 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83350 +#endif
83351 +
83352 for (nstart = start ; ; ) {
83353 unsigned long newflags;
83354
83355 @@ -386,6 +517,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83356
83357 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83358 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83359 + if (prot & (PROT_WRITE | PROT_EXEC))
83360 + gr_log_rwxmprotect(vma->vm_file);
83361 +
83362 + error = -EACCES;
83363 + goto out;
83364 + }
83365 +
83366 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83367 error = -EACCES;
83368 goto out;
83369 }
83370 @@ -400,6 +539,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83371 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83372 if (error)
83373 goto out;
83374 +
83375 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83376 +
83377 nstart = tmp;
83378
83379 if (nstart < prev->vm_end)
83380 diff --git a/mm/mremap.c b/mm/mremap.c
83381 index e1031e1..1f2a0a1 100644
83382 --- a/mm/mremap.c
83383 +++ b/mm/mremap.c
83384 @@ -125,6 +125,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83385 continue;
83386 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83387 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83388 +
83389 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83390 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83391 + pte = pte_exprotect(pte);
83392 +#endif
83393 +
83394 set_pte_at(mm, new_addr, new_pte, pte);
83395 }
83396
83397 @@ -319,6 +325,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83398 if (is_vm_hugetlb_page(vma))
83399 goto Einval;
83400
83401 +#ifdef CONFIG_PAX_SEGMEXEC
83402 + if (pax_find_mirror_vma(vma))
83403 + goto Einval;
83404 +#endif
83405 +
83406 /* We can't remap across vm area boundaries */
83407 if (old_len > vma->vm_end - addr)
83408 goto Efault;
83409 @@ -375,20 +386,25 @@ static unsigned long mremap_to(unsigned long addr,
83410 unsigned long ret = -EINVAL;
83411 unsigned long charged = 0;
83412 unsigned long map_flags;
83413 + unsigned long pax_task_size = TASK_SIZE;
83414
83415 if (new_addr & ~PAGE_MASK)
83416 goto out;
83417
83418 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83419 +#ifdef CONFIG_PAX_SEGMEXEC
83420 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83421 + pax_task_size = SEGMEXEC_TASK_SIZE;
83422 +#endif
83423 +
83424 + pax_task_size -= PAGE_SIZE;
83425 +
83426 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83427 goto out;
83428
83429 /* Check if the location we're moving into overlaps the
83430 * old location at all, and fail if it does.
83431 */
83432 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83433 - goto out;
83434 -
83435 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83436 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83437 goto out;
83438
83439 ret = do_munmap(mm, new_addr, new_len);
83440 @@ -456,6 +472,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83441 struct vm_area_struct *vma;
83442 unsigned long ret = -EINVAL;
83443 unsigned long charged = 0;
83444 + unsigned long pax_task_size = TASK_SIZE;
83445
83446 down_write(&current->mm->mmap_sem);
83447
83448 @@ -476,6 +493,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83449 if (!new_len)
83450 goto out;
83451
83452 +#ifdef CONFIG_PAX_SEGMEXEC
83453 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83454 + pax_task_size = SEGMEXEC_TASK_SIZE;
83455 +#endif
83456 +
83457 + pax_task_size -= PAGE_SIZE;
83458 +
83459 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83460 + old_len > pax_task_size || addr > pax_task_size-old_len)
83461 + goto out;
83462 +
83463 if (flags & MREMAP_FIXED) {
83464 if (flags & MREMAP_MAYMOVE)
83465 ret = mremap_to(addr, old_len, new_addr, new_len);
83466 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83467 addr + new_len);
83468 }
83469 ret = addr;
83470 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83471 goto out;
83472 }
83473 }
83474 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83475 goto out;
83476 }
83477
83478 + map_flags = vma->vm_flags;
83479 ret = move_vma(vma, addr, old_len, new_len, new_addr);
83480 + if (!(ret & ~PAGE_MASK)) {
83481 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83482 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83483 + }
83484 }
83485 out:
83486 if (ret & ~PAGE_MASK)
83487 diff --git a/mm/nommu.c b/mm/nommu.c
83488 index bbe1f3f..b2601ea 100644
83489 --- a/mm/nommu.c
83490 +++ b/mm/nommu.c
83491 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83492 int sysctl_overcommit_ratio = 50; /* default is 50% */
83493 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83494 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83495 -int heap_stack_gap = 0;
83496
83497 atomic_long_t mmap_pages_allocated;
83498
83499 @@ -839,15 +838,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83500 EXPORT_SYMBOL(find_vma);
83501
83502 /*
83503 - * find a VMA
83504 - * - we don't extend stack VMAs under NOMMU conditions
83505 - */
83506 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
83507 -{
83508 - return find_vma(mm, addr);
83509 -}
83510 -
83511 -/*
83512 * expand a stack to a given address
83513 * - not supported under NOMMU conditions
83514 */
83515 @@ -1555,6 +1545,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83516
83517 /* most fields are the same, copy all, and then fixup */
83518 *new = *vma;
83519 + INIT_LIST_HEAD(&new->anon_vma_chain);
83520 *region = *vma->vm_region;
83521 new->vm_region = region;
83522
83523 @@ -1975,8 +1966,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
83524 }
83525 EXPORT_SYMBOL(generic_file_remap_pages);
83526
83527 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83528 - unsigned long addr, void *buf, int len, int write)
83529 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83530 + unsigned long addr, void *buf, size_t len, int write)
83531 {
83532 struct vm_area_struct *vma;
83533
83534 @@ -2017,8 +2008,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83535 *
83536 * The caller must hold a reference on @mm.
83537 */
83538 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83539 - void *buf, int len, int write)
83540 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83541 + void *buf, size_t len, int write)
83542 {
83543 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83544 }
83545 @@ -2027,7 +2018,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83546 * Access another process' address space.
83547 * - source/target buffer must be kernel space
83548 */
83549 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
83550 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
83551 {
83552 struct mm_struct *mm;
83553
83554 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
83555 index 0713bfb..b95bb87 100644
83556 --- a/mm/page-writeback.c
83557 +++ b/mm/page-writeback.c
83558 @@ -655,7 +655,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
83559 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
83560 * - the bdi dirty thresh drops quickly due to change of JBOD workload
83561 */
83562 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
83563 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
83564 unsigned long thresh,
83565 unsigned long bg_thresh,
83566 unsigned long dirty,
83567 @@ -1630,7 +1630,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
83568 }
83569 }
83570
83571 -static struct notifier_block __cpuinitdata ratelimit_nb = {
83572 +static struct notifier_block ratelimit_nb = {
83573 .notifier_call = ratelimit_handler,
83574 .next = NULL,
83575 };
83576 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
83577 index 6a83cd3..3ab04ef 100644
83578 --- a/mm/page_alloc.c
83579 +++ b/mm/page_alloc.c
83580 @@ -58,6 +58,7 @@
83581 #include <linux/prefetch.h>
83582 #include <linux/migrate.h>
83583 #include <linux/page-debug-flags.h>
83584 +#include <linux/random.h>
83585
83586 #include <asm/tlbflush.h>
83587 #include <asm/div64.h>
83588 @@ -338,7 +339,7 @@ out:
83589 * This usage means that zero-order pages may not be compound.
83590 */
83591
83592 -static void free_compound_page(struct page *page)
83593 +void free_compound_page(struct page *page)
83594 {
83595 __free_pages_ok(page, compound_order(page));
83596 }
83597 @@ -693,6 +694,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83598 int i;
83599 int bad = 0;
83600
83601 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83602 + unsigned long index = 1UL << order;
83603 +#endif
83604 +
83605 trace_mm_page_free(page, order);
83606 kmemcheck_free_shadow(page, order);
83607
83608 @@ -708,6 +713,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83609 debug_check_no_obj_freed(page_address(page),
83610 PAGE_SIZE << order);
83611 }
83612 +
83613 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83614 + for (; index; --index)
83615 + sanitize_highpage(page + index - 1);
83616 +#endif
83617 +
83618 arch_free_page(page, order);
83619 kernel_map_pages(page, 1 << order, 0);
83620
83621 @@ -730,6 +741,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
83622 local_irq_restore(flags);
83623 }
83624
83625 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83626 +bool __meminitdata extra_latent_entropy;
83627 +
83628 +static int __init setup_pax_extra_latent_entropy(char *str)
83629 +{
83630 + extra_latent_entropy = true;
83631 + return 0;
83632 +}
83633 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
83634 +
83635 +volatile u64 latent_entropy;
83636 +#endif
83637 +
83638 /*
83639 * Read access to zone->managed_pages is safe because it's unsigned long,
83640 * but we still need to serialize writers. Currently all callers of
83641 @@ -752,6 +776,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
83642 set_page_count(p, 0);
83643 }
83644
83645 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83646 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
83647 + u64 hash = 0;
83648 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
83649 + const u64 *data = lowmem_page_address(page);
83650 +
83651 + for (index = 0; index < end; index++)
83652 + hash ^= hash + data[index];
83653 + latent_entropy ^= hash;
83654 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
83655 + }
83656 +#endif
83657 +
83658 page_zone(page)->managed_pages += 1 << order;
83659 set_page_refcounted(page);
83660 __free_pages(page, order);
83661 @@ -861,8 +898,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
83662 arch_alloc_page(page, order);
83663 kernel_map_pages(page, 1 << order, 1);
83664
83665 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
83666 if (gfp_flags & __GFP_ZERO)
83667 prep_zero_page(page, order, gfp_flags);
83668 +#endif
83669
83670 if (order && (gfp_flags & __GFP_COMP))
83671 prep_compound_page(page, order);
83672 @@ -3752,7 +3791,13 @@ static int pageblock_is_reserved(unsigned long start_pfn, unsigned long end_pfn)
83673 unsigned long pfn;
83674
83675 for (pfn = start_pfn; pfn < end_pfn; pfn++) {
83676 +#ifdef CONFIG_X86_32
83677 + /* boot failures in VMware 8 on 32bit vanilla since
83678 + this change */
83679 + if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
83680 +#else
83681 if (!pfn_valid_within(pfn) || PageReserved(pfn_to_page(pfn)))
83682 +#endif
83683 return 1;
83684 }
83685 return 0;
83686 diff --git a/mm/percpu.c b/mm/percpu.c
83687 index 8c8e08f..73a5cda 100644
83688 --- a/mm/percpu.c
83689 +++ b/mm/percpu.c
83690 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
83691 static unsigned int pcpu_high_unit_cpu __read_mostly;
83692
83693 /* the address of the first chunk which starts with the kernel static area */
83694 -void *pcpu_base_addr __read_mostly;
83695 +void *pcpu_base_addr __read_only;
83696 EXPORT_SYMBOL_GPL(pcpu_base_addr);
83697
83698 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
83699 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
83700 index fd26d04..0cea1b0 100644
83701 --- a/mm/process_vm_access.c
83702 +++ b/mm/process_vm_access.c
83703 @@ -13,6 +13,7 @@
83704 #include <linux/uio.h>
83705 #include <linux/sched.h>
83706 #include <linux/highmem.h>
83707 +#include <linux/security.h>
83708 #include <linux/ptrace.h>
83709 #include <linux/slab.h>
83710 #include <linux/syscalls.h>
83711 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83712 size_t iov_l_curr_offset = 0;
83713 ssize_t iov_len;
83714
83715 + return -ENOSYS; // PaX: until properly audited
83716 +
83717 /*
83718 * Work out how many pages of struct pages we're going to need
83719 * when eventually calling get_user_pages
83720 */
83721 for (i = 0; i < riovcnt; i++) {
83722 iov_len = rvec[i].iov_len;
83723 - if (iov_len > 0) {
83724 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
83725 - + iov_len)
83726 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
83727 - / PAGE_SIZE + 1;
83728 - nr_pages = max(nr_pages, nr_pages_iov);
83729 - }
83730 + if (iov_len <= 0)
83731 + continue;
83732 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
83733 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
83734 + nr_pages = max(nr_pages, nr_pages_iov);
83735 }
83736
83737 if (nr_pages == 0)
83738 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83739 goto free_proc_pages;
83740 }
83741
83742 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
83743 + rc = -EPERM;
83744 + goto put_task_struct;
83745 + }
83746 +
83747 mm = mm_access(task, PTRACE_MODE_ATTACH);
83748 if (!mm || IS_ERR(mm)) {
83749 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
83750 diff --git a/mm/rmap.c b/mm/rmap.c
83751 index 2c78f8c..9e9c624 100644
83752 --- a/mm/rmap.c
83753 +++ b/mm/rmap.c
83754 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83755 struct anon_vma *anon_vma = vma->anon_vma;
83756 struct anon_vma_chain *avc;
83757
83758 +#ifdef CONFIG_PAX_SEGMEXEC
83759 + struct anon_vma_chain *avc_m = NULL;
83760 +#endif
83761 +
83762 might_sleep();
83763 if (unlikely(!anon_vma)) {
83764 struct mm_struct *mm = vma->vm_mm;
83765 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83766 if (!avc)
83767 goto out_enomem;
83768
83769 +#ifdef CONFIG_PAX_SEGMEXEC
83770 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
83771 + if (!avc_m)
83772 + goto out_enomem_free_avc;
83773 +#endif
83774 +
83775 anon_vma = find_mergeable_anon_vma(vma);
83776 allocated = NULL;
83777 if (!anon_vma) {
83778 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83779 /* page_table_lock to protect against threads */
83780 spin_lock(&mm->page_table_lock);
83781 if (likely(!vma->anon_vma)) {
83782 +
83783 +#ifdef CONFIG_PAX_SEGMEXEC
83784 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
83785 +
83786 + if (vma_m) {
83787 + BUG_ON(vma_m->anon_vma);
83788 + vma_m->anon_vma = anon_vma;
83789 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
83790 + avc_m = NULL;
83791 + }
83792 +#endif
83793 +
83794 vma->anon_vma = anon_vma;
83795 anon_vma_chain_link(vma, avc, anon_vma);
83796 allocated = NULL;
83797 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83798
83799 if (unlikely(allocated))
83800 put_anon_vma(allocated);
83801 +
83802 +#ifdef CONFIG_PAX_SEGMEXEC
83803 + if (unlikely(avc_m))
83804 + anon_vma_chain_free(avc_m);
83805 +#endif
83806 +
83807 if (unlikely(avc))
83808 anon_vma_chain_free(avc);
83809 }
83810 return 0;
83811
83812 out_enomem_free_avc:
83813 +
83814 +#ifdef CONFIG_PAX_SEGMEXEC
83815 + if (avc_m)
83816 + anon_vma_chain_free(avc_m);
83817 +#endif
83818 +
83819 anon_vma_chain_free(avc);
83820 out_enomem:
83821 return -ENOMEM;
83822 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
83823 * Attach the anon_vmas from src to dst.
83824 * Returns 0 on success, -ENOMEM on failure.
83825 */
83826 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83827 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
83828 {
83829 struct anon_vma_chain *avc, *pavc;
83830 struct anon_vma *root = NULL;
83831 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83832 * the corresponding VMA in the parent process is attached to.
83833 * Returns 0 on success, non-zero on failure.
83834 */
83835 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
83836 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
83837 {
83838 struct anon_vma_chain *avc;
83839 struct anon_vma *anon_vma;
83840 diff --git a/mm/shmem.c b/mm/shmem.c
83841 index efd0b3a..994b702 100644
83842 --- a/mm/shmem.c
83843 +++ b/mm/shmem.c
83844 @@ -31,7 +31,7 @@
83845 #include <linux/export.h>
83846 #include <linux/swap.h>
83847
83848 -static struct vfsmount *shm_mnt;
83849 +struct vfsmount *shm_mnt;
83850
83851 #ifdef CONFIG_SHMEM
83852 /*
83853 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
83854 #define BOGO_DIRENT_SIZE 20
83855
83856 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
83857 -#define SHORT_SYMLINK_LEN 128
83858 +#define SHORT_SYMLINK_LEN 64
83859
83860 /*
83861 * shmem_fallocate and shmem_writepage communicate via inode->i_private
83862 @@ -2202,6 +2202,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
83863 static int shmem_xattr_validate(const char *name)
83864 {
83865 struct { const char *prefix; size_t len; } arr[] = {
83866 +
83867 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83868 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
83869 +#endif
83870 +
83871 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
83872 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
83873 };
83874 @@ -2257,6 +2262,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
83875 if (err)
83876 return err;
83877
83878 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83879 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
83880 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
83881 + return -EOPNOTSUPP;
83882 + if (size > 8)
83883 + return -EINVAL;
83884 + }
83885 +#endif
83886 +
83887 return simple_xattr_set(&info->xattrs, name, value, size, flags);
83888 }
83889
83890 @@ -2562,8 +2576,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
83891 int err = -ENOMEM;
83892
83893 /* Round up to L1_CACHE_BYTES to resist false sharing */
83894 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
83895 - L1_CACHE_BYTES), GFP_KERNEL);
83896 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
83897 if (!sbinfo)
83898 return -ENOMEM;
83899
83900 diff --git a/mm/slab.c b/mm/slab.c
83901 index e7667a3..a48e73b 100644
83902 --- a/mm/slab.c
83903 +++ b/mm/slab.c
83904 @@ -306,7 +306,7 @@ struct kmem_list3 {
83905 * Need this for bootstrapping a per node allocator.
83906 */
83907 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
83908 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
83909 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
83910 #define CACHE_CACHE 0
83911 #define SIZE_AC MAX_NUMNODES
83912 #define SIZE_L3 (2 * MAX_NUMNODES)
83913 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
83914 if ((x)->max_freeable < i) \
83915 (x)->max_freeable = i; \
83916 } while (0)
83917 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
83918 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
83919 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
83920 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
83921 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
83922 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
83923 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
83924 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
83925 #else
83926 #define STATS_INC_ACTIVE(x) do { } while (0)
83927 #define STATS_DEC_ACTIVE(x) do { } while (0)
83928 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
83929 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
83930 */
83931 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
83932 - const struct slab *slab, void *obj)
83933 + const struct slab *slab, const void *obj)
83934 {
83935 u32 offset = (obj - slab->s_mem);
83936 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
83937 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
83938 struct cache_names {
83939 char *name;
83940 char *name_dma;
83941 + char *name_usercopy;
83942 };
83943
83944 static struct cache_names __initdata cache_names[] = {
83945 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
83946 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
83947 #include <linux/kmalloc_sizes.h>
83948 - {NULL,}
83949 + {NULL}
83950 #undef CACHE
83951 };
83952
83953 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
83954 if (unlikely(gfpflags & GFP_DMA))
83955 return csizep->cs_dmacachep;
83956 #endif
83957 +
83958 +#ifdef CONFIG_PAX_USERCOPY_SLABS
83959 + if (unlikely(gfpflags & GFP_USERCOPY))
83960 + return csizep->cs_usercopycachep;
83961 +#endif
83962 +
83963 return csizep->cs_cachep;
83964 }
83965
83966 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
83967 return notifier_from_errno(err);
83968 }
83969
83970 -static struct notifier_block __cpuinitdata cpucache_notifier = {
83971 +static struct notifier_block cpucache_notifier = {
83972 &cpuup_callback, NULL, 0
83973 };
83974
83975 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
83976 */
83977
83978 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
83979 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
83980 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83981
83982 if (INDEX_AC != INDEX_L3)
83983 sizes[INDEX_L3].cs_cachep =
83984 create_kmalloc_cache(names[INDEX_L3].name,
83985 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
83986 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83987
83988 slab_early_init = 0;
83989
83990 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
83991 */
83992 if (!sizes->cs_cachep)
83993 sizes->cs_cachep = create_kmalloc_cache(names->name,
83994 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
83995 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
83996
83997 #ifdef CONFIG_ZONE_DMA
83998 sizes->cs_dmacachep = create_kmalloc_cache(
83999 names->name_dma, sizes->cs_size,
84000 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
84001 #endif
84002 +
84003 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84004 + sizes->cs_usercopycachep = create_kmalloc_cache(
84005 + names->name_usercopy, sizes->cs_size,
84006 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84007 +#endif
84008 +
84009 sizes++;
84010 names++;
84011 }
84012 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
84013
84014 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84015 return;
84016 + VM_BUG_ON(!virt_addr_valid(objp));
84017 local_irq_save(flags);
84018 kfree_debugcheck(objp);
84019 c = virt_to_cache(objp);
84020 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84021 }
84022 /* cpu stats */
84023 {
84024 - unsigned long allochit = atomic_read(&cachep->allochit);
84025 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84026 - unsigned long freehit = atomic_read(&cachep->freehit);
84027 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84028 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84029 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84030 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84031 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84032
84033 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84034 allochit, allocmiss, freehit, freemiss);
84035 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
84036 static int __init slab_proc_init(void)
84037 {
84038 #ifdef CONFIG_DEBUG_SLAB_LEAK
84039 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84040 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84041 #endif
84042 return 0;
84043 }
84044 module_init(slab_proc_init);
84045 #endif
84046
84047 +bool is_usercopy_object(const void *ptr)
84048 +{
84049 + struct page *page;
84050 + struct kmem_cache *cachep;
84051 +
84052 + if (ZERO_OR_NULL_PTR(ptr))
84053 + return false;
84054 +
84055 + if (!slab_is_available())
84056 + return false;
84057 +
84058 + if (!virt_addr_valid(ptr))
84059 + return false;
84060 +
84061 + page = virt_to_head_page(ptr);
84062 +
84063 + if (!PageSlab(page))
84064 + return false;
84065 +
84066 + cachep = page->slab_cache;
84067 + return cachep->flags & SLAB_USERCOPY;
84068 +}
84069 +
84070 +#ifdef CONFIG_PAX_USERCOPY
84071 +const char *check_heap_object(const void *ptr, unsigned long n)
84072 +{
84073 + struct page *page;
84074 + struct kmem_cache *cachep;
84075 + struct slab *slabp;
84076 + unsigned int objnr;
84077 + unsigned long offset;
84078 +
84079 + if (ZERO_OR_NULL_PTR(ptr))
84080 + return "<null>";
84081 +
84082 + if (!virt_addr_valid(ptr))
84083 + return NULL;
84084 +
84085 + page = virt_to_head_page(ptr);
84086 +
84087 + if (!PageSlab(page))
84088 + return NULL;
84089 +
84090 + cachep = page->slab_cache;
84091 + if (!(cachep->flags & SLAB_USERCOPY))
84092 + return cachep->name;
84093 +
84094 + slabp = page->slab_page;
84095 + objnr = obj_to_index(cachep, slabp, ptr);
84096 + BUG_ON(objnr >= cachep->num);
84097 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84098 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84099 + return NULL;
84100 +
84101 + return cachep->name;
84102 +}
84103 +#endif
84104 +
84105 /**
84106 * ksize - get the actual amount of memory allocated for a given object
84107 * @objp: Pointer to the object
84108 diff --git a/mm/slab.h b/mm/slab.h
84109 index 34a98d6..73633d1 100644
84110 --- a/mm/slab.h
84111 +++ b/mm/slab.h
84112 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84113
84114 /* Legal flag mask for kmem_cache_create(), for various configurations */
84115 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84116 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84117 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84118
84119 #if defined(CONFIG_DEBUG_SLAB)
84120 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84121 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84122 return s;
84123
84124 page = virt_to_head_page(x);
84125 +
84126 + BUG_ON(!PageSlab(page));
84127 +
84128 cachep = page->slab_cache;
84129 if (slab_equal_or_root(cachep, s))
84130 return cachep;
84131 diff --git a/mm/slab_common.c b/mm/slab_common.c
84132 index 3f3cd97..93b0236 100644
84133 --- a/mm/slab_common.c
84134 +++ b/mm/slab_common.c
84135 @@ -22,7 +22,7 @@
84136
84137 #include "slab.h"
84138
84139 -enum slab_state slab_state;
84140 +enum slab_state slab_state __read_only;
84141 LIST_HEAD(slab_caches);
84142 DEFINE_MUTEX(slab_mutex);
84143 struct kmem_cache *kmem_cache;
84144 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84145
84146 err = __kmem_cache_create(s, flags);
84147 if (!err) {
84148 - s->refcount = 1;
84149 + atomic_set(&s->refcount, 1);
84150 list_add(&s->list, &slab_caches);
84151 memcg_cache_list_add(memcg, s);
84152 } else {
84153 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84154
84155 get_online_cpus();
84156 mutex_lock(&slab_mutex);
84157 - s->refcount--;
84158 - if (!s->refcount) {
84159 + if (atomic_dec_and_test(&s->refcount)) {
84160 list_del(&s->list);
84161
84162 if (!__kmem_cache_shutdown(s)) {
84163 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84164 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
84165 name, size, err);
84166
84167 - s->refcount = -1; /* Exempt from merging for now */
84168 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84169 }
84170
84171 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84172 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84173
84174 create_boot_cache(s, name, size, flags);
84175 list_add(&s->list, &slab_caches);
84176 - s->refcount = 1;
84177 + atomic_set(&s->refcount, 1);
84178 return s;
84179 }
84180
84181 diff --git a/mm/slob.c b/mm/slob.c
84182 index a99fdf7..6ee34ec 100644
84183 --- a/mm/slob.c
84184 +++ b/mm/slob.c
84185 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84186 /*
84187 * Return the size of a slob block.
84188 */
84189 -static slobidx_t slob_units(slob_t *s)
84190 +static slobidx_t slob_units(const slob_t *s)
84191 {
84192 if (s->units > 0)
84193 return s->units;
84194 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84195 /*
84196 * Return the next free slob block pointer after this one.
84197 */
84198 -static slob_t *slob_next(slob_t *s)
84199 +static slob_t *slob_next(const slob_t *s)
84200 {
84201 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84202 slobidx_t next;
84203 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84204 /*
84205 * Returns true if s is the last free block in its page.
84206 */
84207 -static int slob_last(slob_t *s)
84208 +static int slob_last(const slob_t *s)
84209 {
84210 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84211 }
84212
84213 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84214 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84215 {
84216 - void *page;
84217 + struct page *page;
84218
84219 #ifdef CONFIG_NUMA
84220 if (node != NUMA_NO_NODE)
84221 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84222 if (!page)
84223 return NULL;
84224
84225 - return page_address(page);
84226 + __SetPageSlab(page);
84227 + return page;
84228 }
84229
84230 -static void slob_free_pages(void *b, int order)
84231 +static void slob_free_pages(struct page *sp, int order)
84232 {
84233 if (current->reclaim_state)
84234 current->reclaim_state->reclaimed_slab += 1 << order;
84235 - free_pages((unsigned long)b, order);
84236 + __ClearPageSlab(sp);
84237 + reset_page_mapcount(sp);
84238 + sp->private = 0;
84239 + __free_pages(sp, order);
84240 }
84241
84242 /*
84243 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84244
84245 /* Not enough space: must allocate a new page */
84246 if (!b) {
84247 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84248 - if (!b)
84249 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84250 + if (!sp)
84251 return NULL;
84252 - sp = virt_to_page(b);
84253 - __SetPageSlab(sp);
84254 + b = page_address(sp);
84255
84256 spin_lock_irqsave(&slob_lock, flags);
84257 sp->units = SLOB_UNITS(PAGE_SIZE);
84258 sp->freelist = b;
84259 + sp->private = 0;
84260 INIT_LIST_HEAD(&sp->list);
84261 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84262 set_slob_page_free(sp, slob_list);
84263 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84264 if (slob_page_free(sp))
84265 clear_slob_page_free(sp);
84266 spin_unlock_irqrestore(&slob_lock, flags);
84267 - __ClearPageSlab(sp);
84268 - reset_page_mapcount(sp);
84269 - slob_free_pages(b, 0);
84270 + slob_free_pages(sp, 0);
84271 return;
84272 }
84273
84274 @@ -424,11 +426,10 @@ out:
84275 */
84276
84277 static __always_inline void *
84278 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84279 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84280 {
84281 - unsigned int *m;
84282 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84283 - void *ret;
84284 + slob_t *m;
84285 + void *ret = NULL;
84286
84287 gfp &= gfp_allowed_mask;
84288
84289 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84290
84291 if (!m)
84292 return NULL;
84293 - *m = size;
84294 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84295 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84296 + m[0].units = size;
84297 + m[1].units = align;
84298 ret = (void *)m + align;
84299
84300 trace_kmalloc_node(caller, ret,
84301 size, size + align, gfp, node);
84302 } else {
84303 unsigned int order = get_order(size);
84304 + struct page *page;
84305
84306 if (likely(order))
84307 gfp |= __GFP_COMP;
84308 - ret = slob_new_pages(gfp, order, node);
84309 + page = slob_new_pages(gfp, order, node);
84310 + if (page) {
84311 + ret = page_address(page);
84312 + page->private = size;
84313 + }
84314
84315 trace_kmalloc_node(caller, ret,
84316 size, PAGE_SIZE << order, gfp, node);
84317 }
84318
84319 - kmemleak_alloc(ret, size, 1, gfp);
84320 + return ret;
84321 +}
84322 +
84323 +static __always_inline void *
84324 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84325 +{
84326 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84327 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84328 +
84329 + if (!ZERO_OR_NULL_PTR(ret))
84330 + kmemleak_alloc(ret, size, 1, gfp);
84331 return ret;
84332 }
84333
84334 @@ -493,34 +512,112 @@ void kfree(const void *block)
84335 return;
84336 kmemleak_free(block);
84337
84338 + VM_BUG_ON(!virt_addr_valid(block));
84339 sp = virt_to_page(block);
84340 - if (PageSlab(sp)) {
84341 + VM_BUG_ON(!PageSlab(sp));
84342 + if (!sp->private) {
84343 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84344 - unsigned int *m = (unsigned int *)(block - align);
84345 - slob_free(m, *m + align);
84346 - } else
84347 + slob_t *m = (slob_t *)(block - align);
84348 + slob_free(m, m[0].units + align);
84349 + } else {
84350 + __ClearPageSlab(sp);
84351 + reset_page_mapcount(sp);
84352 + sp->private = 0;
84353 __free_pages(sp, compound_order(sp));
84354 + }
84355 }
84356 EXPORT_SYMBOL(kfree);
84357
84358 +bool is_usercopy_object(const void *ptr)
84359 +{
84360 + if (!slab_is_available())
84361 + return false;
84362 +
84363 + // PAX: TODO
84364 +
84365 + return false;
84366 +}
84367 +
84368 +#ifdef CONFIG_PAX_USERCOPY
84369 +const char *check_heap_object(const void *ptr, unsigned long n)
84370 +{
84371 + struct page *page;
84372 + const slob_t *free;
84373 + const void *base;
84374 + unsigned long flags;
84375 +
84376 + if (ZERO_OR_NULL_PTR(ptr))
84377 + return "<null>";
84378 +
84379 + if (!virt_addr_valid(ptr))
84380 + return NULL;
84381 +
84382 + page = virt_to_head_page(ptr);
84383 + if (!PageSlab(page))
84384 + return NULL;
84385 +
84386 + if (page->private) {
84387 + base = page;
84388 + if (base <= ptr && n <= page->private - (ptr - base))
84389 + return NULL;
84390 + return "<slob>";
84391 + }
84392 +
84393 + /* some tricky double walking to find the chunk */
84394 + spin_lock_irqsave(&slob_lock, flags);
84395 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84396 + free = page->freelist;
84397 +
84398 + while (!slob_last(free) && (void *)free <= ptr) {
84399 + base = free + slob_units(free);
84400 + free = slob_next(free);
84401 + }
84402 +
84403 + while (base < (void *)free) {
84404 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84405 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84406 + int offset;
84407 +
84408 + if (ptr < base + align)
84409 + break;
84410 +
84411 + offset = ptr - base - align;
84412 + if (offset >= m) {
84413 + base += size;
84414 + continue;
84415 + }
84416 +
84417 + if (n > m - offset)
84418 + break;
84419 +
84420 + spin_unlock_irqrestore(&slob_lock, flags);
84421 + return NULL;
84422 + }
84423 +
84424 + spin_unlock_irqrestore(&slob_lock, flags);
84425 + return "<slob>";
84426 +}
84427 +#endif
84428 +
84429 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84430 size_t ksize(const void *block)
84431 {
84432 struct page *sp;
84433 int align;
84434 - unsigned int *m;
84435 + slob_t *m;
84436
84437 BUG_ON(!block);
84438 if (unlikely(block == ZERO_SIZE_PTR))
84439 return 0;
84440
84441 sp = virt_to_page(block);
84442 - if (unlikely(!PageSlab(sp)))
84443 - return PAGE_SIZE << compound_order(sp);
84444 + VM_BUG_ON(!PageSlab(sp));
84445 + if (sp->private)
84446 + return sp->private;
84447
84448 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84449 - m = (unsigned int *)(block - align);
84450 - return SLOB_UNITS(*m) * SLOB_UNIT;
84451 + m = (slob_t *)(block - align);
84452 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84453 }
84454 EXPORT_SYMBOL(ksize);
84455
84456 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84457
84458 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84459 {
84460 - void *b;
84461 + void *b = NULL;
84462
84463 flags &= gfp_allowed_mask;
84464
84465 lockdep_trace_alloc(flags);
84466
84467 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84468 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84469 +#else
84470 if (c->size < PAGE_SIZE) {
84471 b = slob_alloc(c->size, flags, c->align, node);
84472 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84473 SLOB_UNITS(c->size) * SLOB_UNIT,
84474 flags, node);
84475 } else {
84476 - b = slob_new_pages(flags, get_order(c->size), node);
84477 + struct page *sp;
84478 +
84479 + sp = slob_new_pages(flags, get_order(c->size), node);
84480 + if (sp) {
84481 + b = page_address(sp);
84482 + sp->private = c->size;
84483 + }
84484 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84485 PAGE_SIZE << get_order(c->size),
84486 flags, node);
84487 }
84488 +#endif
84489
84490 if (c->ctor)
84491 c->ctor(b);
84492 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84493
84494 static void __kmem_cache_free(void *b, int size)
84495 {
84496 - if (size < PAGE_SIZE)
84497 + struct page *sp;
84498 +
84499 + sp = virt_to_page(b);
84500 + BUG_ON(!PageSlab(sp));
84501 + if (!sp->private)
84502 slob_free(b, size);
84503 else
84504 - slob_free_pages(b, get_order(size));
84505 + slob_free_pages(sp, get_order(size));
84506 }
84507
84508 static void kmem_rcu_free(struct rcu_head *head)
84509 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84510
84511 void kmem_cache_free(struct kmem_cache *c, void *b)
84512 {
84513 + int size = c->size;
84514 +
84515 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84516 + if (size + c->align < PAGE_SIZE) {
84517 + size += c->align;
84518 + b -= c->align;
84519 + }
84520 +#endif
84521 +
84522 kmemleak_free_recursive(b, c->flags);
84523 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84524 struct slob_rcu *slob_rcu;
84525 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84526 - slob_rcu->size = c->size;
84527 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84528 + slob_rcu->size = size;
84529 call_rcu(&slob_rcu->head, kmem_rcu_free);
84530 } else {
84531 - __kmem_cache_free(b, c->size);
84532 + __kmem_cache_free(b, size);
84533 }
84534
84535 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84536 + trace_kfree(_RET_IP_, b);
84537 +#else
84538 trace_kmem_cache_free(_RET_IP_, b);
84539 +#endif
84540 +
84541 }
84542 EXPORT_SYMBOL(kmem_cache_free);
84543
84544 diff --git a/mm/slub.c b/mm/slub.c
84545 index ba2ca53..991c4f7 100644
84546 --- a/mm/slub.c
84547 +++ b/mm/slub.c
84548 @@ -197,7 +197,7 @@ struct track {
84549
84550 enum track_item { TRACK_ALLOC, TRACK_FREE };
84551
84552 -#ifdef CONFIG_SYSFS
84553 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84554 static int sysfs_slab_add(struct kmem_cache *);
84555 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84556 static void sysfs_slab_remove(struct kmem_cache *);
84557 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84558 if (!t->addr)
84559 return;
84560
84561 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84562 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84563 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84564 #ifdef CONFIG_STACKTRACE
84565 {
84566 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84567 * Merge control. If this is set then no merging of slab caches will occur.
84568 * (Could be removed. This was introduced to pacify the merge skeptics.)
84569 */
84570 -static int slub_nomerge;
84571 +static int slub_nomerge = 1;
84572
84573 /*
84574 * Calculate the order of allocation given an slab object size.
84575 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84576 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84577 #endif
84578
84579 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84580 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84581 +#endif
84582 +
84583 static int __init setup_slub_min_order(char *str)
84584 {
84585 get_option(&str, &slub_min_order);
84586 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84587 return kmalloc_dma_caches[index];
84588
84589 #endif
84590 +
84591 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84592 + if (flags & SLAB_USERCOPY)
84593 + return kmalloc_usercopy_caches[index];
84594 +
84595 +#endif
84596 +
84597 return kmalloc_caches[index];
84598 }
84599
84600 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84601 EXPORT_SYMBOL(__kmalloc_node);
84602 #endif
84603
84604 +bool is_usercopy_object(const void *ptr)
84605 +{
84606 + struct page *page;
84607 + struct kmem_cache *s;
84608 +
84609 + if (ZERO_OR_NULL_PTR(ptr))
84610 + return false;
84611 +
84612 + if (!slab_is_available())
84613 + return false;
84614 +
84615 + if (!virt_addr_valid(ptr))
84616 + return false;
84617 +
84618 + page = virt_to_head_page(ptr);
84619 +
84620 + if (!PageSlab(page))
84621 + return false;
84622 +
84623 + s = page->slab_cache;
84624 + return s->flags & SLAB_USERCOPY;
84625 +}
84626 +
84627 +#ifdef CONFIG_PAX_USERCOPY
84628 +const char *check_heap_object(const void *ptr, unsigned long n)
84629 +{
84630 + struct page *page;
84631 + struct kmem_cache *s;
84632 + unsigned long offset;
84633 +
84634 + if (ZERO_OR_NULL_PTR(ptr))
84635 + return "<null>";
84636 +
84637 + if (!virt_addr_valid(ptr))
84638 + return NULL;
84639 +
84640 + page = virt_to_head_page(ptr);
84641 +
84642 + if (!PageSlab(page))
84643 + return NULL;
84644 +
84645 + s = page->slab_cache;
84646 + if (!(s->flags & SLAB_USERCOPY))
84647 + return s->name;
84648 +
84649 + offset = (ptr - page_address(page)) % s->size;
84650 + if (offset <= s->object_size && n <= s->object_size - offset)
84651 + return NULL;
84652 +
84653 + return s->name;
84654 +}
84655 +#endif
84656 +
84657 size_t ksize(const void *object)
84658 {
84659 struct page *page;
84660 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
84661 if (unlikely(ZERO_OR_NULL_PTR(x)))
84662 return;
84663
84664 + VM_BUG_ON(!virt_addr_valid(x));
84665 page = virt_to_head_page(x);
84666 if (unlikely(!PageSlab(page))) {
84667 BUG_ON(!PageCompound(page));
84668 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
84669
84670 /* Caches that are not of the two-to-the-power-of size */
84671 if (KMALLOC_MIN_SIZE <= 32) {
84672 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
84673 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
84674 caches++;
84675 }
84676
84677 if (KMALLOC_MIN_SIZE <= 64) {
84678 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
84679 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
84680 caches++;
84681 }
84682
84683 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
84684 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
84685 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
84686 caches++;
84687 }
84688
84689 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
84690 }
84691 }
84692 #endif
84693 +
84694 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84695 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
84696 + struct kmem_cache *s = kmalloc_caches[i];
84697 +
84698 + if (s && s->size) {
84699 + char *name = kasprintf(GFP_NOWAIT,
84700 + "usercopy-kmalloc-%d", s->object_size);
84701 +
84702 + BUG_ON(!name);
84703 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
84704 + s->object_size, SLAB_USERCOPY);
84705 + }
84706 + }
84707 +#endif
84708 +
84709 printk(KERN_INFO
84710 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
84711 " CPUs=%d, Nodes=%d\n",
84712 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
84713 /*
84714 * We may have set a slab to be unmergeable during bootstrap.
84715 */
84716 - if (s->refcount < 0)
84717 + if (atomic_read(&s->refcount) < 0)
84718 return 1;
84719
84720 return 0;
84721 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84722
84723 s = find_mergeable(memcg, size, align, flags, name, ctor);
84724 if (s) {
84725 - s->refcount++;
84726 + atomic_inc(&s->refcount);
84727 /*
84728 * Adjust the object sizes so that we clear
84729 * the complete object on kzalloc.
84730 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84731 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
84732
84733 if (sysfs_slab_alias(s, name)) {
84734 - s->refcount--;
84735 + atomic_dec(&s->refcount);
84736 s = NULL;
84737 }
84738 }
84739 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
84740 return NOTIFY_OK;
84741 }
84742
84743 -static struct notifier_block __cpuinitdata slab_notifier = {
84744 +static struct notifier_block slab_notifier = {
84745 .notifier_call = slab_cpuup_callback
84746 };
84747
84748 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
84749 }
84750 #endif
84751
84752 -#ifdef CONFIG_SYSFS
84753 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84754 static int count_inuse(struct page *page)
84755 {
84756 return page->inuse;
84757 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
84758 validate_slab_cache(kmalloc_caches[9]);
84759 }
84760 #else
84761 -#ifdef CONFIG_SYSFS
84762 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84763 static void resiliency_test(void) {};
84764 #endif
84765 #endif
84766
84767 -#ifdef CONFIG_SYSFS
84768 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84769 enum slab_stat_type {
84770 SL_ALL, /* All slabs */
84771 SL_PARTIAL, /* Only partially allocated slabs */
84772 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
84773
84774 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
84775 {
84776 - return sprintf(buf, "%d\n", s->refcount - 1);
84777 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
84778 }
84779 SLAB_ATTR_RO(aliases);
84780
84781 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
84782 return name;
84783 }
84784
84785 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84786 static int sysfs_slab_add(struct kmem_cache *s)
84787 {
84788 int err;
84789 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
84790 kobject_del(&s->kobj);
84791 kobject_put(&s->kobj);
84792 }
84793 +#endif
84794
84795 /*
84796 * Need to buffer aliases during bootup until sysfs becomes
84797 @@ -5336,6 +5419,7 @@ struct saved_alias {
84798
84799 static struct saved_alias *alias_list;
84800
84801 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84802 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84803 {
84804 struct saved_alias *al;
84805 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84806 alias_list = al;
84807 return 0;
84808 }
84809 +#endif
84810
84811 static int __init slab_sysfs_init(void)
84812 {
84813 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
84814 index 1b7e22a..3fcd4f3 100644
84815 --- a/mm/sparse-vmemmap.c
84816 +++ b/mm/sparse-vmemmap.c
84817 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
84818 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84819 if (!p)
84820 return NULL;
84821 - pud_populate(&init_mm, pud, p);
84822 + pud_populate_kernel(&init_mm, pud, p);
84823 }
84824 return pud;
84825 }
84826 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
84827 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84828 if (!p)
84829 return NULL;
84830 - pgd_populate(&init_mm, pgd, p);
84831 + pgd_populate_kernel(&init_mm, pgd, p);
84832 }
84833 return pgd;
84834 }
84835 diff --git a/mm/sparse.c b/mm/sparse.c
84836 index 6b5fb76..db0c190 100644
84837 --- a/mm/sparse.c
84838 +++ b/mm/sparse.c
84839 @@ -782,7 +782,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
84840
84841 for (i = 0; i < PAGES_PER_SECTION; i++) {
84842 if (PageHWPoison(&memmap[i])) {
84843 - atomic_long_sub(1, &mce_bad_pages);
84844 + atomic_long_sub_unchecked(1, &mce_bad_pages);
84845 ClearPageHWPoison(&memmap[i]);
84846 }
84847 }
84848 diff --git a/mm/swap.c b/mm/swap.c
84849 index 6310dc2..3662b3f 100644
84850 --- a/mm/swap.c
84851 +++ b/mm/swap.c
84852 @@ -30,6 +30,7 @@
84853 #include <linux/backing-dev.h>
84854 #include <linux/memcontrol.h>
84855 #include <linux/gfp.h>
84856 +#include <linux/hugetlb.h>
84857
84858 #include "internal.h"
84859
84860 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
84861
84862 __page_cache_release(page);
84863 dtor = get_compound_page_dtor(page);
84864 + if (!PageHuge(page))
84865 + BUG_ON(dtor != free_compound_page);
84866 (*dtor)(page);
84867 }
84868
84869 diff --git a/mm/swapfile.c b/mm/swapfile.c
84870 index e97a0e5..b50e796 100644
84871 --- a/mm/swapfile.c
84872 +++ b/mm/swapfile.c
84873 @@ -64,7 +64,7 @@ static DEFINE_MUTEX(swapon_mutex);
84874
84875 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
84876 /* Activity counter to indicate that a swapon or swapoff has occurred */
84877 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
84878 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
84879
84880 static inline unsigned char swap_count(unsigned char ent)
84881 {
84882 @@ -1608,7 +1608,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
84883 }
84884 filp_close(swap_file, NULL);
84885 err = 0;
84886 - atomic_inc(&proc_poll_event);
84887 + atomic_inc_unchecked(&proc_poll_event);
84888 wake_up_interruptible(&proc_poll_wait);
84889
84890 out_dput:
84891 @@ -1625,8 +1625,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
84892
84893 poll_wait(file, &proc_poll_wait, wait);
84894
84895 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
84896 - seq->poll_event = atomic_read(&proc_poll_event);
84897 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
84898 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84899 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
84900 }
84901
84902 @@ -1724,7 +1724,7 @@ static int swaps_open(struct inode *inode, struct file *file)
84903 return ret;
84904
84905 seq = file->private_data;
84906 - seq->poll_event = atomic_read(&proc_poll_event);
84907 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
84908 return 0;
84909 }
84910
84911 @@ -2066,7 +2066,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
84912 (frontswap_map) ? "FS" : "");
84913
84914 mutex_unlock(&swapon_mutex);
84915 - atomic_inc(&proc_poll_event);
84916 + atomic_inc_unchecked(&proc_poll_event);
84917 wake_up_interruptible(&proc_poll_wait);
84918
84919 if (S_ISREG(inode->i_mode))
84920 diff --git a/mm/util.c b/mm/util.c
84921 index c55e26b..3f913a9 100644
84922 --- a/mm/util.c
84923 +++ b/mm/util.c
84924 @@ -292,6 +292,12 @@ done:
84925 void arch_pick_mmap_layout(struct mm_struct *mm)
84926 {
84927 mm->mmap_base = TASK_UNMAPPED_BASE;
84928 +
84929 +#ifdef CONFIG_PAX_RANDMMAP
84930 + if (mm->pax_flags & MF_PAX_RANDMMAP)
84931 + mm->mmap_base += mm->delta_mmap;
84932 +#endif
84933 +
84934 mm->get_unmapped_area = arch_get_unmapped_area;
84935 mm->unmap_area = arch_unmap_area;
84936 }
84937 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
84938 index 5123a16..f234a48 100644
84939 --- a/mm/vmalloc.c
84940 +++ b/mm/vmalloc.c
84941 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
84942
84943 pte = pte_offset_kernel(pmd, addr);
84944 do {
84945 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84946 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84947 +
84948 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84949 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
84950 + BUG_ON(!pte_exec(*pte));
84951 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
84952 + continue;
84953 + }
84954 +#endif
84955 +
84956 + {
84957 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
84958 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
84959 + }
84960 } while (pte++, addr += PAGE_SIZE, addr != end);
84961 }
84962
84963 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
84964 pte = pte_alloc_kernel(pmd, addr);
84965 if (!pte)
84966 return -ENOMEM;
84967 +
84968 + pax_open_kernel();
84969 do {
84970 struct page *page = pages[*nr];
84971
84972 - if (WARN_ON(!pte_none(*pte)))
84973 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
84974 + if (pgprot_val(prot) & _PAGE_NX)
84975 +#endif
84976 +
84977 + if (!pte_none(*pte)) {
84978 + pax_close_kernel();
84979 + WARN_ON(1);
84980 return -EBUSY;
84981 - if (WARN_ON(!page))
84982 + }
84983 + if (!page) {
84984 + pax_close_kernel();
84985 + WARN_ON(1);
84986 return -ENOMEM;
84987 + }
84988 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
84989 (*nr)++;
84990 } while (pte++, addr += PAGE_SIZE, addr != end);
84991 + pax_close_kernel();
84992 return 0;
84993 }
84994
84995 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
84996 pmd_t *pmd;
84997 unsigned long next;
84998
84999 - pmd = pmd_alloc(&init_mm, pud, addr);
85000 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85001 if (!pmd)
85002 return -ENOMEM;
85003 do {
85004 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85005 pud_t *pud;
85006 unsigned long next;
85007
85008 - pud = pud_alloc(&init_mm, pgd, addr);
85009 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85010 if (!pud)
85011 return -ENOMEM;
85012 do {
85013 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
85014 * and fall back on vmalloc() if that fails. Others
85015 * just put it in the vmalloc space.
85016 */
85017 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
85018 +#ifdef CONFIG_MODULES
85019 +#ifdef MODULES_VADDR
85020 unsigned long addr = (unsigned long)x;
85021 if (addr >= MODULES_VADDR && addr < MODULES_END)
85022 return 1;
85023 #endif
85024 +
85025 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85026 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85027 + return 1;
85028 +#endif
85029 +
85030 +#endif
85031 +
85032 return is_vmalloc_addr(x);
85033 }
85034
85035 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85036
85037 if (!pgd_none(*pgd)) {
85038 pud_t *pud = pud_offset(pgd, addr);
85039 +#ifdef CONFIG_X86
85040 + if (!pud_large(*pud))
85041 +#endif
85042 if (!pud_none(*pud)) {
85043 pmd_t *pmd = pmd_offset(pud, addr);
85044 +#ifdef CONFIG_X86
85045 + if (!pmd_large(*pmd))
85046 +#endif
85047 if (!pmd_none(*pmd)) {
85048 pte_t *ptep, pte;
85049
85050 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
85051 * Allocate a region of KVA of the specified size and alignment, within the
85052 * vstart and vend.
85053 */
85054 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85055 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85056 unsigned long align,
85057 unsigned long vstart, unsigned long vend,
85058 int node, gfp_t gfp_mask)
85059 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85060 struct vm_struct *area;
85061
85062 BUG_ON(in_interrupt());
85063 +
85064 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85065 + if (flags & VM_KERNEXEC) {
85066 + if (start != VMALLOC_START || end != VMALLOC_END)
85067 + return NULL;
85068 + start = (unsigned long)MODULES_EXEC_VADDR;
85069 + end = (unsigned long)MODULES_EXEC_END;
85070 + }
85071 +#endif
85072 +
85073 if (flags & VM_IOREMAP) {
85074 int bit = fls(size);
85075
85076 @@ -1568,6 +1617,11 @@ void *vmap(struct page **pages, unsigned int count,
85077 if (count > totalram_pages)
85078 return NULL;
85079
85080 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85081 + if (!(pgprot_val(prot) & _PAGE_NX))
85082 + flags |= VM_KERNEXEC;
85083 +#endif
85084 +
85085 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85086 __builtin_return_address(0));
85087 if (!area)
85088 @@ -1669,6 +1723,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85089 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85090 goto fail;
85091
85092 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85093 + if (!(pgprot_val(prot) & _PAGE_NX))
85094 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85095 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85096 + else
85097 +#endif
85098 +
85099 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85100 start, end, node, gfp_mask, caller);
85101 if (!area)
85102 @@ -1842,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
85103 * For tight control over page level allocator and protection flags
85104 * use __vmalloc() instead.
85105 */
85106 -
85107 void *vmalloc_exec(unsigned long size)
85108 {
85109 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85110 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85111 -1, __builtin_return_address(0));
85112 }
85113
85114 @@ -2136,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85115 unsigned long uaddr = vma->vm_start;
85116 unsigned long usize = vma->vm_end - vma->vm_start;
85117
85118 + BUG_ON(vma->vm_mirror);
85119 +
85120 if ((PAGE_SIZE-1) & (unsigned long)addr)
85121 return -EINVAL;
85122
85123 @@ -2575,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
85124 v->addr, v->addr + v->size, v->size);
85125
85126 if (v->caller)
85127 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85128 + seq_printf(m, " %pK", v->caller);
85129 +#else
85130 seq_printf(m, " %pS", v->caller);
85131 +#endif
85132
85133 if (v->nr_pages)
85134 seq_printf(m, " pages=%d", v->nr_pages);
85135 diff --git a/mm/vmstat.c b/mm/vmstat.c
85136 index 9800306..76b4b27 100644
85137 --- a/mm/vmstat.c
85138 +++ b/mm/vmstat.c
85139 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
85140 *
85141 * vm_stat contains the global counters
85142 */
85143 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85144 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85145 EXPORT_SYMBOL(vm_stat);
85146
85147 #ifdef CONFIG_SMP
85148 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
85149 v = p->vm_stat_diff[i];
85150 p->vm_stat_diff[i] = 0;
85151 local_irq_restore(flags);
85152 - atomic_long_add(v, &zone->vm_stat[i]);
85153 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85154 global_diff[i] += v;
85155 #ifdef CONFIG_NUMA
85156 /* 3 seconds idle till flush */
85157 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
85158
85159 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85160 if (global_diff[i])
85161 - atomic_long_add(global_diff[i], &vm_stat[i]);
85162 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85163 }
85164
85165 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85166 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85167 if (pset->vm_stat_diff[i]) {
85168 int v = pset->vm_stat_diff[i];
85169 pset->vm_stat_diff[i] = 0;
85170 - atomic_long_add(v, &zone->vm_stat[i]);
85171 - atomic_long_add(v, &vm_stat[i]);
85172 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85173 + atomic_long_add_unchecked(v, &vm_stat[i]);
85174 }
85175 }
85176 #endif
85177 @@ -1223,7 +1223,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85178 return NOTIFY_OK;
85179 }
85180
85181 -static struct notifier_block __cpuinitdata vmstat_notifier =
85182 +static struct notifier_block vmstat_notifier =
85183 { &vmstat_cpuup_callback, NULL, 0 };
85184 #endif
85185
85186 @@ -1238,10 +1238,20 @@ static int __init setup_vmstat(void)
85187 start_cpu_timer(cpu);
85188 #endif
85189 #ifdef CONFIG_PROC_FS
85190 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85191 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85192 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85193 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85194 + {
85195 + mode_t gr_mode = S_IRUGO;
85196 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85197 + gr_mode = S_IRUSR;
85198 +#endif
85199 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85200 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85201 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85202 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85203 +#else
85204 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85205 +#endif
85206 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85207 + }
85208 #endif
85209 return 0;
85210 }
85211 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85212 index acc74ad..be02639 100644
85213 --- a/net/8021q/vlan.c
85214 +++ b/net/8021q/vlan.c
85215 @@ -108,6 +108,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
85216 if (vlan_id)
85217 vlan_vid_del(real_dev, vlan_id);
85218
85219 + /* Take it out of our own structures, but be sure to interlock with
85220 + * HW accelerating devices or SW vlan input packet processing if
85221 + * VLAN is not 0 (leave it there for 802.1p).
85222 + */
85223 + if (vlan_id)
85224 + vlan_vid_del(real_dev, vlan_id);
85225 +
85226 /* Get rid of the vlan's reference to real_dev */
85227 dev_put(real_dev);
85228 }
85229 @@ -485,7 +492,7 @@ out:
85230 return NOTIFY_DONE;
85231 }
85232
85233 -static struct notifier_block vlan_notifier_block __read_mostly = {
85234 +static struct notifier_block vlan_notifier_block = {
85235 .notifier_call = vlan_device_event,
85236 };
85237
85238 @@ -560,8 +567,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85239 err = -EPERM;
85240 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85241 break;
85242 - if ((args.u.name_type >= 0) &&
85243 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85244 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85245 struct vlan_net *vn;
85246
85247 vn = net_generic(net, vlan_net_id);
85248 diff --git a/net/9p/mod.c b/net/9p/mod.c
85249 index 6ab36ae..6f1841b 100644
85250 --- a/net/9p/mod.c
85251 +++ b/net/9p/mod.c
85252 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85253 void v9fs_register_trans(struct p9_trans_module *m)
85254 {
85255 spin_lock(&v9fs_trans_lock);
85256 - list_add_tail(&m->list, &v9fs_trans_list);
85257 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85258 spin_unlock(&v9fs_trans_lock);
85259 }
85260 EXPORT_SYMBOL(v9fs_register_trans);
85261 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85262 void v9fs_unregister_trans(struct p9_trans_module *m)
85263 {
85264 spin_lock(&v9fs_trans_lock);
85265 - list_del_init(&m->list);
85266 + pax_list_del_init((struct list_head *)&m->list);
85267 spin_unlock(&v9fs_trans_lock);
85268 }
85269 EXPORT_SYMBOL(v9fs_unregister_trans);
85270 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85271 index 02efb25..41541a9 100644
85272 --- a/net/9p/trans_fd.c
85273 +++ b/net/9p/trans_fd.c
85274 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85275 oldfs = get_fs();
85276 set_fs(get_ds());
85277 /* The cast to a user pointer is valid due to the set_fs() */
85278 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85279 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85280 set_fs(oldfs);
85281
85282 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85283 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85284 index 876fbe8..8bbea9f 100644
85285 --- a/net/atm/atm_misc.c
85286 +++ b/net/atm/atm_misc.c
85287 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85288 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85289 return 1;
85290 atm_return(vcc, truesize);
85291 - atomic_inc(&vcc->stats->rx_drop);
85292 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85293 return 0;
85294 }
85295 EXPORT_SYMBOL(atm_charge);
85296 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85297 }
85298 }
85299 atm_return(vcc, guess);
85300 - atomic_inc(&vcc->stats->rx_drop);
85301 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85302 return NULL;
85303 }
85304 EXPORT_SYMBOL(atm_alloc_charge);
85305 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85306
85307 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85308 {
85309 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85310 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85311 __SONET_ITEMS
85312 #undef __HANDLE_ITEM
85313 }
85314 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85315
85316 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85317 {
85318 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85319 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85320 __SONET_ITEMS
85321 #undef __HANDLE_ITEM
85322 }
85323 diff --git a/net/atm/lec.h b/net/atm/lec.h
85324 index a86aff9..3a0d6f6 100644
85325 --- a/net/atm/lec.h
85326 +++ b/net/atm/lec.h
85327 @@ -48,7 +48,7 @@ struct lane2_ops {
85328 const u8 *tlvs, u32 sizeoftlvs);
85329 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85330 const u8 *tlvs, u32 sizeoftlvs);
85331 -};
85332 +} __no_const;
85333
85334 /*
85335 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85336 diff --git a/net/atm/proc.c b/net/atm/proc.c
85337 index 0d020de..011c7bb 100644
85338 --- a/net/atm/proc.c
85339 +++ b/net/atm/proc.c
85340 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85341 const struct k_atm_aal_stats *stats)
85342 {
85343 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85344 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85345 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85346 - atomic_read(&stats->rx_drop));
85347 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85348 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85349 + atomic_read_unchecked(&stats->rx_drop));
85350 }
85351
85352 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85353 diff --git a/net/atm/resources.c b/net/atm/resources.c
85354 index 0447d5d..3cf4728 100644
85355 --- a/net/atm/resources.c
85356 +++ b/net/atm/resources.c
85357 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85358 static void copy_aal_stats(struct k_atm_aal_stats *from,
85359 struct atm_aal_stats *to)
85360 {
85361 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85362 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85363 __AAL_STAT_ITEMS
85364 #undef __HANDLE_ITEM
85365 }
85366 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85367 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85368 struct atm_aal_stats *to)
85369 {
85370 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85371 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85372 __AAL_STAT_ITEMS
85373 #undef __HANDLE_ITEM
85374 }
85375 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85376 index d5744b7..506bae3 100644
85377 --- a/net/ax25/sysctl_net_ax25.c
85378 +++ b/net/ax25/sysctl_net_ax25.c
85379 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85380 {
85381 char path[sizeof("net/ax25/") + IFNAMSIZ];
85382 int k;
85383 - struct ctl_table *table;
85384 + ctl_table_no_const *table;
85385
85386 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85387 if (!table)
85388 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85389 index 1ee94d0..14beea2 100644
85390 --- a/net/batman-adv/bat_iv_ogm.c
85391 +++ b/net/batman-adv/bat_iv_ogm.c
85392 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85393
85394 /* randomize initial seqno to avoid collision */
85395 get_random_bytes(&random_seqno, sizeof(random_seqno));
85396 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85397 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85398
85399 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85400 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85401 @@ -615,9 +615,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85402 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85403
85404 /* change sequence number to network order */
85405 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85406 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85407 batadv_ogm_packet->seqno = htonl(seqno);
85408 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85409 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85410
85411 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85412 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85413 @@ -1022,7 +1022,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85414 return;
85415
85416 /* could be changed by schedule_own_packet() */
85417 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85418 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85419
85420 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85421 has_directlink_flag = 1;
85422 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85423 index f1d37cd..4190879 100644
85424 --- a/net/batman-adv/hard-interface.c
85425 +++ b/net/batman-adv/hard-interface.c
85426 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85427 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85428 dev_add_pack(&hard_iface->batman_adv_ptype);
85429
85430 - atomic_set(&hard_iface->frag_seqno, 1);
85431 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85432 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85433 hard_iface->net_dev->name);
85434
85435 @@ -493,7 +493,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85436 /* This can't be called via a bat_priv callback because
85437 * we have no bat_priv yet.
85438 */
85439 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85440 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85441 hard_iface->bat_iv.ogm_buff = NULL;
85442
85443 return hard_iface;
85444 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85445 index 6b548fd..fc32c8d 100644
85446 --- a/net/batman-adv/soft-interface.c
85447 +++ b/net/batman-adv/soft-interface.c
85448 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85449 primary_if->net_dev->dev_addr, ETH_ALEN);
85450
85451 /* set broadcast sequence number */
85452 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85453 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85454 bcast_packet->seqno = htonl(seqno);
85455
85456 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85457 @@ -497,7 +497,7 @@ struct net_device *batadv_softif_create(const char *name)
85458 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85459
85460 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85461 - atomic_set(&bat_priv->bcast_seqno, 1);
85462 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85463 atomic_set(&bat_priv->tt.vn, 0);
85464 atomic_set(&bat_priv->tt.local_changes, 0);
85465 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85466 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85467 index ae9ac9a..11e0fe7 100644
85468 --- a/net/batman-adv/types.h
85469 +++ b/net/batman-adv/types.h
85470 @@ -48,7 +48,7 @@
85471 struct batadv_hard_iface_bat_iv {
85472 unsigned char *ogm_buff;
85473 int ogm_buff_len;
85474 - atomic_t ogm_seqno;
85475 + atomic_unchecked_t ogm_seqno;
85476 };
85477
85478 struct batadv_hard_iface {
85479 @@ -56,7 +56,7 @@ struct batadv_hard_iface {
85480 int16_t if_num;
85481 char if_status;
85482 struct net_device *net_dev;
85483 - atomic_t frag_seqno;
85484 + atomic_unchecked_t frag_seqno;
85485 struct kobject *hardif_obj;
85486 atomic_t refcount;
85487 struct packet_type batman_adv_ptype;
85488 @@ -284,7 +284,7 @@ struct batadv_priv {
85489 atomic_t orig_interval; /* uint */
85490 atomic_t hop_penalty; /* uint */
85491 atomic_t log_level; /* uint */
85492 - atomic_t bcast_seqno;
85493 + atomic_unchecked_t bcast_seqno;
85494 atomic_t bcast_queue_left;
85495 atomic_t batman_queue_left;
85496 char num_ifaces;
85497 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85498 index 10aff49..ea8e021 100644
85499 --- a/net/batman-adv/unicast.c
85500 +++ b/net/batman-adv/unicast.c
85501 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85502 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85503 frag2->flags = large_tail;
85504
85505 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85506 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85507 frag1->seqno = htons(seqno - 1);
85508 frag2->seqno = htons(seqno);
85509
85510 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85511 index 07f0739..3c42e34 100644
85512 --- a/net/bluetooth/hci_sock.c
85513 +++ b/net/bluetooth/hci_sock.c
85514 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85515 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85516 }
85517
85518 - len = min_t(unsigned int, len, sizeof(uf));
85519 + len = min((size_t)len, sizeof(uf));
85520 if (copy_from_user(&uf, optval, len)) {
85521 err = -EFAULT;
85522 break;
85523 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85524 index 22e6583..426e2f3 100644
85525 --- a/net/bluetooth/l2cap_core.c
85526 +++ b/net/bluetooth/l2cap_core.c
85527 @@ -3400,8 +3400,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85528 break;
85529
85530 case L2CAP_CONF_RFC:
85531 - if (olen == sizeof(rfc))
85532 - memcpy(&rfc, (void *)val, olen);
85533 + if (olen != sizeof(rfc))
85534 + break;
85535 +
85536 + memcpy(&rfc, (void *)val, olen);
85537
85538 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85539 rfc.mode != chan->mode)
85540 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85541 index 1bcfb84..dad9f98 100644
85542 --- a/net/bluetooth/l2cap_sock.c
85543 +++ b/net/bluetooth/l2cap_sock.c
85544 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85545 struct sock *sk = sock->sk;
85546 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85547 struct l2cap_options opts;
85548 - int len, err = 0;
85549 + int err = 0;
85550 + size_t len = optlen;
85551 u32 opt;
85552
85553 BT_DBG("sk %p", sk);
85554 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85555 opts.max_tx = chan->max_tx;
85556 opts.txwin_size = chan->tx_win;
85557
85558 - len = min_t(unsigned int, sizeof(opts), optlen);
85559 + len = min(sizeof(opts), len);
85560 if (copy_from_user((char *) &opts, optval, len)) {
85561 err = -EFAULT;
85562 break;
85563 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85564 struct bt_security sec;
85565 struct bt_power pwr;
85566 struct l2cap_conn *conn;
85567 - int len, err = 0;
85568 + int err = 0;
85569 + size_t len = optlen;
85570 u32 opt;
85571
85572 BT_DBG("sk %p", sk);
85573 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85574
85575 sec.level = BT_SECURITY_LOW;
85576
85577 - len = min_t(unsigned int, sizeof(sec), optlen);
85578 + len = min(sizeof(sec), len);
85579 if (copy_from_user((char *) &sec, optval, len)) {
85580 err = -EFAULT;
85581 break;
85582 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85583
85584 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85585
85586 - len = min_t(unsigned int, sizeof(pwr), optlen);
85587 + len = min(sizeof(pwr), len);
85588 if (copy_from_user((char *) &pwr, optval, len)) {
85589 err = -EFAULT;
85590 break;
85591 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85592 index ce3f665..2c7d08f 100644
85593 --- a/net/bluetooth/rfcomm/sock.c
85594 +++ b/net/bluetooth/rfcomm/sock.c
85595 @@ -667,7 +667,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85596 struct sock *sk = sock->sk;
85597 struct bt_security sec;
85598 int err = 0;
85599 - size_t len;
85600 + size_t len = optlen;
85601 u32 opt;
85602
85603 BT_DBG("sk %p", sk);
85604 @@ -689,7 +689,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85605
85606 sec.level = BT_SECURITY_LOW;
85607
85608 - len = min_t(unsigned int, sizeof(sec), optlen);
85609 + len = min(sizeof(sec), len);
85610 if (copy_from_user((char *) &sec, optval, len)) {
85611 err = -EFAULT;
85612 break;
85613 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85614 index bd6fd0f..6492cba 100644
85615 --- a/net/bluetooth/rfcomm/tty.c
85616 +++ b/net/bluetooth/rfcomm/tty.c
85617 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
85618 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
85619
85620 spin_lock_irqsave(&dev->port.lock, flags);
85621 - if (dev->port.count > 0) {
85622 + if (atomic_read(&dev->port.count) > 0) {
85623 spin_unlock_irqrestore(&dev->port.lock, flags);
85624 return;
85625 }
85626 @@ -664,10 +664,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
85627 return -ENODEV;
85628
85629 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
85630 - dev->channel, dev->port.count);
85631 + dev->channel, atomic_read(&dev->port.count));
85632
85633 spin_lock_irqsave(&dev->port.lock, flags);
85634 - if (++dev->port.count > 1) {
85635 + if (atomic_inc_return(&dev->port.count) > 1) {
85636 spin_unlock_irqrestore(&dev->port.lock, flags);
85637 return 0;
85638 }
85639 @@ -732,10 +732,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
85640 return;
85641
85642 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
85643 - dev->port.count);
85644 + atomic_read(&dev->port.count));
85645
85646 spin_lock_irqsave(&dev->port.lock, flags);
85647 - if (!--dev->port.count) {
85648 + if (!atomic_dec_return(&dev->port.count)) {
85649 spin_unlock_irqrestore(&dev->port.lock, flags);
85650 if (dev->tty_dev->parent)
85651 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
85652 diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
85653 index d9576e6..85f4f4e 100644
85654 --- a/net/bridge/br_fdb.c
85655 +++ b/net/bridge/br_fdb.c
85656 @@ -386,7 +386,7 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
85657 return 0;
85658 br_warn(br, "adding interface %s with same address "
85659 "as a received packet\n",
85660 - source->dev->name);
85661 + source ? source->dev->name : br->dev->name);
85662 fdb_delete(br, fdb);
85663 }
85664
85665 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
85666 index 5fe2ff3..121d696 100644
85667 --- a/net/bridge/netfilter/ebtables.c
85668 +++ b/net/bridge/netfilter/ebtables.c
85669 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85670 tmp.valid_hooks = t->table->valid_hooks;
85671 }
85672 mutex_unlock(&ebt_mutex);
85673 - if (copy_to_user(user, &tmp, *len) != 0){
85674 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
85675 BUGPRINT("c2u Didn't work\n");
85676 ret = -EFAULT;
85677 break;
85678 @@ -2327,7 +2327,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85679 goto out;
85680 tmp.valid_hooks = t->valid_hooks;
85681
85682 - if (copy_to_user(user, &tmp, *len) != 0) {
85683 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85684 ret = -EFAULT;
85685 break;
85686 }
85687 @@ -2338,7 +2338,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85688 tmp.entries_size = t->table->entries_size;
85689 tmp.valid_hooks = t->table->valid_hooks;
85690
85691 - if (copy_to_user(user, &tmp, *len) != 0) {
85692 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85693 ret = -EFAULT;
85694 break;
85695 }
85696 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
85697 index a376ec1..1fbd6be 100644
85698 --- a/net/caif/cfctrl.c
85699 +++ b/net/caif/cfctrl.c
85700 @@ -10,6 +10,7 @@
85701 #include <linux/spinlock.h>
85702 #include <linux/slab.h>
85703 #include <linux/pkt_sched.h>
85704 +#include <linux/sched.h>
85705 #include <net/caif/caif_layer.h>
85706 #include <net/caif/cfpkt.h>
85707 #include <net/caif/cfctrl.h>
85708 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
85709 memset(&dev_info, 0, sizeof(dev_info));
85710 dev_info.id = 0xff;
85711 cfsrvl_init(&this->serv, 0, &dev_info, false);
85712 - atomic_set(&this->req_seq_no, 1);
85713 - atomic_set(&this->rsp_seq_no, 1);
85714 + atomic_set_unchecked(&this->req_seq_no, 1);
85715 + atomic_set_unchecked(&this->rsp_seq_no, 1);
85716 this->serv.layer.receive = cfctrl_recv;
85717 sprintf(this->serv.layer.name, "ctrl");
85718 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
85719 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
85720 struct cfctrl_request_info *req)
85721 {
85722 spin_lock_bh(&ctrl->info_list_lock);
85723 - atomic_inc(&ctrl->req_seq_no);
85724 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
85725 + atomic_inc_unchecked(&ctrl->req_seq_no);
85726 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
85727 list_add_tail(&req->list, &ctrl->list);
85728 spin_unlock_bh(&ctrl->info_list_lock);
85729 }
85730 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
85731 if (p != first)
85732 pr_warn("Requests are not received in order\n");
85733
85734 - atomic_set(&ctrl->rsp_seq_no,
85735 + atomic_set_unchecked(&ctrl->rsp_seq_no,
85736 p->sequence_no);
85737 list_del(&p->list);
85738 goto out;
85739 diff --git a/net/can/af_can.c b/net/can/af_can.c
85740 index ddac1ee..3ee0a78 100644
85741 --- a/net/can/af_can.c
85742 +++ b/net/can/af_can.c
85743 @@ -872,7 +872,7 @@ static const struct net_proto_family can_family_ops = {
85744 };
85745
85746 /* notifier block for netdevice event */
85747 -static struct notifier_block can_netdev_notifier __read_mostly = {
85748 +static struct notifier_block can_netdev_notifier = {
85749 .notifier_call = can_notifier,
85750 };
85751
85752 diff --git a/net/can/gw.c b/net/can/gw.c
85753 index 28e7bdc..d42c4cd 100644
85754 --- a/net/can/gw.c
85755 +++ b/net/can/gw.c
85756 @@ -67,7 +67,6 @@ MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
85757 MODULE_ALIAS("can-gw");
85758
85759 static HLIST_HEAD(cgw_list);
85760 -static struct notifier_block notifier;
85761
85762 static struct kmem_cache *cgw_cache __read_mostly;
85763
85764 @@ -893,6 +892,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
85765 return err;
85766 }
85767
85768 +static struct notifier_block notifier = {
85769 + .notifier_call = cgw_notifier
85770 +};
85771 +
85772 static __init int cgw_module_init(void)
85773 {
85774 printk(banner);
85775 @@ -904,7 +907,6 @@ static __init int cgw_module_init(void)
85776 return -ENOMEM;
85777
85778 /* set notifier */
85779 - notifier.notifier_call = cgw_notifier;
85780 register_netdevice_notifier(&notifier);
85781
85782 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
85783 diff --git a/net/compat.c b/net/compat.c
85784 index 79ae884..17c5c09 100644
85785 --- a/net/compat.c
85786 +++ b/net/compat.c
85787 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
85788 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
85789 __get_user(kmsg->msg_flags, &umsg->msg_flags))
85790 return -EFAULT;
85791 - kmsg->msg_name = compat_ptr(tmp1);
85792 - kmsg->msg_iov = compat_ptr(tmp2);
85793 - kmsg->msg_control = compat_ptr(tmp3);
85794 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
85795 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
85796 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
85797 return 0;
85798 }
85799
85800 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85801
85802 if (kern_msg->msg_namelen) {
85803 if (mode == VERIFY_READ) {
85804 - int err = move_addr_to_kernel(kern_msg->msg_name,
85805 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
85806 kern_msg->msg_namelen,
85807 kern_address);
85808 if (err < 0)
85809 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85810 kern_msg->msg_name = NULL;
85811
85812 tot_len = iov_from_user_compat_to_kern(kern_iov,
85813 - (struct compat_iovec __user *)kern_msg->msg_iov,
85814 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
85815 kern_msg->msg_iovlen);
85816 if (tot_len >= 0)
85817 kern_msg->msg_iov = kern_iov;
85818 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85819
85820 #define CMSG_COMPAT_FIRSTHDR(msg) \
85821 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
85822 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
85823 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
85824 (struct compat_cmsghdr __user *)NULL)
85825
85826 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
85827 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
85828 (ucmlen) <= (unsigned long) \
85829 ((mhdr)->msg_controllen - \
85830 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
85831 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
85832
85833 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
85834 struct compat_cmsghdr __user *cmsg, int cmsg_len)
85835 {
85836 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
85837 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
85838 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
85839 msg->msg_controllen)
85840 return NULL;
85841 return (struct compat_cmsghdr __user *)ptr;
85842 @@ -219,7 +219,7 @@ Efault:
85843
85844 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
85845 {
85846 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85847 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85848 struct compat_cmsghdr cmhdr;
85849 struct compat_timeval ctv;
85850 struct compat_timespec cts[3];
85851 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
85852
85853 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
85854 {
85855 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85856 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85857 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
85858 int fdnum = scm->fp->count;
85859 struct file **fp = scm->fp->fp;
85860 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
85861 return -EFAULT;
85862 old_fs = get_fs();
85863 set_fs(KERNEL_DS);
85864 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
85865 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
85866 set_fs(old_fs);
85867
85868 return err;
85869 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
85870 len = sizeof(ktime);
85871 old_fs = get_fs();
85872 set_fs(KERNEL_DS);
85873 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
85874 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
85875 set_fs(old_fs);
85876
85877 if (!err) {
85878 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85879 case MCAST_JOIN_GROUP:
85880 case MCAST_LEAVE_GROUP:
85881 {
85882 - struct compat_group_req __user *gr32 = (void *)optval;
85883 + struct compat_group_req __user *gr32 = (void __user *)optval;
85884 struct group_req __user *kgr =
85885 compat_alloc_user_space(sizeof(struct group_req));
85886 u32 interface;
85887 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85888 case MCAST_BLOCK_SOURCE:
85889 case MCAST_UNBLOCK_SOURCE:
85890 {
85891 - struct compat_group_source_req __user *gsr32 = (void *)optval;
85892 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
85893 struct group_source_req __user *kgsr = compat_alloc_user_space(
85894 sizeof(struct group_source_req));
85895 u32 interface;
85896 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85897 }
85898 case MCAST_MSFILTER:
85899 {
85900 - struct compat_group_filter __user *gf32 = (void *)optval;
85901 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85902 struct group_filter __user *kgf;
85903 u32 interface, fmode, numsrc;
85904
85905 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
85906 char __user *optval, int __user *optlen,
85907 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
85908 {
85909 - struct compat_group_filter __user *gf32 = (void *)optval;
85910 + struct compat_group_filter __user *gf32 = (void __user *)optval;
85911 struct group_filter __user *kgf;
85912 int __user *koptlen;
85913 u32 interface, fmode, numsrc;
85914 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
85915
85916 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
85917 return -EINVAL;
85918 - if (copy_from_user(a, args, nas[call]))
85919 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
85920 return -EFAULT;
85921 a0 = a[0];
85922 a1 = a[1];
85923 diff --git a/net/core/datagram.c b/net/core/datagram.c
85924 index 368f9c3..f82d4a3 100644
85925 --- a/net/core/datagram.c
85926 +++ b/net/core/datagram.c
85927 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
85928 }
85929
85930 kfree_skb(skb);
85931 - atomic_inc(&sk->sk_drops);
85932 + atomic_inc_unchecked(&sk->sk_drops);
85933 sk_mem_reclaim_partial(sk);
85934
85935 return err;
85936 diff --git a/net/core/dev.c b/net/core/dev.c
85937 index 5d9c43d..b471558 100644
85938 --- a/net/core/dev.c
85939 +++ b/net/core/dev.c
85940 @@ -1250,9 +1250,13 @@ void dev_load(struct net *net, const char *name)
85941 if (no_module && capable(CAP_NET_ADMIN))
85942 no_module = request_module("netdev-%s", name);
85943 if (no_module && capable(CAP_SYS_MODULE)) {
85944 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
85945 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
85946 +#else
85947 if (!request_module("%s", name))
85948 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
85949 name);
85950 +#endif
85951 }
85952 }
85953 EXPORT_SYMBOL(dev_load);
85954 @@ -1714,7 +1718,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85955 {
85956 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
85957 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
85958 - atomic_long_inc(&dev->rx_dropped);
85959 + atomic_long_inc_unchecked(&dev->rx_dropped);
85960 kfree_skb(skb);
85961 return NET_RX_DROP;
85962 }
85963 @@ -1724,7 +1728,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
85964 nf_reset(skb);
85965
85966 if (unlikely(!is_skb_forwardable(dev, skb))) {
85967 - atomic_long_inc(&dev->rx_dropped);
85968 + atomic_long_inc_unchecked(&dev->rx_dropped);
85969 kfree_skb(skb);
85970 return NET_RX_DROP;
85971 }
85972 @@ -2179,7 +2183,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
85973
85974 struct dev_gso_cb {
85975 void (*destructor)(struct sk_buff *skb);
85976 -};
85977 +} __no_const;
85978
85979 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
85980
85981 @@ -3052,7 +3056,7 @@ enqueue:
85982
85983 local_irq_restore(flags);
85984
85985 - atomic_long_inc(&skb->dev->rx_dropped);
85986 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
85987 kfree_skb(skb);
85988 return NET_RX_DROP;
85989 }
85990 @@ -3124,7 +3128,7 @@ int netif_rx_ni(struct sk_buff *skb)
85991 }
85992 EXPORT_SYMBOL(netif_rx_ni);
85993
85994 -static void net_tx_action(struct softirq_action *h)
85995 +static void net_tx_action(void)
85996 {
85997 struct softnet_data *sd = &__get_cpu_var(softnet_data);
85998
85999 @@ -3462,7 +3466,7 @@ ncls:
86000 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86001 } else {
86002 drop:
86003 - atomic_long_inc(&skb->dev->rx_dropped);
86004 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86005 kfree_skb(skb);
86006 /* Jamal, now you will not able to escape explaining
86007 * me how you were going to use this. :-)
86008 @@ -4045,7 +4049,7 @@ void netif_napi_del(struct napi_struct *napi)
86009 }
86010 EXPORT_SYMBOL(netif_napi_del);
86011
86012 -static void net_rx_action(struct softirq_action *h)
86013 +static void net_rx_action(void)
86014 {
86015 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86016 unsigned long time_limit = jiffies + 2;
86017 @@ -4529,8 +4533,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86018 else
86019 seq_printf(seq, "%04x", ntohs(pt->type));
86020
86021 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86022 + seq_printf(seq, " %-8s %p\n",
86023 + pt->dev ? pt->dev->name : "", NULL);
86024 +#else
86025 seq_printf(seq, " %-8s %pF\n",
86026 pt->dev ? pt->dev->name : "", pt->func);
86027 +#endif
86028 }
86029
86030 return 0;
86031 @@ -6102,7 +6111,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86032 } else {
86033 netdev_stats_to_stats64(storage, &dev->stats);
86034 }
86035 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86036 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86037 return storage;
86038 }
86039 EXPORT_SYMBOL(dev_get_stats);
86040 diff --git a/net/core/flow.c b/net/core/flow.c
86041 index 3bad824..2071a55 100644
86042 --- a/net/core/flow.c
86043 +++ b/net/core/flow.c
86044 @@ -61,7 +61,7 @@ struct flow_cache {
86045 struct timer_list rnd_timer;
86046 };
86047
86048 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86049 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86050 EXPORT_SYMBOL(flow_cache_genid);
86051 static struct flow_cache flow_cache_global;
86052 static struct kmem_cache *flow_cachep __read_mostly;
86053 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86054
86055 static int flow_entry_valid(struct flow_cache_entry *fle)
86056 {
86057 - if (atomic_read(&flow_cache_genid) != fle->genid)
86058 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86059 return 0;
86060 if (fle->object && !fle->object->ops->check(fle->object))
86061 return 0;
86062 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86063 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86064 fcp->hash_count++;
86065 }
86066 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86067 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86068 flo = fle->object;
86069 if (!flo)
86070 goto ret_object;
86071 @@ -280,7 +280,7 @@ nocache:
86072 }
86073 flo = resolver(net, key, family, dir, flo, ctx);
86074 if (fle) {
86075 - fle->genid = atomic_read(&flow_cache_genid);
86076 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86077 if (!IS_ERR(flo))
86078 fle->object = flo;
86079 else
86080 diff --git a/net/core/iovec.c b/net/core/iovec.c
86081 index 7e7aeb0..2a998cb 100644
86082 --- a/net/core/iovec.c
86083 +++ b/net/core/iovec.c
86084 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86085 if (m->msg_namelen) {
86086 if (mode == VERIFY_READ) {
86087 void __user *namep;
86088 - namep = (void __user __force *) m->msg_name;
86089 + namep = (void __force_user *) m->msg_name;
86090 err = move_addr_to_kernel(namep, m->msg_namelen,
86091 address);
86092 if (err < 0)
86093 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86094 }
86095
86096 size = m->msg_iovlen * sizeof(struct iovec);
86097 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86098 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86099 return -EFAULT;
86100
86101 m->msg_iov = iov;
86102 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86103 index c815f28..e6403f2 100644
86104 --- a/net/core/neighbour.c
86105 +++ b/net/core/neighbour.c
86106 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86107 size_t *lenp, loff_t *ppos)
86108 {
86109 int size, ret;
86110 - ctl_table tmp = *ctl;
86111 + ctl_table_no_const tmp = *ctl;
86112
86113 tmp.extra1 = &zero;
86114 tmp.extra2 = &unres_qlen_max;
86115 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86116 index 28c5f5a..7edf2e2 100644
86117 --- a/net/core/net-sysfs.c
86118 +++ b/net/core/net-sysfs.c
86119 @@ -1455,7 +1455,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86120 }
86121 EXPORT_SYMBOL(netdev_class_remove_file);
86122
86123 -int netdev_kobject_init(void)
86124 +int __init netdev_kobject_init(void)
86125 {
86126 kobj_ns_type_register(&net_ns_type_operations);
86127 return class_register(&net_class);
86128 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86129 index 8acce01..2e306bb 100644
86130 --- a/net/core/net_namespace.c
86131 +++ b/net/core/net_namespace.c
86132 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
86133 int error;
86134 LIST_HEAD(net_exit_list);
86135
86136 - list_add_tail(&ops->list, list);
86137 + pax_list_add_tail((struct list_head *)&ops->list, list);
86138 if (ops->init || (ops->id && ops->size)) {
86139 for_each_net(net) {
86140 error = ops_init(ops, net);
86141 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
86142
86143 out_undo:
86144 /* If I have an error cleanup all namespaces I initialized */
86145 - list_del(&ops->list);
86146 + pax_list_del((struct list_head *)&ops->list);
86147 ops_exit_list(ops, &net_exit_list);
86148 ops_free_list(ops, &net_exit_list);
86149 return error;
86150 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86151 struct net *net;
86152 LIST_HEAD(net_exit_list);
86153
86154 - list_del(&ops->list);
86155 + pax_list_del((struct list_head *)&ops->list);
86156 for_each_net(net)
86157 list_add_tail(&net->exit_list, &net_exit_list);
86158 ops_exit_list(ops, &net_exit_list);
86159 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
86160 mutex_lock(&net_mutex);
86161 error = register_pernet_operations(&pernet_list, ops);
86162 if (!error && (first_device == &pernet_list))
86163 - first_device = &ops->list;
86164 + first_device = (struct list_head *)&ops->list;
86165 mutex_unlock(&net_mutex);
86166 return error;
86167 }
86168 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86169 index 6212ec9..5ee16b2 100644
86170 --- a/net/core/rtnetlink.c
86171 +++ b/net/core/rtnetlink.c
86172 @@ -58,7 +58,7 @@ struct rtnl_link {
86173 rtnl_doit_func doit;
86174 rtnl_dumpit_func dumpit;
86175 rtnl_calcit_func calcit;
86176 -};
86177 +} __no_const;
86178
86179 static DEFINE_MUTEX(rtnl_mutex);
86180
86181 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86182 if (rtnl_link_ops_get(ops->kind))
86183 return -EEXIST;
86184
86185 - if (!ops->dellink)
86186 - ops->dellink = unregister_netdevice_queue;
86187 + if (!ops->dellink) {
86188 + pax_open_kernel();
86189 + *(void **)&ops->dellink = unregister_netdevice_queue;
86190 + pax_close_kernel();
86191 + }
86192
86193 - list_add_tail(&ops->list, &link_ops);
86194 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86195 return 0;
86196 }
86197 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86198 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86199 for_each_net(net) {
86200 __rtnl_kill_links(net, ops);
86201 }
86202 - list_del(&ops->list);
86203 + pax_list_del((struct list_head *)&ops->list);
86204 }
86205 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86206
86207 @@ -1068,7 +1071,7 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
86208 rcu_read_lock();
86209 cb->seq = net->dev_base_seq;
86210
86211 - if (nlmsg_parse(cb->nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX,
86212 + if (nlmsg_parse(cb->nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
86213 ifla_policy) >= 0) {
86214
86215 if (tb[IFLA_EXT_MASK])
86216 @@ -1924,7 +1927,7 @@ static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh)
86217 u32 ext_filter_mask = 0;
86218 u16 min_ifinfo_dump_size = 0;
86219
86220 - if (nlmsg_parse(nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX,
86221 + if (nlmsg_parse(nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
86222 ifla_policy) >= 0) {
86223 if (tb[IFLA_EXT_MASK])
86224 ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
86225 diff --git a/net/core/scm.c b/net/core/scm.c
86226 index 2dc6cda..2159524 100644
86227 --- a/net/core/scm.c
86228 +++ b/net/core/scm.c
86229 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
86230 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86231 {
86232 struct cmsghdr __user *cm
86233 - = (__force struct cmsghdr __user *)msg->msg_control;
86234 + = (struct cmsghdr __force_user *)msg->msg_control;
86235 struct cmsghdr cmhdr;
86236 int cmlen = CMSG_LEN(len);
86237 int err;
86238 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86239 err = -EFAULT;
86240 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86241 goto out;
86242 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86243 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86244 goto out;
86245 cmlen = CMSG_SPACE(len);
86246 if (msg->msg_controllen < cmlen)
86247 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
86248 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86249 {
86250 struct cmsghdr __user *cm
86251 - = (__force struct cmsghdr __user*)msg->msg_control;
86252 + = (struct cmsghdr __force_user *)msg->msg_control;
86253
86254 int fdmax = 0;
86255 int fdnum = scm->fp->count;
86256 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86257 if (fdnum < fdmax)
86258 fdmax = fdnum;
86259
86260 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86261 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86262 i++, cmfptr++)
86263 {
86264 struct socket *sock;
86265 diff --git a/net/core/sock.c b/net/core/sock.c
86266 index bc131d4..029e378 100644
86267 --- a/net/core/sock.c
86268 +++ b/net/core/sock.c
86269 @@ -388,7 +388,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86270 struct sk_buff_head *list = &sk->sk_receive_queue;
86271
86272 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86273 - atomic_inc(&sk->sk_drops);
86274 + atomic_inc_unchecked(&sk->sk_drops);
86275 trace_sock_rcvqueue_full(sk, skb);
86276 return -ENOMEM;
86277 }
86278 @@ -398,7 +398,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86279 return err;
86280
86281 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86282 - atomic_inc(&sk->sk_drops);
86283 + atomic_inc_unchecked(&sk->sk_drops);
86284 return -ENOBUFS;
86285 }
86286
86287 @@ -418,7 +418,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86288 skb_dst_force(skb);
86289
86290 spin_lock_irqsave(&list->lock, flags);
86291 - skb->dropcount = atomic_read(&sk->sk_drops);
86292 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86293 __skb_queue_tail(list, skb);
86294 spin_unlock_irqrestore(&list->lock, flags);
86295
86296 @@ -438,7 +438,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86297 skb->dev = NULL;
86298
86299 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86300 - atomic_inc(&sk->sk_drops);
86301 + atomic_inc_unchecked(&sk->sk_drops);
86302 goto discard_and_relse;
86303 }
86304 if (nested)
86305 @@ -456,7 +456,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86306 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86307 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86308 bh_unlock_sock(sk);
86309 - atomic_inc(&sk->sk_drops);
86310 + atomic_inc_unchecked(&sk->sk_drops);
86311 goto discard_and_relse;
86312 }
86313
86314 @@ -930,12 +930,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86315 struct timeval tm;
86316 } v;
86317
86318 - int lv = sizeof(int);
86319 - int len;
86320 + unsigned int lv = sizeof(int);
86321 + unsigned int len;
86322
86323 if (get_user(len, optlen))
86324 return -EFAULT;
86325 - if (len < 0)
86326 + if (len > INT_MAX)
86327 return -EINVAL;
86328
86329 memset(&v, 0, sizeof(v));
86330 @@ -1083,11 +1083,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86331
86332 case SO_PEERNAME:
86333 {
86334 - char address[128];
86335 + char address[_K_SS_MAXSIZE];
86336
86337 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86338 return -ENOTCONN;
86339 - if (lv < len)
86340 + if (lv < len || sizeof address < len)
86341 return -EINVAL;
86342 if (copy_to_user(optval, address, len))
86343 return -EFAULT;
86344 @@ -1146,7 +1146,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86345
86346 if (len > lv)
86347 len = lv;
86348 - if (copy_to_user(optval, &v, len))
86349 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86350 return -EFAULT;
86351 lenout:
86352 if (put_user(len, optlen))
86353 @@ -2276,7 +2276,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86354 */
86355 smp_wmb();
86356 atomic_set(&sk->sk_refcnt, 1);
86357 - atomic_set(&sk->sk_drops, 0);
86358 + atomic_set_unchecked(&sk->sk_drops, 0);
86359 }
86360 EXPORT_SYMBOL(sock_init_data);
86361
86362 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86363 index 750f44f..922399c 100644
86364 --- a/net/core/sock_diag.c
86365 +++ b/net/core/sock_diag.c
86366 @@ -9,26 +9,33 @@
86367 #include <linux/inet_diag.h>
86368 #include <linux/sock_diag.h>
86369
86370 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86371 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86372 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86373 static DEFINE_MUTEX(sock_diag_table_mutex);
86374
86375 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86376 {
86377 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86378 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86379 cookie[1] != INET_DIAG_NOCOOKIE) &&
86380 ((u32)(unsigned long)sk != cookie[0] ||
86381 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86382 return -ESTALE;
86383 else
86384 +#endif
86385 return 0;
86386 }
86387 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86388
86389 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86390 {
86391 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86392 + cookie[0] = 0;
86393 + cookie[1] = 0;
86394 +#else
86395 cookie[0] = (u32)(unsigned long)sk;
86396 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86397 +#endif
86398 }
86399 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86400
86401 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86402 mutex_lock(&sock_diag_table_mutex);
86403 if (sock_diag_handlers[hndl->family])
86404 err = -EBUSY;
86405 - else
86406 + else {
86407 + pax_open_kernel();
86408 sock_diag_handlers[hndl->family] = hndl;
86409 + pax_close_kernel();
86410 + }
86411 mutex_unlock(&sock_diag_table_mutex);
86412
86413 return err;
86414 @@ -92,26 +102,13 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86415
86416 mutex_lock(&sock_diag_table_mutex);
86417 BUG_ON(sock_diag_handlers[family] != hnld);
86418 + pax_open_kernel();
86419 sock_diag_handlers[family] = NULL;
86420 + pax_close_kernel();
86421 mutex_unlock(&sock_diag_table_mutex);
86422 }
86423 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86424
86425 -static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
86426 -{
86427 - if (sock_diag_handlers[family] == NULL)
86428 - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86429 - NETLINK_SOCK_DIAG, family);
86430 -
86431 - mutex_lock(&sock_diag_table_mutex);
86432 - return sock_diag_handlers[family];
86433 -}
86434 -
86435 -static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
86436 -{
86437 - mutex_unlock(&sock_diag_table_mutex);
86438 -}
86439 -
86440 static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86441 {
86442 int err;
86443 @@ -124,12 +121,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86444 if (req->sdiag_family >= AF_MAX)
86445 return -EINVAL;
86446
86447 - hndl = sock_diag_lock_handler(req->sdiag_family);
86448 + if (sock_diag_handlers[req->sdiag_family] == NULL)
86449 + request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86450 + NETLINK_SOCK_DIAG, req->sdiag_family);
86451 +
86452 + mutex_lock(&sock_diag_table_mutex);
86453 + hndl = sock_diag_handlers[req->sdiag_family];
86454 if (hndl == NULL)
86455 err = -ENOENT;
86456 else
86457 err = hndl->dump(skb, nlh);
86458 - sock_diag_unlock_handler(hndl);
86459 + mutex_unlock(&sock_diag_table_mutex);
86460
86461 return err;
86462 }
86463 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86464 index d1b0804..98cf5f7 100644
86465 --- a/net/core/sysctl_net_core.c
86466 +++ b/net/core/sysctl_net_core.c
86467 @@ -26,7 +26,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86468 {
86469 unsigned int orig_size, size;
86470 int ret, i;
86471 - ctl_table tmp = {
86472 + ctl_table_no_const tmp = {
86473 .data = &size,
86474 .maxlen = sizeof(size),
86475 .mode = table->mode
86476 @@ -205,13 +205,12 @@ static struct ctl_table netns_core_table[] = {
86477
86478 static __net_init int sysctl_core_net_init(struct net *net)
86479 {
86480 - struct ctl_table *tbl;
86481 + ctl_table_no_const *tbl = NULL;
86482
86483 net->core.sysctl_somaxconn = SOMAXCONN;
86484
86485 - tbl = netns_core_table;
86486 if (!net_eq(net, &init_net)) {
86487 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86488 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86489 if (tbl == NULL)
86490 goto err_dup;
86491
86492 @@ -221,17 +220,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86493 if (net->user_ns != &init_user_ns) {
86494 tbl[0].procname = NULL;
86495 }
86496 - }
86497 -
86498 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86499 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86500 + } else
86501 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86502 if (net->core.sysctl_hdr == NULL)
86503 goto err_reg;
86504
86505 return 0;
86506
86507 err_reg:
86508 - if (tbl != netns_core_table)
86509 - kfree(tbl);
86510 + kfree(tbl);
86511 err_dup:
86512 return -ENOMEM;
86513 }
86514 @@ -246,7 +244,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86515 kfree(tbl);
86516 }
86517
86518 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86519 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86520 .init = sysctl_core_net_init,
86521 .exit = sysctl_core_net_exit,
86522 };
86523 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86524 index 307c322..78a4c6f 100644
86525 --- a/net/decnet/af_decnet.c
86526 +++ b/net/decnet/af_decnet.c
86527 @@ -468,6 +468,7 @@ static struct proto dn_proto = {
86528 .sysctl_rmem = sysctl_decnet_rmem,
86529 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86530 .obj_size = sizeof(struct dn_sock),
86531 + .slab_flags = SLAB_USERCOPY,
86532 };
86533
86534 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86535 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86536 index a55eecc..dd8428c 100644
86537 --- a/net/decnet/sysctl_net_decnet.c
86538 +++ b/net/decnet/sysctl_net_decnet.c
86539 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86540
86541 if (len > *lenp) len = *lenp;
86542
86543 - if (copy_to_user(buffer, addr, len))
86544 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86545 return -EFAULT;
86546
86547 *lenp = len;
86548 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86549
86550 if (len > *lenp) len = *lenp;
86551
86552 - if (copy_to_user(buffer, devname, len))
86553 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86554 return -EFAULT;
86555
86556 *lenp = len;
86557 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86558 index fcf104e..95552d4 100644
86559 --- a/net/ipv4/af_inet.c
86560 +++ b/net/ipv4/af_inet.c
86561 @@ -1717,13 +1717,9 @@ static int __init inet_init(void)
86562
86563 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
86564
86565 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86566 - if (!sysctl_local_reserved_ports)
86567 - goto out;
86568 -
86569 rc = proto_register(&tcp_prot, 1);
86570 if (rc)
86571 - goto out_free_reserved_ports;
86572 + goto out;
86573
86574 rc = proto_register(&udp_prot, 1);
86575 if (rc)
86576 @@ -1832,8 +1828,6 @@ out_unregister_udp_proto:
86577 proto_unregister(&udp_prot);
86578 out_unregister_tcp_proto:
86579 proto_unregister(&tcp_prot);
86580 -out_free_reserved_ports:
86581 - kfree(sysctl_local_reserved_ports);
86582 goto out;
86583 }
86584
86585 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86586 index a69b4e4..dbccba5 100644
86587 --- a/net/ipv4/ah4.c
86588 +++ b/net/ipv4/ah4.c
86589 @@ -421,7 +421,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86590 return;
86591
86592 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86593 - atomic_inc(&flow_cache_genid);
86594 + atomic_inc_unchecked(&flow_cache_genid);
86595 rt_genid_bump(net);
86596
86597 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86598 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86599 index a8e4f26..25e5f40 100644
86600 --- a/net/ipv4/devinet.c
86601 +++ b/net/ipv4/devinet.c
86602 @@ -1763,7 +1763,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86603 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86604 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86605
86606 -static struct devinet_sysctl_table {
86607 +static const struct devinet_sysctl_table {
86608 struct ctl_table_header *sysctl_header;
86609 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86610 } devinet_sysctl = {
86611 @@ -1881,7 +1881,7 @@ static __net_init int devinet_init_net(struct net *net)
86612 int err;
86613 struct ipv4_devconf *all, *dflt;
86614 #ifdef CONFIG_SYSCTL
86615 - struct ctl_table *tbl = ctl_forward_entry;
86616 + ctl_table_no_const *tbl = NULL;
86617 struct ctl_table_header *forw_hdr;
86618 #endif
86619
86620 @@ -1899,7 +1899,7 @@ static __net_init int devinet_init_net(struct net *net)
86621 goto err_alloc_dflt;
86622
86623 #ifdef CONFIG_SYSCTL
86624 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86625 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86626 if (tbl == NULL)
86627 goto err_alloc_ctl;
86628
86629 @@ -1919,7 +1919,10 @@ static __net_init int devinet_init_net(struct net *net)
86630 goto err_reg_dflt;
86631
86632 err = -ENOMEM;
86633 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86634 + if (!net_eq(net, &init_net))
86635 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86636 + else
86637 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
86638 if (forw_hdr == NULL)
86639 goto err_reg_ctl;
86640 net->ipv4.forw_hdr = forw_hdr;
86641 @@ -1935,8 +1938,7 @@ err_reg_ctl:
86642 err_reg_dflt:
86643 __devinet_sysctl_unregister(all);
86644 err_reg_all:
86645 - if (tbl != ctl_forward_entry)
86646 - kfree(tbl);
86647 + kfree(tbl);
86648 err_alloc_ctl:
86649 #endif
86650 if (dflt != &ipv4_devconf_dflt)
86651 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
86652 index 3b4f0cd..8cb864c 100644
86653 --- a/net/ipv4/esp4.c
86654 +++ b/net/ipv4/esp4.c
86655 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
86656 return;
86657
86658 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86659 - atomic_inc(&flow_cache_genid);
86660 + atomic_inc_unchecked(&flow_cache_genid);
86661 rt_genid_bump(net);
86662
86663 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
86664 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
86665 index 5cd75e2..f57ef39 100644
86666 --- a/net/ipv4/fib_frontend.c
86667 +++ b/net/ipv4/fib_frontend.c
86668 @@ -1020,12 +1020,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
86669 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86670 fib_sync_up(dev);
86671 #endif
86672 - atomic_inc(&net->ipv4.dev_addr_genid);
86673 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86674 rt_cache_flush(dev_net(dev));
86675 break;
86676 case NETDEV_DOWN:
86677 fib_del_ifaddr(ifa, NULL);
86678 - atomic_inc(&net->ipv4.dev_addr_genid);
86679 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86680 if (ifa->ifa_dev->ifa_list == NULL) {
86681 /* Last address was deleted from this interface.
86682 * Disable IP.
86683 @@ -1061,7 +1061,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
86684 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86685 fib_sync_up(dev);
86686 #endif
86687 - atomic_inc(&net->ipv4.dev_addr_genid);
86688 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86689 rt_cache_flush(net);
86690 break;
86691 case NETDEV_DOWN:
86692 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
86693 index 4797a80..2bd54e9 100644
86694 --- a/net/ipv4/fib_semantics.c
86695 +++ b/net/ipv4/fib_semantics.c
86696 @@ -767,7 +767,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
86697 nh->nh_saddr = inet_select_addr(nh->nh_dev,
86698 nh->nh_gw,
86699 nh->nh_parent->fib_scope);
86700 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
86701 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
86702
86703 return nh->nh_saddr;
86704 }
86705 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
86706 index d0670f0..744ac80 100644
86707 --- a/net/ipv4/inet_connection_sock.c
86708 +++ b/net/ipv4/inet_connection_sock.c
86709 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
86710 .range = { 32768, 61000 },
86711 };
86712
86713 -unsigned long *sysctl_local_reserved_ports;
86714 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
86715 EXPORT_SYMBOL(sysctl_local_reserved_ports);
86716
86717 void inet_get_local_port_range(int *low, int *high)
86718 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
86719 index fa3ae81..0dbe6b8 100644
86720 --- a/net/ipv4/inet_hashtables.c
86721 +++ b/net/ipv4/inet_hashtables.c
86722 @@ -18,12 +18,15 @@
86723 #include <linux/sched.h>
86724 #include <linux/slab.h>
86725 #include <linux/wait.h>
86726 +#include <linux/security.h>
86727
86728 #include <net/inet_connection_sock.h>
86729 #include <net/inet_hashtables.h>
86730 #include <net/secure_seq.h>
86731 #include <net/ip.h>
86732
86733 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
86734 +
86735 /*
86736 * Allocate and initialize a new local port bind bucket.
86737 * The bindhash mutex for snum's hash chain must be held here.
86738 @@ -540,6 +543,8 @@ ok:
86739 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
86740 spin_unlock(&head->lock);
86741
86742 + gr_update_task_in_ip_table(current, inet_sk(sk));
86743 +
86744 if (tw) {
86745 inet_twsk_deschedule(tw, death_row);
86746 while (twrefcnt) {
86747 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
86748 index 000e3d2..5472da3 100644
86749 --- a/net/ipv4/inetpeer.c
86750 +++ b/net/ipv4/inetpeer.c
86751 @@ -503,8 +503,8 @@ relookup:
86752 if (p) {
86753 p->daddr = *daddr;
86754 atomic_set(&p->refcnt, 1);
86755 - atomic_set(&p->rid, 0);
86756 - atomic_set(&p->ip_id_count,
86757 + atomic_set_unchecked(&p->rid, 0);
86758 + atomic_set_unchecked(&p->ip_id_count,
86759 (daddr->family == AF_INET) ?
86760 secure_ip_id(daddr->addr.a4) :
86761 secure_ipv6_id(daddr->addr.a6));
86762 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
86763 index a8fc332..4ca4ca65 100644
86764 --- a/net/ipv4/ip_fragment.c
86765 +++ b/net/ipv4/ip_fragment.c
86766 @@ -319,7 +319,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
86767 return 0;
86768
86769 start = qp->rid;
86770 - end = atomic_inc_return(&peer->rid);
86771 + end = atomic_inc_return_unchecked(&peer->rid);
86772 qp->rid = end;
86773
86774 rc = qp->q.fragments && (end - start) > max;
86775 @@ -786,12 +786,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
86776
86777 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86778 {
86779 - struct ctl_table *table;
86780 + ctl_table_no_const *table = NULL;
86781 struct ctl_table_header *hdr;
86782
86783 - table = ip4_frags_ns_ctl_table;
86784 if (!net_eq(net, &init_net)) {
86785 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86786 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86787 if (table == NULL)
86788 goto err_alloc;
86789
86790 @@ -802,9 +801,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86791 /* Don't export sysctls to unprivileged users */
86792 if (net->user_ns != &init_user_ns)
86793 table[0].procname = NULL;
86794 - }
86795 + hdr = register_net_sysctl(net, "net/ipv4", table);
86796 + } else
86797 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
86798
86799 - hdr = register_net_sysctl(net, "net/ipv4", table);
86800 if (hdr == NULL)
86801 goto err_reg;
86802
86803 @@ -812,8 +812,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86804 return 0;
86805
86806 err_reg:
86807 - if (!net_eq(net, &init_net))
86808 - kfree(table);
86809 + kfree(table);
86810 err_alloc:
86811 return -ENOMEM;
86812 }
86813 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
86814 index a85062b..2958a9b 100644
86815 --- a/net/ipv4/ip_gre.c
86816 +++ b/net/ipv4/ip_gre.c
86817 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
86818 module_param(log_ecn_error, bool, 0644);
86819 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
86820
86821 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
86822 +static struct rtnl_link_ops ipgre_link_ops;
86823 static int ipgre_tunnel_init(struct net_device *dev);
86824 static void ipgre_tunnel_setup(struct net_device *dev);
86825 static int ipgre_tunnel_bind_dev(struct net_device *dev);
86826 @@ -1753,7 +1753,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
86827 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
86828 };
86829
86830 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86831 +static struct rtnl_link_ops ipgre_link_ops = {
86832 .kind = "gre",
86833 .maxtype = IFLA_GRE_MAX,
86834 .policy = ipgre_policy,
86835 @@ -1766,7 +1766,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86836 .fill_info = ipgre_fill_info,
86837 };
86838
86839 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
86840 +static struct rtnl_link_ops ipgre_tap_ops = {
86841 .kind = "gretap",
86842 .maxtype = IFLA_GRE_MAX,
86843 .policy = ipgre_policy,
86844 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
86845 index d9c4f11..02b82dbc 100644
86846 --- a/net/ipv4/ip_sockglue.c
86847 +++ b/net/ipv4/ip_sockglue.c
86848 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86849 len = min_t(unsigned int, len, opt->optlen);
86850 if (put_user(len, optlen))
86851 return -EFAULT;
86852 - if (copy_to_user(optval, opt->__data, len))
86853 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
86854 + copy_to_user(optval, opt->__data, len))
86855 return -EFAULT;
86856 return 0;
86857 }
86858 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86859 if (sk->sk_type != SOCK_STREAM)
86860 return -ENOPROTOOPT;
86861
86862 - msg.msg_control = optval;
86863 + msg.msg_control = (void __force_kernel *)optval;
86864 msg.msg_controllen = len;
86865 msg.msg_flags = flags;
86866
86867 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
86868 index c3a4233..1412161 100644
86869 --- a/net/ipv4/ip_vti.c
86870 +++ b/net/ipv4/ip_vti.c
86871 @@ -47,7 +47,7 @@
86872 #define HASH_SIZE 16
86873 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
86874
86875 -static struct rtnl_link_ops vti_link_ops __read_mostly;
86876 +static struct rtnl_link_ops vti_link_ops;
86877
86878 static int vti_net_id __read_mostly;
86879 struct vti_net {
86880 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
86881 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
86882 };
86883
86884 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
86885 +static struct rtnl_link_ops vti_link_ops = {
86886 .kind = "vti",
86887 .maxtype = IFLA_VTI_MAX,
86888 .policy = vti_policy,
86889 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
86890 index 9a46dae..5f793a0 100644
86891 --- a/net/ipv4/ipcomp.c
86892 +++ b/net/ipv4/ipcomp.c
86893 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
86894 return;
86895
86896 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86897 - atomic_inc(&flow_cache_genid);
86898 + atomic_inc_unchecked(&flow_cache_genid);
86899 rt_genid_bump(net);
86900
86901 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
86902 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
86903 index a2e50ae..e152b7c 100644
86904 --- a/net/ipv4/ipconfig.c
86905 +++ b/net/ipv4/ipconfig.c
86906 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
86907
86908 mm_segment_t oldfs = get_fs();
86909 set_fs(get_ds());
86910 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86911 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86912 set_fs(oldfs);
86913 return res;
86914 }
86915 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
86916
86917 mm_segment_t oldfs = get_fs();
86918 set_fs(get_ds());
86919 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
86920 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
86921 set_fs(oldfs);
86922 return res;
86923 }
86924 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
86925
86926 mm_segment_t oldfs = get_fs();
86927 set_fs(get_ds());
86928 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
86929 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
86930 set_fs(oldfs);
86931 return res;
86932 }
86933 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
86934 index 191fc24..1b3b804 100644
86935 --- a/net/ipv4/ipip.c
86936 +++ b/net/ipv4/ipip.c
86937 @@ -138,7 +138,7 @@ struct ipip_net {
86938 static int ipip_tunnel_init(struct net_device *dev);
86939 static void ipip_tunnel_setup(struct net_device *dev);
86940 static void ipip_dev_free(struct net_device *dev);
86941 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
86942 +static struct rtnl_link_ops ipip_link_ops;
86943
86944 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
86945 struct rtnl_link_stats64 *tot)
86946 @@ -972,7 +972,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
86947 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
86948 };
86949
86950 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
86951 +static struct rtnl_link_ops ipip_link_ops = {
86952 .kind = "ipip",
86953 .maxtype = IFLA_IPTUN_MAX,
86954 .policy = ipip_policy,
86955 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
86956 index 3ea4127..849297b 100644
86957 --- a/net/ipv4/netfilter/arp_tables.c
86958 +++ b/net/ipv4/netfilter/arp_tables.c
86959 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
86960 #endif
86961
86962 static int get_info(struct net *net, void __user *user,
86963 - const int *len, int compat)
86964 + int len, int compat)
86965 {
86966 char name[XT_TABLE_MAXNAMELEN];
86967 struct xt_table *t;
86968 int ret;
86969
86970 - if (*len != sizeof(struct arpt_getinfo)) {
86971 - duprintf("length %u != %Zu\n", *len,
86972 + if (len != sizeof(struct arpt_getinfo)) {
86973 + duprintf("length %u != %Zu\n", len,
86974 sizeof(struct arpt_getinfo));
86975 return -EINVAL;
86976 }
86977 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
86978 info.size = private->size;
86979 strcpy(info.name, name);
86980
86981 - if (copy_to_user(user, &info, *len) != 0)
86982 + if (copy_to_user(user, &info, len) != 0)
86983 ret = -EFAULT;
86984 else
86985 ret = 0;
86986 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
86987
86988 switch (cmd) {
86989 case ARPT_SO_GET_INFO:
86990 - ret = get_info(sock_net(sk), user, len, 1);
86991 + ret = get_info(sock_net(sk), user, *len, 1);
86992 break;
86993 case ARPT_SO_GET_ENTRIES:
86994 ret = compat_get_entries(sock_net(sk), user, len);
86995 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
86996
86997 switch (cmd) {
86998 case ARPT_SO_GET_INFO:
86999 - ret = get_info(sock_net(sk), user, len, 0);
87000 + ret = get_info(sock_net(sk), user, *len, 0);
87001 break;
87002
87003 case ARPT_SO_GET_ENTRIES:
87004 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87005 index 17c5e06..1b91206 100644
87006 --- a/net/ipv4/netfilter/ip_tables.c
87007 +++ b/net/ipv4/netfilter/ip_tables.c
87008 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87009 #endif
87010
87011 static int get_info(struct net *net, void __user *user,
87012 - const int *len, int compat)
87013 + int len, int compat)
87014 {
87015 char name[XT_TABLE_MAXNAMELEN];
87016 struct xt_table *t;
87017 int ret;
87018
87019 - if (*len != sizeof(struct ipt_getinfo)) {
87020 - duprintf("length %u != %zu\n", *len,
87021 + if (len != sizeof(struct ipt_getinfo)) {
87022 + duprintf("length %u != %zu\n", len,
87023 sizeof(struct ipt_getinfo));
87024 return -EINVAL;
87025 }
87026 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87027 info.size = private->size;
87028 strcpy(info.name, name);
87029
87030 - if (copy_to_user(user, &info, *len) != 0)
87031 + if (copy_to_user(user, &info, len) != 0)
87032 ret = -EFAULT;
87033 else
87034 ret = 0;
87035 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87036
87037 switch (cmd) {
87038 case IPT_SO_GET_INFO:
87039 - ret = get_info(sock_net(sk), user, len, 1);
87040 + ret = get_info(sock_net(sk), user, *len, 1);
87041 break;
87042 case IPT_SO_GET_ENTRIES:
87043 ret = compat_get_entries(sock_net(sk), user, len);
87044 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87045
87046 switch (cmd) {
87047 case IPT_SO_GET_INFO:
87048 - ret = get_info(sock_net(sk), user, len, 0);
87049 + ret = get_info(sock_net(sk), user, *len, 0);
87050 break;
87051
87052 case IPT_SO_GET_ENTRIES:
87053 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87054 index dc454cc..5bb917f 100644
87055 --- a/net/ipv4/ping.c
87056 +++ b/net/ipv4/ping.c
87057 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87058 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87059 0, sock_i_ino(sp),
87060 atomic_read(&sp->sk_refcnt), sp,
87061 - atomic_read(&sp->sk_drops), len);
87062 + atomic_read_unchecked(&sp->sk_drops), len);
87063 }
87064
87065 static int ping_seq_show(struct seq_file *seq, void *v)
87066 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87067 index 6f08991..55867ad 100644
87068 --- a/net/ipv4/raw.c
87069 +++ b/net/ipv4/raw.c
87070 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87071 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87072 {
87073 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87074 - atomic_inc(&sk->sk_drops);
87075 + atomic_inc_unchecked(&sk->sk_drops);
87076 kfree_skb(skb);
87077 return NET_RX_DROP;
87078 }
87079 @@ -747,16 +747,20 @@ static int raw_init(struct sock *sk)
87080
87081 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87082 {
87083 + struct icmp_filter filter;
87084 +
87085 if (optlen > sizeof(struct icmp_filter))
87086 optlen = sizeof(struct icmp_filter);
87087 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87088 + if (copy_from_user(&filter, optval, optlen))
87089 return -EFAULT;
87090 + raw_sk(sk)->filter = filter;
87091 return 0;
87092 }
87093
87094 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87095 {
87096 int len, ret = -EFAULT;
87097 + struct icmp_filter filter;
87098
87099 if (get_user(len, optlen))
87100 goto out;
87101 @@ -766,8 +770,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87102 if (len > sizeof(struct icmp_filter))
87103 len = sizeof(struct icmp_filter);
87104 ret = -EFAULT;
87105 - if (put_user(len, optlen) ||
87106 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87107 + filter = raw_sk(sk)->filter;
87108 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87109 goto out;
87110 ret = 0;
87111 out: return ret;
87112 @@ -998,7 +1002,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87113 0, 0L, 0,
87114 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87115 0, sock_i_ino(sp),
87116 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87117 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87118 }
87119
87120 static int raw_seq_show(struct seq_file *seq, void *v)
87121 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87122 index a0fcc47..32e2c89 100644
87123 --- a/net/ipv4/route.c
87124 +++ b/net/ipv4/route.c
87125 @@ -2552,34 +2552,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87126 .maxlen = sizeof(int),
87127 .mode = 0200,
87128 .proc_handler = ipv4_sysctl_rtcache_flush,
87129 + .extra1 = &init_net,
87130 },
87131 { },
87132 };
87133
87134 static __net_init int sysctl_route_net_init(struct net *net)
87135 {
87136 - struct ctl_table *tbl;
87137 + ctl_table_no_const *tbl = NULL;
87138
87139 - tbl = ipv4_route_flush_table;
87140 if (!net_eq(net, &init_net)) {
87141 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87142 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87143 if (tbl == NULL)
87144 goto err_dup;
87145
87146 /* Don't export sysctls to unprivileged users */
87147 if (net->user_ns != &init_user_ns)
87148 tbl[0].procname = NULL;
87149 - }
87150 - tbl[0].extra1 = net;
87151 + tbl[0].extra1 = net;
87152 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87153 + } else
87154 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87155
87156 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87157 if (net->ipv4.route_hdr == NULL)
87158 goto err_reg;
87159 return 0;
87160
87161 err_reg:
87162 - if (tbl != ipv4_route_flush_table)
87163 - kfree(tbl);
87164 + kfree(tbl);
87165 err_dup:
87166 return -ENOMEM;
87167 }
87168 @@ -2602,7 +2602,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87169
87170 static __net_init int rt_genid_init(struct net *net)
87171 {
87172 - atomic_set(&net->rt_genid, 0);
87173 + atomic_set_unchecked(&net->rt_genid, 0);
87174 get_random_bytes(&net->ipv4.dev_addr_genid,
87175 sizeof(net->ipv4.dev_addr_genid));
87176 return 0;
87177 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87178 index d84400b..62e066e 100644
87179 --- a/net/ipv4/sysctl_net_ipv4.c
87180 +++ b/net/ipv4/sysctl_net_ipv4.c
87181 @@ -54,7 +54,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87182 {
87183 int ret;
87184 int range[2];
87185 - ctl_table tmp = {
87186 + ctl_table_no_const tmp = {
87187 .data = &range,
87188 .maxlen = sizeof(range),
87189 .mode = table->mode,
87190 @@ -107,7 +107,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87191 int ret;
87192 gid_t urange[2];
87193 kgid_t low, high;
87194 - ctl_table tmp = {
87195 + ctl_table_no_const tmp = {
87196 .data = &urange,
87197 .maxlen = sizeof(urange),
87198 .mode = table->mode,
87199 @@ -138,7 +138,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87200 void __user *buffer, size_t *lenp, loff_t *ppos)
87201 {
87202 char val[TCP_CA_NAME_MAX];
87203 - ctl_table tbl = {
87204 + ctl_table_no_const tbl = {
87205 .data = val,
87206 .maxlen = TCP_CA_NAME_MAX,
87207 };
87208 @@ -157,7 +157,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87209 void __user *buffer, size_t *lenp,
87210 loff_t *ppos)
87211 {
87212 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87213 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87214 int ret;
87215
87216 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87217 @@ -174,7 +174,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87218 void __user *buffer, size_t *lenp,
87219 loff_t *ppos)
87220 {
87221 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87222 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87223 int ret;
87224
87225 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87226 @@ -200,15 +200,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87227 struct mem_cgroup *memcg;
87228 #endif
87229
87230 - ctl_table tmp = {
87231 + ctl_table_no_const tmp = {
87232 .data = &vec,
87233 .maxlen = sizeof(vec),
87234 .mode = ctl->mode,
87235 };
87236
87237 if (!write) {
87238 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87239 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87240 + ctl_table_no_const tcp_mem = *ctl;
87241 +
87242 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87243 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87244 }
87245
87246 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87247 @@ -235,7 +237,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87248 int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87249 size_t *lenp, loff_t *ppos)
87250 {
87251 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87252 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87253 struct tcp_fastopen_context *ctxt;
87254 int ret;
87255 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87256 @@ -476,7 +478,7 @@ static struct ctl_table ipv4_table[] = {
87257 },
87258 {
87259 .procname = "ip_local_reserved_ports",
87260 - .data = NULL, /* initialized in sysctl_ipv4_init */
87261 + .data = sysctl_local_reserved_ports,
87262 .maxlen = 65536,
87263 .mode = 0644,
87264 .proc_handler = proc_do_large_bitmap,
87265 @@ -860,11 +862,10 @@ static struct ctl_table ipv4_net_table[] = {
87266
87267 static __net_init int ipv4_sysctl_init_net(struct net *net)
87268 {
87269 - struct ctl_table *table;
87270 + ctl_table_no_const *table = NULL;
87271
87272 - table = ipv4_net_table;
87273 if (!net_eq(net, &init_net)) {
87274 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87275 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87276 if (table == NULL)
87277 goto err_alloc;
87278
87279 @@ -897,15 +898,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87280
87281 tcp_init_mem(net);
87282
87283 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87284 + if (!net_eq(net, &init_net))
87285 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87286 + else
87287 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87288 if (net->ipv4.ipv4_hdr == NULL)
87289 goto err_reg;
87290
87291 return 0;
87292
87293 err_reg:
87294 - if (!net_eq(net, &init_net))
87295 - kfree(table);
87296 + kfree(table);
87297 err_alloc:
87298 return -ENOMEM;
87299 }
87300 @@ -927,16 +930,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87301 static __init int sysctl_ipv4_init(void)
87302 {
87303 struct ctl_table_header *hdr;
87304 - struct ctl_table *i;
87305 -
87306 - for (i = ipv4_table; i->procname; i++) {
87307 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87308 - i->data = sysctl_local_reserved_ports;
87309 - break;
87310 - }
87311 - }
87312 - if (!i->procname)
87313 - return -EINVAL;
87314
87315 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87316 if (hdr == NULL)
87317 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87318 index 9841a71..ef60409 100644
87319 --- a/net/ipv4/tcp_input.c
87320 +++ b/net/ipv4/tcp_input.c
87321 @@ -4730,7 +4730,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87322 * simplifies code)
87323 */
87324 static void
87325 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87326 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87327 struct sk_buff *head, struct sk_buff *tail,
87328 u32 start, u32 end)
87329 {
87330 @@ -5847,6 +5847,7 @@ discard:
87331 tcp_paws_reject(&tp->rx_opt, 0))
87332 goto discard_and_undo;
87333
87334 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87335 if (th->syn) {
87336 /* We see SYN without ACK. It is attempt of
87337 * simultaneous connect with crossed SYNs.
87338 @@ -5897,6 +5898,7 @@ discard:
87339 goto discard;
87340 #endif
87341 }
87342 +#endif
87343 /* "fifth, if neither of the SYN or RST bits is set then
87344 * drop the segment and return."
87345 */
87346 @@ -5941,7 +5943,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87347 goto discard;
87348
87349 if (th->syn) {
87350 - if (th->fin)
87351 + if (th->fin || th->urg || th->psh)
87352 goto discard;
87353 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87354 return 1;
87355 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87356 index d9130a9..00328ff 100644
87357 --- a/net/ipv4/tcp_ipv4.c
87358 +++ b/net/ipv4/tcp_ipv4.c
87359 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87360 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87361
87362
87363 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87364 +extern int grsec_enable_blackhole;
87365 +#endif
87366 +
87367 #ifdef CONFIG_TCP_MD5SIG
87368 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87369 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87370 @@ -1895,6 +1899,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87371 return 0;
87372
87373 reset:
87374 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87375 + if (!grsec_enable_blackhole)
87376 +#endif
87377 tcp_v4_send_reset(rsk, skb);
87378 discard:
87379 kfree_skb(skb);
87380 @@ -1994,12 +2001,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87381 TCP_SKB_CB(skb)->sacked = 0;
87382
87383 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87384 - if (!sk)
87385 + if (!sk) {
87386 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87387 + ret = 1;
87388 +#endif
87389 goto no_tcp_socket;
87390 -
87391 + }
87392 process:
87393 - if (sk->sk_state == TCP_TIME_WAIT)
87394 + if (sk->sk_state == TCP_TIME_WAIT) {
87395 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87396 + ret = 2;
87397 +#endif
87398 goto do_time_wait;
87399 + }
87400
87401 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87402 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87403 @@ -2050,6 +2064,10 @@ no_tcp_socket:
87404 bad_packet:
87405 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87406 } else {
87407 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87408 + if (!grsec_enable_blackhole || (ret == 1 &&
87409 + (skb->dev->flags & IFF_LOOPBACK)))
87410 +#endif
87411 tcp_v4_send_reset(NULL, skb);
87412 }
87413
87414 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87415 index f35f2df..ccb5ca6 100644
87416 --- a/net/ipv4/tcp_minisocks.c
87417 +++ b/net/ipv4/tcp_minisocks.c
87418 @@ -27,6 +27,10 @@
87419 #include <net/inet_common.h>
87420 #include <net/xfrm.h>
87421
87422 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87423 +extern int grsec_enable_blackhole;
87424 +#endif
87425 +
87426 int sysctl_tcp_syncookies __read_mostly = 1;
87427 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87428
87429 @@ -742,7 +746,10 @@ embryonic_reset:
87430 * avoid becoming vulnerable to outside attack aiming at
87431 * resetting legit local connections.
87432 */
87433 - req->rsk_ops->send_reset(sk, skb);
87434 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87435 + if (!grsec_enable_blackhole)
87436 +#endif
87437 + req->rsk_ops->send_reset(sk, skb);
87438 } else if (fastopen) { /* received a valid RST pkt */
87439 reqsk_fastopen_remove(sk, req, true);
87440 tcp_reset(sk);
87441 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87442 index 4526fe6..1a34e43 100644
87443 --- a/net/ipv4/tcp_probe.c
87444 +++ b/net/ipv4/tcp_probe.c
87445 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87446 if (cnt + width >= len)
87447 break;
87448
87449 - if (copy_to_user(buf + cnt, tbuf, width))
87450 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87451 return -EFAULT;
87452 cnt += width;
87453 }
87454 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87455 index b78aac3..e18230b 100644
87456 --- a/net/ipv4/tcp_timer.c
87457 +++ b/net/ipv4/tcp_timer.c
87458 @@ -22,6 +22,10 @@
87459 #include <linux/gfp.h>
87460 #include <net/tcp.h>
87461
87462 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87463 +extern int grsec_lastack_retries;
87464 +#endif
87465 +
87466 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87467 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87468 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87469 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87470 }
87471 }
87472
87473 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87474 + if ((sk->sk_state == TCP_LAST_ACK) &&
87475 + (grsec_lastack_retries > 0) &&
87476 + (grsec_lastack_retries < retry_until))
87477 + retry_until = grsec_lastack_retries;
87478 +#endif
87479 +
87480 if (retransmits_timed_out(sk, retry_until,
87481 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87482 /* Has it gone just too far? */
87483 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87484 index 1f4d405..3524677 100644
87485 --- a/net/ipv4/udp.c
87486 +++ b/net/ipv4/udp.c
87487 @@ -87,6 +87,7 @@
87488 #include <linux/types.h>
87489 #include <linux/fcntl.h>
87490 #include <linux/module.h>
87491 +#include <linux/security.h>
87492 #include <linux/socket.h>
87493 #include <linux/sockios.h>
87494 #include <linux/igmp.h>
87495 @@ -111,6 +112,10 @@
87496 #include <trace/events/skb.h>
87497 #include "udp_impl.h"
87498
87499 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87500 +extern int grsec_enable_blackhole;
87501 +#endif
87502 +
87503 struct udp_table udp_table __read_mostly;
87504 EXPORT_SYMBOL(udp_table);
87505
87506 @@ -569,6 +574,9 @@ found:
87507 return s;
87508 }
87509
87510 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87511 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87512 +
87513 /*
87514 * This routine is called by the ICMP module when it gets some
87515 * sort of error condition. If err < 0 then the socket should
87516 @@ -864,9 +872,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87517 dport = usin->sin_port;
87518 if (dport == 0)
87519 return -EINVAL;
87520 +
87521 + err = gr_search_udp_sendmsg(sk, usin);
87522 + if (err)
87523 + return err;
87524 } else {
87525 if (sk->sk_state != TCP_ESTABLISHED)
87526 return -EDESTADDRREQ;
87527 +
87528 + err = gr_search_udp_sendmsg(sk, NULL);
87529 + if (err)
87530 + return err;
87531 +
87532 daddr = inet->inet_daddr;
87533 dport = inet->inet_dport;
87534 /* Open fast path for connected socket.
87535 @@ -1108,7 +1125,7 @@ static unsigned int first_packet_length(struct sock *sk)
87536 udp_lib_checksum_complete(skb)) {
87537 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87538 IS_UDPLITE(sk));
87539 - atomic_inc(&sk->sk_drops);
87540 + atomic_inc_unchecked(&sk->sk_drops);
87541 __skb_unlink(skb, rcvq);
87542 __skb_queue_tail(&list_kill, skb);
87543 }
87544 @@ -1194,6 +1211,10 @@ try_again:
87545 if (!skb)
87546 goto out;
87547
87548 + err = gr_search_udp_recvmsg(sk, skb);
87549 + if (err)
87550 + goto out_free;
87551 +
87552 ulen = skb->len - sizeof(struct udphdr);
87553 copied = len;
87554 if (copied > ulen)
87555 @@ -1227,7 +1248,7 @@ try_again:
87556 if (unlikely(err)) {
87557 trace_kfree_skb(skb, udp_recvmsg);
87558 if (!peeked) {
87559 - atomic_inc(&sk->sk_drops);
87560 + atomic_inc_unchecked(&sk->sk_drops);
87561 UDP_INC_STATS_USER(sock_net(sk),
87562 UDP_MIB_INERRORS, is_udplite);
87563 }
87564 @@ -1510,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87565
87566 drop:
87567 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87568 - atomic_inc(&sk->sk_drops);
87569 + atomic_inc_unchecked(&sk->sk_drops);
87570 kfree_skb(skb);
87571 return -1;
87572 }
87573 @@ -1529,7 +1550,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87574 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87575
87576 if (!skb1) {
87577 - atomic_inc(&sk->sk_drops);
87578 + atomic_inc_unchecked(&sk->sk_drops);
87579 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87580 IS_UDPLITE(sk));
87581 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87582 @@ -1698,6 +1719,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87583 goto csum_error;
87584
87585 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87586 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87587 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87588 +#endif
87589 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87590
87591 /*
87592 @@ -2120,7 +2144,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87593 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87594 0, sock_i_ino(sp),
87595 atomic_read(&sp->sk_refcnt), sp,
87596 - atomic_read(&sp->sk_drops), len);
87597 + atomic_read_unchecked(&sp->sk_drops), len);
87598 }
87599
87600 int udp4_seq_show(struct seq_file *seq, void *v)
87601 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
87602 index a36d17e..96d099f 100644
87603 --- a/net/ipv6/addrconf.c
87604 +++ b/net/ipv6/addrconf.c
87605 @@ -2272,7 +2272,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
87606 p.iph.ihl = 5;
87607 p.iph.protocol = IPPROTO_IPV6;
87608 p.iph.ttl = 64;
87609 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
87610 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
87611
87612 if (ops->ndo_do_ioctl) {
87613 mm_segment_t oldfs = get_fs();
87614 @@ -4388,7 +4388,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
87615 int *valp = ctl->data;
87616 int val = *valp;
87617 loff_t pos = *ppos;
87618 - ctl_table lctl;
87619 + ctl_table_no_const lctl;
87620 int ret;
87621
87622 /*
87623 @@ -4470,7 +4470,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
87624 int *valp = ctl->data;
87625 int val = *valp;
87626 loff_t pos = *ppos;
87627 - ctl_table lctl;
87628 + ctl_table_no_const lctl;
87629 int ret;
87630
87631 /*
87632 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
87633 index fff5bdd..15194fb 100644
87634 --- a/net/ipv6/icmp.c
87635 +++ b/net/ipv6/icmp.c
87636 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
87637
87638 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
87639 {
87640 - struct ctl_table *table;
87641 + ctl_table_no_const *table;
87642
87643 table = kmemdup(ipv6_icmp_table_template,
87644 sizeof(ipv6_icmp_table_template),
87645 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
87646 index 131dd09..f7ed64f 100644
87647 --- a/net/ipv6/ip6_gre.c
87648 +++ b/net/ipv6/ip6_gre.c
87649 @@ -73,7 +73,7 @@ struct ip6gre_net {
87650 struct net_device *fb_tunnel_dev;
87651 };
87652
87653 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
87654 +static struct rtnl_link_ops ip6gre_link_ops;
87655 static int ip6gre_tunnel_init(struct net_device *dev);
87656 static void ip6gre_tunnel_setup(struct net_device *dev);
87657 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
87658 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
87659 }
87660
87661
87662 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
87663 +static struct inet6_protocol ip6gre_protocol = {
87664 .handler = ip6gre_rcv,
87665 .err_handler = ip6gre_err,
87666 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
87667 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
87668 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
87669 };
87670
87671 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87672 +static struct rtnl_link_ops ip6gre_link_ops = {
87673 .kind = "ip6gre",
87674 .maxtype = IFLA_GRE_MAX,
87675 .policy = ip6gre_policy,
87676 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87677 .fill_info = ip6gre_fill_info,
87678 };
87679
87680 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
87681 +static struct rtnl_link_ops ip6gre_tap_ops = {
87682 .kind = "ip6gretap",
87683 .maxtype = IFLA_GRE_MAX,
87684 .policy = ip6gre_policy,
87685 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
87686 index a14f28b..b4b8956 100644
87687 --- a/net/ipv6/ip6_tunnel.c
87688 +++ b/net/ipv6/ip6_tunnel.c
87689 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
87690
87691 static int ip6_tnl_dev_init(struct net_device *dev);
87692 static void ip6_tnl_dev_setup(struct net_device *dev);
87693 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
87694 +static struct rtnl_link_ops ip6_link_ops;
87695
87696 static int ip6_tnl_net_id __read_mostly;
87697 struct ip6_tnl_net {
87698 @@ -1686,7 +1686,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
87699 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
87700 };
87701
87702 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
87703 +static struct rtnl_link_ops ip6_link_ops = {
87704 .kind = "ip6tnl",
87705 .maxtype = IFLA_IPTUN_MAX,
87706 .policy = ip6_tnl_policy,
87707 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
87708 index d1e2e8e..51c19ae 100644
87709 --- a/net/ipv6/ipv6_sockglue.c
87710 +++ b/net/ipv6/ipv6_sockglue.c
87711 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
87712 if (sk->sk_type != SOCK_STREAM)
87713 return -ENOPROTOOPT;
87714
87715 - msg.msg_control = optval;
87716 + msg.msg_control = (void __force_kernel *)optval;
87717 msg.msg_controllen = len;
87718 msg.msg_flags = flags;
87719
87720 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
87721 index 125a90d..2a11f36 100644
87722 --- a/net/ipv6/netfilter/ip6_tables.c
87723 +++ b/net/ipv6/netfilter/ip6_tables.c
87724 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
87725 #endif
87726
87727 static int get_info(struct net *net, void __user *user,
87728 - const int *len, int compat)
87729 + int len, int compat)
87730 {
87731 char name[XT_TABLE_MAXNAMELEN];
87732 struct xt_table *t;
87733 int ret;
87734
87735 - if (*len != sizeof(struct ip6t_getinfo)) {
87736 - duprintf("length %u != %zu\n", *len,
87737 + if (len != sizeof(struct ip6t_getinfo)) {
87738 + duprintf("length %u != %zu\n", len,
87739 sizeof(struct ip6t_getinfo));
87740 return -EINVAL;
87741 }
87742 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
87743 info.size = private->size;
87744 strcpy(info.name, name);
87745
87746 - if (copy_to_user(user, &info, *len) != 0)
87747 + if (copy_to_user(user, &info, len) != 0)
87748 ret = -EFAULT;
87749 else
87750 ret = 0;
87751 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87752
87753 switch (cmd) {
87754 case IP6T_SO_GET_INFO:
87755 - ret = get_info(sock_net(sk), user, len, 1);
87756 + ret = get_info(sock_net(sk), user, *len, 1);
87757 break;
87758 case IP6T_SO_GET_ENTRIES:
87759 ret = compat_get_entries(sock_net(sk), user, len);
87760 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87761
87762 switch (cmd) {
87763 case IP6T_SO_GET_INFO:
87764 - ret = get_info(sock_net(sk), user, len, 0);
87765 + ret = get_info(sock_net(sk), user, *len, 0);
87766 break;
87767
87768 case IP6T_SO_GET_ENTRIES:
87769 diff --git a/net/ipv6/netfilter/ip6t_NPT.c b/net/ipv6/netfilter/ip6t_NPT.c
87770 index 83acc14..0ea43c7 100644
87771 --- a/net/ipv6/netfilter/ip6t_NPT.c
87772 +++ b/net/ipv6/netfilter/ip6t_NPT.c
87773 @@ -57,7 +57,7 @@ static bool ip6t_npt_map_pfx(const struct ip6t_npt_tginfo *npt,
87774 if (pfx_len - i >= 32)
87775 mask = 0;
87776 else
87777 - mask = htonl(~((1 << (pfx_len - i)) - 1));
87778 + mask = htonl((1 << (i - pfx_len + 32)) - 1);
87779
87780 idx = i / 32;
87781 addr->s6_addr32[idx] &= mask;
87782 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
87783 index 2f3a018..8bca195 100644
87784 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
87785 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
87786 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
87787
87788 static int nf_ct_frag6_sysctl_register(struct net *net)
87789 {
87790 - struct ctl_table *table;
87791 + ctl_table_no_const *table = NULL;
87792 struct ctl_table_header *hdr;
87793
87794 - table = nf_ct_frag6_sysctl_table;
87795 if (!net_eq(net, &init_net)) {
87796 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
87797 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
87798 GFP_KERNEL);
87799 if (table == NULL)
87800 goto err_alloc;
87801 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87802 table[0].data = &net->ipv6.frags.high_thresh;
87803 table[1].data = &net->ipv6.frags.low_thresh;
87804 table[2].data = &net->ipv6.frags.timeout;
87805 - }
87806 -
87807 - hdr = register_net_sysctl(net, "net/netfilter", table);
87808 + hdr = register_net_sysctl(net, "net/netfilter", table);
87809 + } else
87810 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
87811 if (hdr == NULL)
87812 goto err_reg;
87813
87814 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87815 return 0;
87816
87817 err_reg:
87818 - if (!net_eq(net, &init_net))
87819 - kfree(table);
87820 + kfree(table);
87821 err_alloc:
87822 return -ENOMEM;
87823 }
87824 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
87825 index 70fa814..d70c28c 100644
87826 --- a/net/ipv6/raw.c
87827 +++ b/net/ipv6/raw.c
87828 @@ -379,7 +379,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
87829 {
87830 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
87831 skb_checksum_complete(skb)) {
87832 - atomic_inc(&sk->sk_drops);
87833 + atomic_inc_unchecked(&sk->sk_drops);
87834 kfree_skb(skb);
87835 return NET_RX_DROP;
87836 }
87837 @@ -407,7 +407,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87838 struct raw6_sock *rp = raw6_sk(sk);
87839
87840 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
87841 - atomic_inc(&sk->sk_drops);
87842 + atomic_inc_unchecked(&sk->sk_drops);
87843 kfree_skb(skb);
87844 return NET_RX_DROP;
87845 }
87846 @@ -431,7 +431,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87847
87848 if (inet->hdrincl) {
87849 if (skb_checksum_complete(skb)) {
87850 - atomic_inc(&sk->sk_drops);
87851 + atomic_inc_unchecked(&sk->sk_drops);
87852 kfree_skb(skb);
87853 return NET_RX_DROP;
87854 }
87855 @@ -604,7 +604,7 @@ out:
87856 return err;
87857 }
87858
87859 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
87860 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
87861 struct flowi6 *fl6, struct dst_entry **dstp,
87862 unsigned int flags)
87863 {
87864 @@ -916,12 +916,15 @@ do_confirm:
87865 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
87866 char __user *optval, int optlen)
87867 {
87868 + struct icmp6_filter filter;
87869 +
87870 switch (optname) {
87871 case ICMPV6_FILTER:
87872 if (optlen > sizeof(struct icmp6_filter))
87873 optlen = sizeof(struct icmp6_filter);
87874 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
87875 + if (copy_from_user(&filter, optval, optlen))
87876 return -EFAULT;
87877 + raw6_sk(sk)->filter = filter;
87878 return 0;
87879 default:
87880 return -ENOPROTOOPT;
87881 @@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87882 char __user *optval, int __user *optlen)
87883 {
87884 int len;
87885 + struct icmp6_filter filter;
87886
87887 switch (optname) {
87888 case ICMPV6_FILTER:
87889 @@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87890 len = sizeof(struct icmp6_filter);
87891 if (put_user(len, optlen))
87892 return -EFAULT;
87893 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
87894 + filter = raw6_sk(sk)->filter;
87895 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
87896 return -EFAULT;
87897 return 0;
87898 default:
87899 @@ -1253,7 +1258,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87900 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87901 0,
87902 sock_i_ino(sp),
87903 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87904 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87905 }
87906
87907 static int raw6_seq_show(struct seq_file *seq, void *v)
87908 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
87909 index d9ba8a2..f3f9e14 100644
87910 --- a/net/ipv6/reassembly.c
87911 +++ b/net/ipv6/reassembly.c
87912 @@ -608,12 +608,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
87913
87914 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87915 {
87916 - struct ctl_table *table;
87917 + ctl_table_no_const *table = NULL;
87918 struct ctl_table_header *hdr;
87919
87920 - table = ip6_frags_ns_ctl_table;
87921 if (!net_eq(net, &init_net)) {
87922 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87923 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
87924 if (table == NULL)
87925 goto err_alloc;
87926
87927 @@ -624,9 +623,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87928 /* Don't export sysctls to unprivileged users */
87929 if (net->user_ns != &init_user_ns)
87930 table[0].procname = NULL;
87931 - }
87932 + hdr = register_net_sysctl(net, "net/ipv6", table);
87933 + } else
87934 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
87935
87936 - hdr = register_net_sysctl(net, "net/ipv6", table);
87937 if (hdr == NULL)
87938 goto err_reg;
87939
87940 @@ -634,8 +634,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
87941 return 0;
87942
87943 err_reg:
87944 - if (!net_eq(net, &init_net))
87945 - kfree(table);
87946 + kfree(table);
87947 err_alloc:
87948 return -ENOMEM;
87949 }
87950 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
87951 index 5845613..3af8fc7 100644
87952 --- a/net/ipv6/route.c
87953 +++ b/net/ipv6/route.c
87954 @@ -2966,7 +2966,7 @@ ctl_table ipv6_route_table_template[] = {
87955
87956 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
87957 {
87958 - struct ctl_table *table;
87959 + ctl_table_no_const *table;
87960
87961 table = kmemdup(ipv6_route_table_template,
87962 sizeof(ipv6_route_table_template),
87963 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
87964 index cfba99b..20ca511 100644
87965 --- a/net/ipv6/sit.c
87966 +++ b/net/ipv6/sit.c
87967 @@ -72,7 +72,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87968 static int ipip6_tunnel_init(struct net_device *dev);
87969 static void ipip6_tunnel_setup(struct net_device *dev);
87970 static void ipip6_dev_free(struct net_device *dev);
87971 -static struct rtnl_link_ops sit_link_ops __read_mostly;
87972 +static struct rtnl_link_ops sit_link_ops;
87973
87974 static int sit_net_id __read_mostly;
87975 struct sit_net {
87976 @@ -1463,7 +1463,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
87977 #endif
87978 };
87979
87980 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
87981 +static struct rtnl_link_ops sit_link_ops = {
87982 .kind = "sit",
87983 .maxtype = IFLA_IPTUN_MAX,
87984 .policy = ipip6_policy,
87985 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
87986 index e85c48b..b8268d3 100644
87987 --- a/net/ipv6/sysctl_net_ipv6.c
87988 +++ b/net/ipv6/sysctl_net_ipv6.c
87989 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
87990
87991 static int __net_init ipv6_sysctl_net_init(struct net *net)
87992 {
87993 - struct ctl_table *ipv6_table;
87994 + ctl_table_no_const *ipv6_table;
87995 struct ctl_table *ipv6_route_table;
87996 struct ctl_table *ipv6_icmp_table;
87997 int err;
87998 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
87999 index 8d19346..f122ba5 100644
88000 --- a/net/ipv6/tcp_ipv6.c
88001 +++ b/net/ipv6/tcp_ipv6.c
88002 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88003 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88004 }
88005
88006 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88007 +extern int grsec_enable_blackhole;
88008 +#endif
88009 +
88010 static void tcp_v6_hash(struct sock *sk)
88011 {
88012 if (sk->sk_state != TCP_CLOSE) {
88013 @@ -386,6 +390,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
88014
88015 if (dst)
88016 dst->ops->redirect(dst, sk, skb);
88017 + goto out;
88018 }
88019
88020 if (type == ICMPV6_PKT_TOOBIG) {
88021 @@ -1440,6 +1445,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88022 return 0;
88023
88024 reset:
88025 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88026 + if (!grsec_enable_blackhole)
88027 +#endif
88028 tcp_v6_send_reset(sk, skb);
88029 discard:
88030 if (opt_skb)
88031 @@ -1521,12 +1529,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88032 TCP_SKB_CB(skb)->sacked = 0;
88033
88034 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88035 - if (!sk)
88036 + if (!sk) {
88037 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88038 + ret = 1;
88039 +#endif
88040 goto no_tcp_socket;
88041 + }
88042
88043 process:
88044 - if (sk->sk_state == TCP_TIME_WAIT)
88045 + if (sk->sk_state == TCP_TIME_WAIT) {
88046 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88047 + ret = 2;
88048 +#endif
88049 goto do_time_wait;
88050 + }
88051
88052 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88053 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88054 @@ -1575,6 +1591,10 @@ no_tcp_socket:
88055 bad_packet:
88056 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88057 } else {
88058 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88059 + if (!grsec_enable_blackhole || (ret == 1 &&
88060 + (skb->dev->flags & IFF_LOOPBACK)))
88061 +#endif
88062 tcp_v6_send_reset(NULL, skb);
88063 }
88064
88065 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88066 index fb08329..2d6919e 100644
88067 --- a/net/ipv6/udp.c
88068 +++ b/net/ipv6/udp.c
88069 @@ -51,6 +51,10 @@
88070 #include <trace/events/skb.h>
88071 #include "udp_impl.h"
88072
88073 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88074 +extern int grsec_enable_blackhole;
88075 +#endif
88076 +
88077 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88078 {
88079 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88080 @@ -395,7 +399,7 @@ try_again:
88081 if (unlikely(err)) {
88082 trace_kfree_skb(skb, udpv6_recvmsg);
88083 if (!peeked) {
88084 - atomic_inc(&sk->sk_drops);
88085 + atomic_inc_unchecked(&sk->sk_drops);
88086 if (is_udp4)
88087 UDP_INC_STATS_USER(sock_net(sk),
88088 UDP_MIB_INERRORS,
88089 @@ -633,7 +637,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
88090 return rc;
88091 drop:
88092 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88093 - atomic_inc(&sk->sk_drops);
88094 + atomic_inc_unchecked(&sk->sk_drops);
88095 kfree_skb(skb);
88096 return -1;
88097 }
88098 @@ -691,7 +695,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88099 if (likely(skb1 == NULL))
88100 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88101 if (!skb1) {
88102 - atomic_inc(&sk->sk_drops);
88103 + atomic_inc_unchecked(&sk->sk_drops);
88104 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88105 IS_UDPLITE(sk));
88106 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88107 @@ -862,6 +866,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88108 goto discard;
88109
88110 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88111 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88112 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88113 +#endif
88114 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88115
88116 kfree_skb(skb);
88117 @@ -1379,7 +1386,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88118 0,
88119 sock_i_ino(sp),
88120 atomic_read(&sp->sk_refcnt), sp,
88121 - atomic_read(&sp->sk_drops));
88122 + atomic_read_unchecked(&sp->sk_drops));
88123 }
88124
88125 int udp6_seq_show(struct seq_file *seq, void *v)
88126 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
88127 index a68c88c..d55b0c5 100644
88128 --- a/net/irda/ircomm/ircomm_tty.c
88129 +++ b/net/irda/ircomm/ircomm_tty.c
88130 @@ -312,12 +312,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88131 add_wait_queue(&port->open_wait, &wait);
88132
88133 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
88134 - __FILE__, __LINE__, tty->driver->name, port->count);
88135 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88136
88137 spin_lock_irqsave(&port->lock, flags);
88138 if (!tty_hung_up_p(filp)) {
88139 extra_count = 1;
88140 - port->count--;
88141 + atomic_dec(&port->count);
88142 }
88143 spin_unlock_irqrestore(&port->lock, flags);
88144 port->blocked_open++;
88145 @@ -353,7 +353,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88146 }
88147
88148 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
88149 - __FILE__, __LINE__, tty->driver->name, port->count);
88150 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88151
88152 schedule();
88153 }
88154 @@ -364,13 +364,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88155 if (extra_count) {
88156 /* ++ is not atomic, so this should be protected - Jean II */
88157 spin_lock_irqsave(&port->lock, flags);
88158 - port->count++;
88159 + atomic_inc(&port->count);
88160 spin_unlock_irqrestore(&port->lock, flags);
88161 }
88162 port->blocked_open--;
88163
88164 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
88165 - __FILE__, __LINE__, tty->driver->name, port->count);
88166 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88167
88168 if (!retval)
88169 port->flags |= ASYNC_NORMAL_ACTIVE;
88170 @@ -444,12 +444,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
88171
88172 /* ++ is not atomic, so this should be protected - Jean II */
88173 spin_lock_irqsave(&self->port.lock, flags);
88174 - self->port.count++;
88175 + atomic_inc(&self->port.count);
88176 spin_unlock_irqrestore(&self->port.lock, flags);
88177 tty_port_tty_set(&self->port, tty);
88178
88179 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
88180 - self->line, self->port.count);
88181 + self->line, atomic_read(&self->port.count));
88182
88183 /* Not really used by us, but lets do it anyway */
88184 tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
88185 @@ -986,7 +986,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
88186 tty_kref_put(port->tty);
88187 }
88188 port->tty = NULL;
88189 - port->count = 0;
88190 + atomic_set(&port->count, 0);
88191 spin_unlock_irqrestore(&port->lock, flags);
88192
88193 wake_up_interruptible(&port->open_wait);
88194 @@ -1343,7 +1343,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88195 seq_putc(m, '\n');
88196
88197 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88198 - seq_printf(m, "Open count: %d\n", self->port.count);
88199 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88200 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88201 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88202
88203 diff --git a/net/irda/iriap.c b/net/irda/iriap.c
88204 index e71e85b..29340a9 100644
88205 --- a/net/irda/iriap.c
88206 +++ b/net/irda/iriap.c
88207 @@ -495,8 +495,11 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
88208 /* case CS_ISO_8859_9: */
88209 /* case CS_UNICODE: */
88210 default:
88211 - IRDA_DEBUG(0, "%s(), charset %s, not supported\n",
88212 - __func__, ias_charset_types[charset]);
88213 + IRDA_DEBUG(0, "%s(), charset [%d] %s, not supported\n",
88214 + __func__, charset,
88215 + charset < ARRAY_SIZE(ias_charset_types) ?
88216 + ias_charset_types[charset] :
88217 + "(unknown)");
88218
88219 /* Aborting, close connection! */
88220 iriap_disconnect_request(self);
88221 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88222 index cd6f7a9..e63fe89 100644
88223 --- a/net/iucv/af_iucv.c
88224 +++ b/net/iucv/af_iucv.c
88225 @@ -782,10 +782,10 @@ static int iucv_sock_autobind(struct sock *sk)
88226
88227 write_lock_bh(&iucv_sk_list.lock);
88228
88229 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88230 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88231 while (__iucv_get_sock_by_name(name)) {
88232 sprintf(name, "%08x",
88233 - atomic_inc_return(&iucv_sk_list.autobind_name));
88234 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88235 }
88236
88237 write_unlock_bh(&iucv_sk_list.lock);
88238 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88239 index df08250..02021fe 100644
88240 --- a/net/iucv/iucv.c
88241 +++ b/net/iucv/iucv.c
88242 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88243 return NOTIFY_OK;
88244 }
88245
88246 -static struct notifier_block __refdata iucv_cpu_notifier = {
88247 +static struct notifier_block iucv_cpu_notifier = {
88248 .notifier_call = iucv_cpu_notify,
88249 };
88250
88251 diff --git a/net/key/af_key.c b/net/key/af_key.c
88252 index 5b426a6..970032b 100644
88253 --- a/net/key/af_key.c
88254 +++ b/net/key/af_key.c
88255 @@ -3019,10 +3019,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88256 static u32 get_acqseq(void)
88257 {
88258 u32 res;
88259 - static atomic_t acqseq;
88260 + static atomic_unchecked_t acqseq;
88261
88262 do {
88263 - res = atomic_inc_return(&acqseq);
88264 + res = atomic_inc_return_unchecked(&acqseq);
88265 } while (!res);
88266 return res;
88267 }
88268 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88269 index 49c48c6..9e72ff4 100644
88270 --- a/net/mac80211/cfg.c
88271 +++ b/net/mac80211/cfg.c
88272 @@ -790,7 +790,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88273 ret = ieee80211_vif_use_channel(sdata, chandef,
88274 IEEE80211_CHANCTX_EXCLUSIVE);
88275 }
88276 - } else if (local->open_count == local->monitors) {
88277 + } else if (local_read(&local->open_count) == local->monitors) {
88278 local->_oper_channel = chandef->chan;
88279 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
88280 ieee80211_hw_config(local, 0);
88281 @@ -2718,7 +2718,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88282 else
88283 local->probe_req_reg--;
88284
88285 - if (!local->open_count)
88286 + if (!local_read(&local->open_count))
88287 break;
88288
88289 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88290 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88291 index 55d8f89..bec0c2b 100644
88292 --- a/net/mac80211/ieee80211_i.h
88293 +++ b/net/mac80211/ieee80211_i.h
88294 @@ -28,6 +28,7 @@
88295 #include <net/ieee80211_radiotap.h>
88296 #include <net/cfg80211.h>
88297 #include <net/mac80211.h>
88298 +#include <asm/local.h>
88299 #include "key.h"
88300 #include "sta_info.h"
88301 #include "debug.h"
88302 @@ -910,7 +911,7 @@ struct ieee80211_local {
88303 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88304 spinlock_t queue_stop_reason_lock;
88305
88306 - int open_count;
88307 + local_t open_count;
88308 int monitors, cooked_mntrs;
88309 /* number of interfaces with corresponding FIF_ flags */
88310 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88311 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88312 index 8be854e..ad72a69 100644
88313 --- a/net/mac80211/iface.c
88314 +++ b/net/mac80211/iface.c
88315 @@ -546,7 +546,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88316 break;
88317 }
88318
88319 - if (local->open_count == 0) {
88320 + if (local_read(&local->open_count) == 0) {
88321 res = drv_start(local);
88322 if (res)
88323 goto err_del_bss;
88324 @@ -591,7 +591,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88325 break;
88326 }
88327
88328 - if (local->monitors == 0 && local->open_count == 0) {
88329 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88330 res = ieee80211_add_virtual_monitor(local);
88331 if (res)
88332 goto err_stop;
88333 @@ -699,7 +699,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88334 mutex_unlock(&local->mtx);
88335
88336 if (coming_up)
88337 - local->open_count++;
88338 + local_inc(&local->open_count);
88339
88340 if (hw_reconf_flags)
88341 ieee80211_hw_config(local, hw_reconf_flags);
88342 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88343 err_del_interface:
88344 drv_remove_interface(local, sdata);
88345 err_stop:
88346 - if (!local->open_count)
88347 + if (!local_read(&local->open_count))
88348 drv_stop(local);
88349 err_del_bss:
88350 sdata->bss = NULL;
88351 @@ -827,7 +827,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88352 }
88353
88354 if (going_down)
88355 - local->open_count--;
88356 + local_dec(&local->open_count);
88357
88358 switch (sdata->vif.type) {
88359 case NL80211_IFTYPE_AP_VLAN:
88360 @@ -884,7 +884,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88361
88362 ieee80211_recalc_ps(local, -1);
88363
88364 - if (local->open_count == 0) {
88365 + if (local_read(&local->open_count) == 0) {
88366 if (local->ops->napi_poll)
88367 napi_disable(&local->napi);
88368 ieee80211_clear_tx_pending(local);
88369 @@ -910,7 +910,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88370 }
88371 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88372
88373 - if (local->monitors == local->open_count && local->monitors > 0)
88374 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88375 ieee80211_add_virtual_monitor(local);
88376 }
88377
88378 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88379 index 1b087ff..bf600e9 100644
88380 --- a/net/mac80211/main.c
88381 +++ b/net/mac80211/main.c
88382 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88383 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88384 IEEE80211_CONF_CHANGE_POWER);
88385
88386 - if (changed && local->open_count) {
88387 + if (changed && local_read(&local->open_count)) {
88388 ret = drv_config(local, changed);
88389 /*
88390 * Goal:
88391 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88392 index 79a48f3..5e185c9 100644
88393 --- a/net/mac80211/pm.c
88394 +++ b/net/mac80211/pm.c
88395 @@ -35,7 +35,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88396 struct sta_info *sta;
88397 struct ieee80211_chanctx *ctx;
88398
88399 - if (!local->open_count)
88400 + if (!local_read(&local->open_count))
88401 goto suspend;
88402
88403 ieee80211_scan_cancel(local);
88404 @@ -73,7 +73,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88405 cancel_work_sync(&local->dynamic_ps_enable_work);
88406 del_timer_sync(&local->dynamic_ps_timer);
88407
88408 - local->wowlan = wowlan && local->open_count;
88409 + local->wowlan = wowlan && local_read(&local->open_count);
88410 if (local->wowlan) {
88411 int err = drv_suspend(local, wowlan);
88412 if (err < 0) {
88413 @@ -187,7 +187,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88414 mutex_unlock(&local->chanctx_mtx);
88415
88416 /* stop hardware - this must stop RX */
88417 - if (local->open_count)
88418 + if (local_read(&local->open_count))
88419 ieee80211_stop_device(local);
88420
88421 suspend:
88422 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88423 index dd88381..eef4dd6 100644
88424 --- a/net/mac80211/rate.c
88425 +++ b/net/mac80211/rate.c
88426 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88427
88428 ASSERT_RTNL();
88429
88430 - if (local->open_count)
88431 + if (local_read(&local->open_count))
88432 return -EBUSY;
88433
88434 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88435 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88436 index c97a065..ff61928 100644
88437 --- a/net/mac80211/rc80211_pid_debugfs.c
88438 +++ b/net/mac80211/rc80211_pid_debugfs.c
88439 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88440
88441 spin_unlock_irqrestore(&events->lock, status);
88442
88443 - if (copy_to_user(buf, pb, p))
88444 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88445 return -EFAULT;
88446
88447 return p;
88448 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88449 index f11e8c5..08d0013 100644
88450 --- a/net/mac80211/util.c
88451 +++ b/net/mac80211/util.c
88452 @@ -1380,7 +1380,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88453 }
88454 #endif
88455 /* everything else happens only if HW was up & running */
88456 - if (!local->open_count)
88457 + if (!local_read(&local->open_count))
88458 goto wake_up;
88459
88460 /*
88461 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88462 index 49e96df..63a51c3 100644
88463 --- a/net/netfilter/Kconfig
88464 +++ b/net/netfilter/Kconfig
88465 @@ -936,6 +936,16 @@ config NETFILTER_XT_MATCH_ESP
88466
88467 To compile it as a module, choose M here. If unsure, say N.
88468
88469 +config NETFILTER_XT_MATCH_GRADM
88470 + tristate '"gradm" match support'
88471 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88472 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88473 + ---help---
88474 + The gradm match allows to match on grsecurity RBAC being enabled.
88475 + It is useful when iptables rules are applied early on bootup to
88476 + prevent connections to the machine (except from a trusted host)
88477 + while the RBAC system is disabled.
88478 +
88479 config NETFILTER_XT_MATCH_HASHLIMIT
88480 tristate '"hashlimit" match support'
88481 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88482 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88483 index 3259697..54d5393 100644
88484 --- a/net/netfilter/Makefile
88485 +++ b/net/netfilter/Makefile
88486 @@ -109,6 +109,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88487 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88488 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88489 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88490 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
88491 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
88492 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
88493 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
88494 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
88495 index 6d6d8f2..a676749 100644
88496 --- a/net/netfilter/ipset/ip_set_core.c
88497 +++ b/net/netfilter/ipset/ip_set_core.c
88498 @@ -1800,7 +1800,7 @@ done:
88499 return ret;
88500 }
88501
88502 -static struct nf_sockopt_ops so_set __read_mostly = {
88503 +static struct nf_sockopt_ops so_set = {
88504 .pf = PF_INET,
88505 .get_optmin = SO_IP_SET,
88506 .get_optmax = SO_IP_SET + 1,
88507 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
88508 index 30e764a..c3b6a9d 100644
88509 --- a/net/netfilter/ipvs/ip_vs_conn.c
88510 +++ b/net/netfilter/ipvs/ip_vs_conn.c
88511 @@ -554,7 +554,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
88512 /* Increase the refcnt counter of the dest */
88513 atomic_inc(&dest->refcnt);
88514
88515 - conn_flags = atomic_read(&dest->conn_flags);
88516 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
88517 if (cp->protocol != IPPROTO_UDP)
88518 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
88519 flags = cp->flags;
88520 @@ -899,7 +899,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
88521 atomic_set(&cp->refcnt, 1);
88522
88523 atomic_set(&cp->n_control, 0);
88524 - atomic_set(&cp->in_pkts, 0);
88525 + atomic_set_unchecked(&cp->in_pkts, 0);
88526
88527 atomic_inc(&ipvs->conn_count);
88528 if (flags & IP_VS_CONN_F_NO_CPORT)
88529 @@ -1180,7 +1180,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
88530
88531 /* Don't drop the entry if its number of incoming packets is not
88532 located in [0, 8] */
88533 - i = atomic_read(&cp->in_pkts);
88534 + i = atomic_read_unchecked(&cp->in_pkts);
88535 if (i > 8 || i < 0) return 0;
88536
88537 if (!todrop_rate[i]) return 0;
88538 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
88539 index 47edf5a..235b07d 100644
88540 --- a/net/netfilter/ipvs/ip_vs_core.c
88541 +++ b/net/netfilter/ipvs/ip_vs_core.c
88542 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
88543 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
88544 /* do not touch skb anymore */
88545
88546 - atomic_inc(&cp->in_pkts);
88547 + atomic_inc_unchecked(&cp->in_pkts);
88548 ip_vs_conn_put(cp);
88549 return ret;
88550 }
88551 @@ -1691,7 +1691,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
88552 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
88553 pkts = sysctl_sync_threshold(ipvs);
88554 else
88555 - pkts = atomic_add_return(1, &cp->in_pkts);
88556 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88557
88558 if (ipvs->sync_state & IP_VS_STATE_MASTER)
88559 ip_vs_sync_conn(net, cp, pkts);
88560 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
88561 index ec664cb..7f34a77 100644
88562 --- a/net/netfilter/ipvs/ip_vs_ctl.c
88563 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
88564 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
88565 ip_vs_rs_hash(ipvs, dest);
88566 write_unlock_bh(&ipvs->rs_lock);
88567 }
88568 - atomic_set(&dest->conn_flags, conn_flags);
88569 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
88570
88571 /* bind the service */
88572 if (!dest->svc) {
88573 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
88574 * align with netns init in ip_vs_control_net_init()
88575 */
88576
88577 -static struct ctl_table vs_vars[] = {
88578 +static ctl_table_no_const vs_vars[] __read_only = {
88579 {
88580 .procname = "amemthresh",
88581 .maxlen = sizeof(int),
88582 @@ -2081,7 +2081,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88583 " %-7s %-6d %-10d %-10d\n",
88584 &dest->addr.in6,
88585 ntohs(dest->port),
88586 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88587 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88588 atomic_read(&dest->weight),
88589 atomic_read(&dest->activeconns),
88590 atomic_read(&dest->inactconns));
88591 @@ -2092,7 +2092,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88592 "%-7s %-6d %-10d %-10d\n",
88593 ntohl(dest->addr.ip),
88594 ntohs(dest->port),
88595 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88596 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88597 atomic_read(&dest->weight),
88598 atomic_read(&dest->activeconns),
88599 atomic_read(&dest->inactconns));
88600 @@ -2562,7 +2562,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
88601
88602 entry.addr = dest->addr.ip;
88603 entry.port = dest->port;
88604 - entry.conn_flags = atomic_read(&dest->conn_flags);
88605 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
88606 entry.weight = atomic_read(&dest->weight);
88607 entry.u_threshold = dest->u_threshold;
88608 entry.l_threshold = dest->l_threshold;
88609 @@ -3098,7 +3098,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
88610 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
88611 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
88612 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
88613 - (atomic_read(&dest->conn_flags) &
88614 + (atomic_read_unchecked(&dest->conn_flags) &
88615 IP_VS_CONN_F_FWD_MASK)) ||
88616 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
88617 atomic_read(&dest->weight)) ||
88618 @@ -3688,7 +3688,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
88619 {
88620 int idx;
88621 struct netns_ipvs *ipvs = net_ipvs(net);
88622 - struct ctl_table *tbl;
88623 + ctl_table_no_const *tbl;
88624
88625 atomic_set(&ipvs->dropentry, 0);
88626 spin_lock_init(&ipvs->dropentry_lock);
88627 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
88628 index fdd89b9..bd96aa9 100644
88629 --- a/net/netfilter/ipvs/ip_vs_lblc.c
88630 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
88631 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
88632 * IPVS LBLC sysctl table
88633 */
88634 #ifdef CONFIG_SYSCTL
88635 -static ctl_table vs_vars_table[] = {
88636 +static ctl_table_no_const vs_vars_table[] __read_only = {
88637 {
88638 .procname = "lblc_expiration",
88639 .data = NULL,
88640 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
88641 index c03b6a3..8ce3681 100644
88642 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
88643 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
88644 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
88645 * IPVS LBLCR sysctl table
88646 */
88647
88648 -static ctl_table vs_vars_table[] = {
88649 +static ctl_table_no_const vs_vars_table[] __read_only = {
88650 {
88651 .procname = "lblcr_expiration",
88652 .data = NULL,
88653 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
88654 index 44fd10c..2a163b3 100644
88655 --- a/net/netfilter/ipvs/ip_vs_sync.c
88656 +++ b/net/netfilter/ipvs/ip_vs_sync.c
88657 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
88658 cp = cp->control;
88659 if (cp) {
88660 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88661 - pkts = atomic_add_return(1, &cp->in_pkts);
88662 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88663 else
88664 pkts = sysctl_sync_threshold(ipvs);
88665 ip_vs_sync_conn(net, cp->control, pkts);
88666 @@ -758,7 +758,7 @@ control:
88667 if (!cp)
88668 return;
88669 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88670 - pkts = atomic_add_return(1, &cp->in_pkts);
88671 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88672 else
88673 pkts = sysctl_sync_threshold(ipvs);
88674 goto sloop;
88675 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
88676
88677 if (opt)
88678 memcpy(&cp->in_seq, opt, sizeof(*opt));
88679 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88680 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88681 cp->state = state;
88682 cp->old_state = cp->state;
88683 /*
88684 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
88685 index ee6b7a9..f9a89f6 100644
88686 --- a/net/netfilter/ipvs/ip_vs_xmit.c
88687 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
88688 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
88689 else
88690 rc = NF_ACCEPT;
88691 /* do not touch skb anymore */
88692 - atomic_inc(&cp->in_pkts);
88693 + atomic_inc_unchecked(&cp->in_pkts);
88694 goto out;
88695 }
88696
88697 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
88698 else
88699 rc = NF_ACCEPT;
88700 /* do not touch skb anymore */
88701 - atomic_inc(&cp->in_pkts);
88702 + atomic_inc_unchecked(&cp->in_pkts);
88703 goto out;
88704 }
88705
88706 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
88707 index 7df424e..a527b02 100644
88708 --- a/net/netfilter/nf_conntrack_acct.c
88709 +++ b/net/netfilter/nf_conntrack_acct.c
88710 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
88711 #ifdef CONFIG_SYSCTL
88712 static int nf_conntrack_acct_init_sysctl(struct net *net)
88713 {
88714 - struct ctl_table *table;
88715 + ctl_table_no_const *table;
88716
88717 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
88718 GFP_KERNEL);
88719 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
88720 index e4a0c4f..c263f28 100644
88721 --- a/net/netfilter/nf_conntrack_core.c
88722 +++ b/net/netfilter/nf_conntrack_core.c
88723 @@ -1529,6 +1529,10 @@ err_extend:
88724 #define DYING_NULLS_VAL ((1<<30)+1)
88725 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
88726
88727 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88728 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
88729 +#endif
88730 +
88731 static int nf_conntrack_init_net(struct net *net)
88732 {
88733 int ret;
88734 @@ -1543,7 +1547,11 @@ static int nf_conntrack_init_net(struct net *net)
88735 goto err_stat;
88736 }
88737
88738 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88739 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
88740 +#else
88741 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
88742 +#endif
88743 if (!net->ct.slabname) {
88744 ret = -ENOMEM;
88745 goto err_slabname;
88746 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
88747 index faa978f..1afb18f 100644
88748 --- a/net/netfilter/nf_conntrack_ecache.c
88749 +++ b/net/netfilter/nf_conntrack_ecache.c
88750 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
88751 #ifdef CONFIG_SYSCTL
88752 static int nf_conntrack_event_init_sysctl(struct net *net)
88753 {
88754 - struct ctl_table *table;
88755 + ctl_table_no_const *table;
88756
88757 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
88758 GFP_KERNEL);
88759 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
88760 index 884f2b3..d53b33a 100644
88761 --- a/net/netfilter/nf_conntrack_helper.c
88762 +++ b/net/netfilter/nf_conntrack_helper.c
88763 @@ -55,7 +55,7 @@ static struct ctl_table helper_sysctl_table[] = {
88764
88765 static int nf_conntrack_helper_init_sysctl(struct net *net)
88766 {
88767 - struct ctl_table *table;
88768 + ctl_table_no_const *table;
88769
88770 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
88771 GFP_KERNEL);
88772 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
88773 index 51e928d..72a413a 100644
88774 --- a/net/netfilter/nf_conntrack_proto.c
88775 +++ b/net/netfilter/nf_conntrack_proto.c
88776 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
88777
88778 static void
88779 nf_ct_unregister_sysctl(struct ctl_table_header **header,
88780 - struct ctl_table **table,
88781 + ctl_table_no_const **table,
88782 unsigned int users)
88783 {
88784 if (users > 0)
88785 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
88786 index e7185c6..4ad6c9c 100644
88787 --- a/net/netfilter/nf_conntrack_standalone.c
88788 +++ b/net/netfilter/nf_conntrack_standalone.c
88789 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
88790
88791 static int nf_conntrack_standalone_init_sysctl(struct net *net)
88792 {
88793 - struct ctl_table *table;
88794 + ctl_table_no_const *table;
88795
88796 if (net_eq(net, &init_net)) {
88797 nf_ct_netfilter_header =
88798 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
88799 index 7ea8026..bc9512d 100644
88800 --- a/net/netfilter/nf_conntrack_timestamp.c
88801 +++ b/net/netfilter/nf_conntrack_timestamp.c
88802 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
88803 #ifdef CONFIG_SYSCTL
88804 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
88805 {
88806 - struct ctl_table *table;
88807 + ctl_table_no_const *table;
88808
88809 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
88810 GFP_KERNEL);
88811 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
88812 index 9e31269..bc4c1b7 100644
88813 --- a/net/netfilter/nf_log.c
88814 +++ b/net/netfilter/nf_log.c
88815 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
88816
88817 #ifdef CONFIG_SYSCTL
88818 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
88819 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
88820 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
88821 static struct ctl_table_header *nf_log_dir_header;
88822
88823 static int nf_log_proc_dostring(ctl_table *table, int write,
88824 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
88825 rcu_assign_pointer(nf_loggers[tindex], logger);
88826 mutex_unlock(&nf_log_mutex);
88827 } else {
88828 + ctl_table_no_const nf_log_table = *table;
88829 +
88830 mutex_lock(&nf_log_mutex);
88831 logger = rcu_dereference_protected(nf_loggers[tindex],
88832 lockdep_is_held(&nf_log_mutex));
88833 if (!logger)
88834 - table->data = "NONE";
88835 + nf_log_table.data = "NONE";
88836 else
88837 - table->data = logger->name;
88838 - r = proc_dostring(table, write, buffer, lenp, ppos);
88839 + nf_log_table.data = logger->name;
88840 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
88841 mutex_unlock(&nf_log_mutex);
88842 }
88843
88844 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
88845 index f042ae5..30ea486 100644
88846 --- a/net/netfilter/nf_sockopt.c
88847 +++ b/net/netfilter/nf_sockopt.c
88848 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
88849 }
88850 }
88851
88852 - list_add(&reg->list, &nf_sockopts);
88853 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
88854 out:
88855 mutex_unlock(&nf_sockopt_mutex);
88856 return ret;
88857 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
88858 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
88859 {
88860 mutex_lock(&nf_sockopt_mutex);
88861 - list_del(&reg->list);
88862 + pax_list_del((struct list_head *)&reg->list);
88863 mutex_unlock(&nf_sockopt_mutex);
88864 }
88865 EXPORT_SYMBOL(nf_unregister_sockopt);
88866 diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
88867 index 589d686..dc3fd5d 100644
88868 --- a/net/netfilter/nfnetlink_acct.c
88869 +++ b/net/netfilter/nfnetlink_acct.c
88870 @@ -49,6 +49,8 @@ nfnl_acct_new(struct sock *nfnl, struct sk_buff *skb,
88871 return -EINVAL;
88872
88873 acct_name = nla_data(tb[NFACCT_NAME]);
88874 + if (strlen(acct_name) == 0)
88875 + return -EINVAL;
88876
88877 list_for_each_entry(nfacct, &nfnl_acct_list, head) {
88878 if (strncmp(nfacct->name, acct_name, NFACCT_NAME_MAX) != 0)
88879 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
88880 index 92fd8ec..3f6ea4b 100644
88881 --- a/net/netfilter/nfnetlink_log.c
88882 +++ b/net/netfilter/nfnetlink_log.c
88883 @@ -72,7 +72,7 @@ struct nfulnl_instance {
88884 };
88885
88886 static DEFINE_SPINLOCK(instances_lock);
88887 -static atomic_t global_seq;
88888 +static atomic_unchecked_t global_seq;
88889
88890 #define INSTANCE_BUCKETS 16
88891 static struct hlist_head instance_table[INSTANCE_BUCKETS];
88892 @@ -537,7 +537,7 @@ __build_packet_message(struct nfulnl_instance *inst,
88893 /* global sequence number */
88894 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
88895 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
88896 - htonl(atomic_inc_return(&global_seq))))
88897 + htonl(atomic_inc_return_unchecked(&global_seq))))
88898 goto nla_put_failure;
88899
88900 if (data_len) {
88901 diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
88902 index 3158d87..39006c9 100644
88903 --- a/net/netfilter/nfnetlink_queue_core.c
88904 +++ b/net/netfilter/nfnetlink_queue_core.c
88905 @@ -1064,8 +1064,10 @@ static int __init nfnetlink_queue_init(void)
88906
88907 #ifdef CONFIG_PROC_FS
88908 if (!proc_create("nfnetlink_queue", 0440,
88909 - proc_net_netfilter, &nfqnl_file_ops))
88910 + proc_net_netfilter, &nfqnl_file_ops)) {
88911 + status = -ENOMEM;
88912 goto cleanup_subsys;
88913 + }
88914 #endif
88915
88916 register_netdevice_notifier(&nfqnl_dev_notifier);
88917 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
88918 new file mode 100644
88919 index 0000000..c566332
88920 --- /dev/null
88921 +++ b/net/netfilter/xt_gradm.c
88922 @@ -0,0 +1,51 @@
88923 +/*
88924 + * gradm match for netfilter
88925 + * Copyright © Zbigniew Krzystolik, 2010
88926 + *
88927 + * This program is free software; you can redistribute it and/or modify
88928 + * it under the terms of the GNU General Public License; either version
88929 + * 2 or 3 as published by the Free Software Foundation.
88930 + */
88931 +#include <linux/module.h>
88932 +#include <linux/moduleparam.h>
88933 +#include <linux/skbuff.h>
88934 +#include <linux/netfilter/x_tables.h>
88935 +#include <linux/grsecurity.h>
88936 +#include <linux/netfilter/xt_gradm.h>
88937 +
88938 +static bool
88939 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
88940 +{
88941 + const struct xt_gradm_mtinfo *info = par->matchinfo;
88942 + bool retval = false;
88943 + if (gr_acl_is_enabled())
88944 + retval = true;
88945 + return retval ^ info->invflags;
88946 +}
88947 +
88948 +static struct xt_match gradm_mt_reg __read_mostly = {
88949 + .name = "gradm",
88950 + .revision = 0,
88951 + .family = NFPROTO_UNSPEC,
88952 + .match = gradm_mt,
88953 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
88954 + .me = THIS_MODULE,
88955 +};
88956 +
88957 +static int __init gradm_mt_init(void)
88958 +{
88959 + return xt_register_match(&gradm_mt_reg);
88960 +}
88961 +
88962 +static void __exit gradm_mt_exit(void)
88963 +{
88964 + xt_unregister_match(&gradm_mt_reg);
88965 +}
88966 +
88967 +module_init(gradm_mt_init);
88968 +module_exit(gradm_mt_exit);
88969 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
88970 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
88971 +MODULE_LICENSE("GPL");
88972 +MODULE_ALIAS("ipt_gradm");
88973 +MODULE_ALIAS("ip6t_gradm");
88974 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
88975 index 4fe4fb4..87a89e5 100644
88976 --- a/net/netfilter/xt_statistic.c
88977 +++ b/net/netfilter/xt_statistic.c
88978 @@ -19,7 +19,7 @@
88979 #include <linux/module.h>
88980
88981 struct xt_statistic_priv {
88982 - atomic_t count;
88983 + atomic_unchecked_t count;
88984 } ____cacheline_aligned_in_smp;
88985
88986 MODULE_LICENSE("GPL");
88987 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
88988 break;
88989 case XT_STATISTIC_MODE_NTH:
88990 do {
88991 - oval = atomic_read(&info->master->count);
88992 + oval = atomic_read_unchecked(&info->master->count);
88993 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
88994 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
88995 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
88996 if (nval == 0)
88997 ret = !ret;
88998 break;
88999 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89000 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89001 if (info->master == NULL)
89002 return -ENOMEM;
89003 - atomic_set(&info->master->count, info->u.nth.count);
89004 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89005
89006 return 0;
89007 }
89008 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89009 index c0353d5..fcb0270 100644
89010 --- a/net/netlink/af_netlink.c
89011 +++ b/net/netlink/af_netlink.c
89012 @@ -785,7 +785,7 @@ static void netlink_overrun(struct sock *sk)
89013 sk->sk_error_report(sk);
89014 }
89015 }
89016 - atomic_inc(&sk->sk_drops);
89017 + atomic_inc_unchecked(&sk->sk_drops);
89018 }
89019
89020 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
89021 @@ -2071,7 +2071,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89022 sk_wmem_alloc_get(s),
89023 nlk->cb,
89024 atomic_read(&s->sk_refcnt),
89025 - atomic_read(&s->sk_drops),
89026 + atomic_read_unchecked(&s->sk_drops),
89027 sock_i_ino(s)
89028 );
89029
89030 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89031 index 5a55be3..7630745 100644
89032 --- a/net/netlink/genetlink.c
89033 +++ b/net/netlink/genetlink.c
89034 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89035 goto errout;
89036 }
89037
89038 + pax_open_kernel();
89039 if (ops->dumpit)
89040 - ops->flags |= GENL_CMD_CAP_DUMP;
89041 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89042 if (ops->doit)
89043 - ops->flags |= GENL_CMD_CAP_DO;
89044 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89045 if (ops->policy)
89046 - ops->flags |= GENL_CMD_CAP_HASPOL;
89047 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89048 + pax_close_kernel();
89049
89050 genl_lock();
89051 - list_add_tail(&ops->ops_list, &family->ops_list);
89052 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89053 genl_unlock();
89054
89055 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89056 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89057 err = 0;
89058 errout:
89059 return err;
89060 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89061 genl_lock();
89062 list_for_each_entry(rc, &family->ops_list, ops_list) {
89063 if (rc == ops) {
89064 - list_del(&ops->ops_list);
89065 + pax_list_del((struct list_head *)&ops->ops_list);
89066 genl_unlock();
89067 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89068 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89069 return 0;
89070 }
89071 }
89072 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89073 index 7261eb8..44e8ac6 100644
89074 --- a/net/netrom/af_netrom.c
89075 +++ b/net/netrom/af_netrom.c
89076 @@ -838,6 +838,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89077 struct sock *sk = sock->sk;
89078 struct nr_sock *nr = nr_sk(sk);
89079
89080 + memset(sax, 0, sizeof(*sax));
89081 lock_sock(sk);
89082 if (peer != 0) {
89083 if (sk->sk_state != TCP_ESTABLISHED) {
89084 @@ -852,7 +853,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89085 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89086 } else {
89087 sax->fsa_ax25.sax25_family = AF_NETROM;
89088 - sax->fsa_ax25.sax25_ndigis = 0;
89089 sax->fsa_ax25.sax25_call = nr->source_addr;
89090 *uaddr_len = sizeof(struct sockaddr_ax25);
89091 }
89092 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
89093 index c111bd0..7788ff7 100644
89094 --- a/net/packet/af_packet.c
89095 +++ b/net/packet/af_packet.c
89096 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89097
89098 spin_lock(&sk->sk_receive_queue.lock);
89099 po->stats.tp_packets++;
89100 - skb->dropcount = atomic_read(&sk->sk_drops);
89101 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
89102 __skb_queue_tail(&sk->sk_receive_queue, skb);
89103 spin_unlock(&sk->sk_receive_queue.lock);
89104 sk->sk_data_ready(sk, skb->len);
89105 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89106 drop_n_acct:
89107 spin_lock(&sk->sk_receive_queue.lock);
89108 po->stats.tp_drops++;
89109 - atomic_inc(&sk->sk_drops);
89110 + atomic_inc_unchecked(&sk->sk_drops);
89111 spin_unlock(&sk->sk_receive_queue.lock);
89112
89113 drop_n_restore:
89114 @@ -2565,6 +2565,7 @@ out:
89115
89116 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89117 {
89118 + struct sock_extended_err ee;
89119 struct sock_exterr_skb *serr;
89120 struct sk_buff *skb, *skb2;
89121 int copied, err;
89122 @@ -2586,8 +2587,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89123 sock_recv_timestamp(msg, sk, skb);
89124
89125 serr = SKB_EXT_ERR(skb);
89126 + ee = serr->ee;
89127 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
89128 - sizeof(serr->ee), &serr->ee);
89129 + sizeof ee, &ee);
89130
89131 msg->msg_flags |= MSG_ERRQUEUE;
89132 err = copied;
89133 @@ -3212,7 +3214,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89134 case PACKET_HDRLEN:
89135 if (len > sizeof(int))
89136 len = sizeof(int);
89137 - if (copy_from_user(&val, optval, len))
89138 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
89139 return -EFAULT;
89140 switch (val) {
89141 case TPACKET_V1:
89142 @@ -3254,7 +3256,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89143 len = lv;
89144 if (put_user(len, optlen))
89145 return -EFAULT;
89146 - if (copy_to_user(optval, data, len))
89147 + if (len > sizeof(st) || copy_to_user(optval, data, len))
89148 return -EFAULT;
89149 return 0;
89150 }
89151 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
89152 index 5a940db..f0b9c12 100644
89153 --- a/net/phonet/af_phonet.c
89154 +++ b/net/phonet/af_phonet.c
89155 @@ -41,7 +41,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
89156 {
89157 struct phonet_protocol *pp;
89158
89159 - if (protocol >= PHONET_NPROTO)
89160 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89161 return NULL;
89162
89163 rcu_read_lock();
89164 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
89165 {
89166 int err = 0;
89167
89168 - if (protocol >= PHONET_NPROTO)
89169 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89170 return -EINVAL;
89171
89172 err = proto_register(pp->prot, 1);
89173 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
89174 index 576f22c..bc7a71b 100644
89175 --- a/net/phonet/pep.c
89176 +++ b/net/phonet/pep.c
89177 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89178
89179 case PNS_PEP_CTRL_REQ:
89180 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
89181 - atomic_inc(&sk->sk_drops);
89182 + atomic_inc_unchecked(&sk->sk_drops);
89183 break;
89184 }
89185 __skb_pull(skb, 4);
89186 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89187 }
89188
89189 if (pn->rx_credits == 0) {
89190 - atomic_inc(&sk->sk_drops);
89191 + atomic_inc_unchecked(&sk->sk_drops);
89192 err = -ENOBUFS;
89193 break;
89194 }
89195 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
89196 }
89197
89198 if (pn->rx_credits == 0) {
89199 - atomic_inc(&sk->sk_drops);
89200 + atomic_inc_unchecked(&sk->sk_drops);
89201 err = NET_RX_DROP;
89202 break;
89203 }
89204 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
89205 index b7e9827..c264c85 100644
89206 --- a/net/phonet/socket.c
89207 +++ b/net/phonet/socket.c
89208 @@ -615,7 +615,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
89209 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
89210 sock_i_ino(sk),
89211 atomic_read(&sk->sk_refcnt), sk,
89212 - atomic_read(&sk->sk_drops), &len);
89213 + atomic_read_unchecked(&sk->sk_drops), &len);
89214 }
89215 seq_printf(seq, "%*s\n", 127 - len, "");
89216 return 0;
89217 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
89218 index d6bbbbd..61561e4 100644
89219 --- a/net/phonet/sysctl.c
89220 +++ b/net/phonet/sysctl.c
89221 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
89222 {
89223 int ret;
89224 int range[2] = {local_port_range[0], local_port_range[1]};
89225 - ctl_table tmp = {
89226 + ctl_table_no_const tmp = {
89227 .data = &range,
89228 .maxlen = sizeof(range),
89229 .mode = table->mode,
89230 diff --git a/net/rds/cong.c b/net/rds/cong.c
89231 index e5b65ac..f3b6fb7 100644
89232 --- a/net/rds/cong.c
89233 +++ b/net/rds/cong.c
89234 @@ -78,7 +78,7 @@
89235 * finds that the saved generation number is smaller than the global generation
89236 * number, it wakes up the process.
89237 */
89238 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89239 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89240
89241 /*
89242 * Congestion monitoring
89243 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89244 rdsdebug("waking map %p for %pI4\n",
89245 map, &map->m_addr);
89246 rds_stats_inc(s_cong_update_received);
89247 - atomic_inc(&rds_cong_generation);
89248 + atomic_inc_unchecked(&rds_cong_generation);
89249 if (waitqueue_active(&map->m_waitq))
89250 wake_up(&map->m_waitq);
89251 if (waitqueue_active(&rds_poll_waitq))
89252 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89253
89254 int rds_cong_updated_since(unsigned long *recent)
89255 {
89256 - unsigned long gen = atomic_read(&rds_cong_generation);
89257 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89258
89259 if (likely(*recent == gen))
89260 return 0;
89261 diff --git a/net/rds/ib.h b/net/rds/ib.h
89262 index 7280ab8..e04f4ea 100644
89263 --- a/net/rds/ib.h
89264 +++ b/net/rds/ib.h
89265 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89266 /* sending acks */
89267 unsigned long i_ack_flags;
89268 #ifdef KERNEL_HAS_ATOMIC64
89269 - atomic64_t i_ack_next; /* next ACK to send */
89270 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89271 #else
89272 spinlock_t i_ack_lock; /* protect i_ack_next */
89273 u64 i_ack_next; /* next ACK to send */
89274 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89275 index 31b74f5..dc1fbfa 100644
89276 --- a/net/rds/ib_cm.c
89277 +++ b/net/rds/ib_cm.c
89278 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89279 /* Clear the ACK state */
89280 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89281 #ifdef KERNEL_HAS_ATOMIC64
89282 - atomic64_set(&ic->i_ack_next, 0);
89283 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89284 #else
89285 ic->i_ack_next = 0;
89286 #endif
89287 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89288 index 8eb9501..0c386ff 100644
89289 --- a/net/rds/ib_recv.c
89290 +++ b/net/rds/ib_recv.c
89291 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89292 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89293 int ack_required)
89294 {
89295 - atomic64_set(&ic->i_ack_next, seq);
89296 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89297 if (ack_required) {
89298 smp_mb__before_clear_bit();
89299 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89300 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89301 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89302 smp_mb__after_clear_bit();
89303
89304 - return atomic64_read(&ic->i_ack_next);
89305 + return atomic64_read_unchecked(&ic->i_ack_next);
89306 }
89307 #endif
89308
89309 diff --git a/net/rds/iw.h b/net/rds/iw.h
89310 index 04ce3b1..48119a6 100644
89311 --- a/net/rds/iw.h
89312 +++ b/net/rds/iw.h
89313 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89314 /* sending acks */
89315 unsigned long i_ack_flags;
89316 #ifdef KERNEL_HAS_ATOMIC64
89317 - atomic64_t i_ack_next; /* next ACK to send */
89318 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89319 #else
89320 spinlock_t i_ack_lock; /* protect i_ack_next */
89321 u64 i_ack_next; /* next ACK to send */
89322 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89323 index a91e1db..cf3053f 100644
89324 --- a/net/rds/iw_cm.c
89325 +++ b/net/rds/iw_cm.c
89326 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89327 /* Clear the ACK state */
89328 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89329 #ifdef KERNEL_HAS_ATOMIC64
89330 - atomic64_set(&ic->i_ack_next, 0);
89331 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89332 #else
89333 ic->i_ack_next = 0;
89334 #endif
89335 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89336 index 4503335..db566b4 100644
89337 --- a/net/rds/iw_recv.c
89338 +++ b/net/rds/iw_recv.c
89339 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89340 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89341 int ack_required)
89342 {
89343 - atomic64_set(&ic->i_ack_next, seq);
89344 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89345 if (ack_required) {
89346 smp_mb__before_clear_bit();
89347 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89348 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89349 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89350 smp_mb__after_clear_bit();
89351
89352 - return atomic64_read(&ic->i_ack_next);
89353 + return atomic64_read_unchecked(&ic->i_ack_next);
89354 }
89355 #endif
89356
89357 diff --git a/net/rds/rds.h b/net/rds/rds.h
89358 index ec1d731..90a3a8d 100644
89359 --- a/net/rds/rds.h
89360 +++ b/net/rds/rds.h
89361 @@ -449,7 +449,7 @@ struct rds_transport {
89362 void (*sync_mr)(void *trans_private, int direction);
89363 void (*free_mr)(void *trans_private, int invalidate);
89364 void (*flush_mrs)(void);
89365 -};
89366 +} __do_const;
89367
89368 struct rds_sock {
89369 struct sock rs_sk;
89370 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89371 index edac9ef..16bcb98 100644
89372 --- a/net/rds/tcp.c
89373 +++ b/net/rds/tcp.c
89374 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89375 int val = 1;
89376
89377 set_fs(KERNEL_DS);
89378 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89379 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89380 sizeof(val));
89381 set_fs(oldfs);
89382 }
89383 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89384 index 81cf5a4..b5826ff 100644
89385 --- a/net/rds/tcp_send.c
89386 +++ b/net/rds/tcp_send.c
89387 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89388
89389 oldfs = get_fs();
89390 set_fs(KERNEL_DS);
89391 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89392 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89393 sizeof(val));
89394 set_fs(oldfs);
89395 }
89396 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89397 index 05996d0..5a1dfe0 100644
89398 --- a/net/rxrpc/af_rxrpc.c
89399 +++ b/net/rxrpc/af_rxrpc.c
89400 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89401 __be32 rxrpc_epoch;
89402
89403 /* current debugging ID */
89404 -atomic_t rxrpc_debug_id;
89405 +atomic_unchecked_t rxrpc_debug_id;
89406
89407 /* count of skbs currently in use */
89408 atomic_t rxrpc_n_skbs;
89409 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89410 index e4d9cbc..b229649 100644
89411 --- a/net/rxrpc/ar-ack.c
89412 +++ b/net/rxrpc/ar-ack.c
89413 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89414
89415 _enter("{%d,%d,%d,%d},",
89416 call->acks_hard, call->acks_unacked,
89417 - atomic_read(&call->sequence),
89418 + atomic_read_unchecked(&call->sequence),
89419 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89420
89421 stop = 0;
89422 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89423
89424 /* each Tx packet has a new serial number */
89425 sp->hdr.serial =
89426 - htonl(atomic_inc_return(&call->conn->serial));
89427 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89428
89429 hdr = (struct rxrpc_header *) txb->head;
89430 hdr->serial = sp->hdr.serial;
89431 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89432 */
89433 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89434 {
89435 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89436 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89437 }
89438
89439 /*
89440 @@ -629,7 +629,7 @@ process_further:
89441
89442 latest = ntohl(sp->hdr.serial);
89443 hard = ntohl(ack.firstPacket);
89444 - tx = atomic_read(&call->sequence);
89445 + tx = atomic_read_unchecked(&call->sequence);
89446
89447 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89448 latest,
89449 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89450 goto maybe_reschedule;
89451
89452 send_ACK_with_skew:
89453 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89454 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89455 ntohl(ack.serial));
89456 send_ACK:
89457 mtu = call->conn->trans->peer->if_mtu;
89458 @@ -1173,7 +1173,7 @@ send_ACK:
89459 ackinfo.rxMTU = htonl(5692);
89460 ackinfo.jumbo_max = htonl(4);
89461
89462 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89463 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89464 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89465 ntohl(hdr.serial),
89466 ntohs(ack.maxSkew),
89467 @@ -1191,7 +1191,7 @@ send_ACK:
89468 send_message:
89469 _debug("send message");
89470
89471 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89472 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89473 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89474 send_message_2:
89475
89476 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89477 index a3bbb36..3341fb9 100644
89478 --- a/net/rxrpc/ar-call.c
89479 +++ b/net/rxrpc/ar-call.c
89480 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89481 spin_lock_init(&call->lock);
89482 rwlock_init(&call->state_lock);
89483 atomic_set(&call->usage, 1);
89484 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89485 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89486 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89487
89488 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89489 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
89490 index 4106ca9..a338d7a 100644
89491 --- a/net/rxrpc/ar-connection.c
89492 +++ b/net/rxrpc/ar-connection.c
89493 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
89494 rwlock_init(&conn->lock);
89495 spin_lock_init(&conn->state_lock);
89496 atomic_set(&conn->usage, 1);
89497 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
89498 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89499 conn->avail_calls = RXRPC_MAXCALLS;
89500 conn->size_align = 4;
89501 conn->header_size = sizeof(struct rxrpc_header);
89502 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
89503 index e7ed43a..6afa140 100644
89504 --- a/net/rxrpc/ar-connevent.c
89505 +++ b/net/rxrpc/ar-connevent.c
89506 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
89507
89508 len = iov[0].iov_len + iov[1].iov_len;
89509
89510 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89511 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89512 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
89513
89514 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89515 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
89516 index 529572f..c758ca7 100644
89517 --- a/net/rxrpc/ar-input.c
89518 +++ b/net/rxrpc/ar-input.c
89519 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
89520 /* track the latest serial number on this connection for ACK packet
89521 * information */
89522 serial = ntohl(sp->hdr.serial);
89523 - hi_serial = atomic_read(&call->conn->hi_serial);
89524 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
89525 while (serial > hi_serial)
89526 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
89527 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
89528 serial);
89529
89530 /* request ACK generation for any ACK or DATA packet that requests
89531 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
89532 index a693aca..81e7293 100644
89533 --- a/net/rxrpc/ar-internal.h
89534 +++ b/net/rxrpc/ar-internal.h
89535 @@ -272,8 +272,8 @@ struct rxrpc_connection {
89536 int error; /* error code for local abort */
89537 int debug_id; /* debug ID for printks */
89538 unsigned int call_counter; /* call ID counter */
89539 - atomic_t serial; /* packet serial number counter */
89540 - atomic_t hi_serial; /* highest serial number received */
89541 + atomic_unchecked_t serial; /* packet serial number counter */
89542 + atomic_unchecked_t hi_serial; /* highest serial number received */
89543 u8 avail_calls; /* number of calls available */
89544 u8 size_align; /* data size alignment (for security) */
89545 u8 header_size; /* rxrpc + security header size */
89546 @@ -346,7 +346,7 @@ struct rxrpc_call {
89547 spinlock_t lock;
89548 rwlock_t state_lock; /* lock for state transition */
89549 atomic_t usage;
89550 - atomic_t sequence; /* Tx data packet sequence counter */
89551 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
89552 u32 abort_code; /* local/remote abort code */
89553 enum { /* current state of call */
89554 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
89555 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
89556 */
89557 extern atomic_t rxrpc_n_skbs;
89558 extern __be32 rxrpc_epoch;
89559 -extern atomic_t rxrpc_debug_id;
89560 +extern atomic_unchecked_t rxrpc_debug_id;
89561 extern struct workqueue_struct *rxrpc_workqueue;
89562
89563 /*
89564 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
89565 index 87f7135..74d3703 100644
89566 --- a/net/rxrpc/ar-local.c
89567 +++ b/net/rxrpc/ar-local.c
89568 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
89569 spin_lock_init(&local->lock);
89570 rwlock_init(&local->services_lock);
89571 atomic_set(&local->usage, 1);
89572 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
89573 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89574 memcpy(&local->srx, srx, sizeof(*srx));
89575 }
89576
89577 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
89578 index e1ac183..b43e10e 100644
89579 --- a/net/rxrpc/ar-output.c
89580 +++ b/net/rxrpc/ar-output.c
89581 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
89582 sp->hdr.cid = call->cid;
89583 sp->hdr.callNumber = call->call_id;
89584 sp->hdr.seq =
89585 - htonl(atomic_inc_return(&call->sequence));
89586 + htonl(atomic_inc_return_unchecked(&call->sequence));
89587 sp->hdr.serial =
89588 - htonl(atomic_inc_return(&conn->serial));
89589 + htonl(atomic_inc_return_unchecked(&conn->serial));
89590 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
89591 sp->hdr.userStatus = 0;
89592 sp->hdr.securityIndex = conn->security_ix;
89593 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
89594 index bebaa43..2644591 100644
89595 --- a/net/rxrpc/ar-peer.c
89596 +++ b/net/rxrpc/ar-peer.c
89597 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
89598 INIT_LIST_HEAD(&peer->error_targets);
89599 spin_lock_init(&peer->lock);
89600 atomic_set(&peer->usage, 1);
89601 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
89602 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89603 memcpy(&peer->srx, srx, sizeof(*srx));
89604
89605 rxrpc_assess_MTU_size(peer);
89606 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
89607 index 38047f7..9f48511 100644
89608 --- a/net/rxrpc/ar-proc.c
89609 +++ b/net/rxrpc/ar-proc.c
89610 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
89611 atomic_read(&conn->usage),
89612 rxrpc_conn_states[conn->state],
89613 key_serial(conn->key),
89614 - atomic_read(&conn->serial),
89615 - atomic_read(&conn->hi_serial));
89616 + atomic_read_unchecked(&conn->serial),
89617 + atomic_read_unchecked(&conn->hi_serial));
89618
89619 return 0;
89620 }
89621 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
89622 index 92df566..87ec1bf 100644
89623 --- a/net/rxrpc/ar-transport.c
89624 +++ b/net/rxrpc/ar-transport.c
89625 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
89626 spin_lock_init(&trans->client_lock);
89627 rwlock_init(&trans->conn_lock);
89628 atomic_set(&trans->usage, 1);
89629 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
89630 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89631
89632 if (peer->srx.transport.family == AF_INET) {
89633 switch (peer->srx.transport_type) {
89634 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
89635 index f226709..0e735a8 100644
89636 --- a/net/rxrpc/rxkad.c
89637 +++ b/net/rxrpc/rxkad.c
89638 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
89639
89640 len = iov[0].iov_len + iov[1].iov_len;
89641
89642 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89643 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89644 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
89645
89646 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89647 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
89648
89649 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
89650
89651 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
89652 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89653 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
89654
89655 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
89656 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
89657 index 391a245..296b3d7 100644
89658 --- a/net/sctp/ipv6.c
89659 +++ b/net/sctp/ipv6.c
89660 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
89661 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
89662 };
89663
89664 -static struct sctp_af sctp_af_inet6 = {
89665 +static struct sctp_af sctp_af_inet6 __read_only = {
89666 .sa_family = AF_INET6,
89667 .sctp_xmit = sctp_v6_xmit,
89668 .setsockopt = ipv6_setsockopt,
89669 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
89670 #endif
89671 };
89672
89673 -static struct sctp_pf sctp_pf_inet6 = {
89674 +static struct sctp_pf sctp_pf_inet6 __read_only = {
89675 .event_msgname = sctp_inet6_event_msgname,
89676 .skb_msgname = sctp_inet6_skb_msgname,
89677 .af_supported = sctp_inet6_af_supported,
89678 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
89679
89680 void sctp_v6_pf_exit(void)
89681 {
89682 - list_del(&sctp_af_inet6.list);
89683 + pax_list_del(&sctp_af_inet6.list);
89684 }
89685
89686 /* Initialize IPv6 support and register with socket layer. */
89687 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
89688 index 8c19e97..16264b8 100644
89689 --- a/net/sctp/proc.c
89690 +++ b/net/sctp/proc.c
89691 @@ -338,7 +338,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
89692 seq_printf(seq,
89693 "%8pK %8pK %-3d %-3d %-2d %-4d "
89694 "%4d %8d %8d %7d %5lu %-5d %5d ",
89695 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
89696 + assoc, sk,
89697 + sctp_sk(sk)->type, sk->sk_state,
89698 assoc->state, hash,
89699 assoc->assoc_id,
89700 assoc->sndbuf_used,
89701 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
89702 index f898b1c..a2d0fe8 100644
89703 --- a/net/sctp/protocol.c
89704 +++ b/net/sctp/protocol.c
89705 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
89706 return 0;
89707 }
89708
89709 + pax_open_kernel();
89710 INIT_LIST_HEAD(&af->list);
89711 - list_add_tail(&af->list, &sctp_address_families);
89712 + pax_close_kernel();
89713 + pax_list_add_tail(&af->list, &sctp_address_families);
89714 return 1;
89715 }
89716
89717 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
89718
89719 static struct sctp_af sctp_af_inet;
89720
89721 -static struct sctp_pf sctp_pf_inet = {
89722 +static struct sctp_pf sctp_pf_inet __read_only = {
89723 .event_msgname = sctp_inet_event_msgname,
89724 .skb_msgname = sctp_inet_skb_msgname,
89725 .af_supported = sctp_inet_af_supported,
89726 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
89727 };
89728
89729 /* IPv4 address related functions. */
89730 -static struct sctp_af sctp_af_inet = {
89731 +static struct sctp_af sctp_af_inet __read_only = {
89732 .sa_family = AF_INET,
89733 .sctp_xmit = sctp_v4_xmit,
89734 .setsockopt = ip_setsockopt,
89735 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
89736
89737 static void sctp_v4_pf_exit(void)
89738 {
89739 - list_del(&sctp_af_inet.list);
89740 + pax_list_del(&sctp_af_inet.list);
89741 }
89742
89743 static int sctp_v4_protosw_init(void)
89744 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
89745 index c957775..6d4593a 100644
89746 --- a/net/sctp/sm_sideeffect.c
89747 +++ b/net/sctp/sm_sideeffect.c
89748 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
89749 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
89750 }
89751
89752 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89753 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89754 NULL,
89755 sctp_generate_t1_cookie_event,
89756 sctp_generate_t1_init_event,
89757 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
89758 index 9ef5c73..1e9a9a9 100644
89759 --- a/net/sctp/socket.c
89760 +++ b/net/sctp/socket.c
89761 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
89762 {
89763 struct sctp_association *asoc;
89764 struct sctp_ulpevent *event;
89765 + struct sctp_event_subscribe subscribe;
89766
89767 if (optlen > sizeof(struct sctp_event_subscribe))
89768 return -EINVAL;
89769 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
89770 + if (copy_from_user(&subscribe, optval, optlen))
89771 return -EFAULT;
89772 + sctp_sk(sk)->subscribe = subscribe;
89773
89774 /*
89775 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
89776 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
89777 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89778 int __user *optlen)
89779 {
89780 + struct sctp_event_subscribe subscribe;
89781 +
89782 if (len <= 0)
89783 return -EINVAL;
89784 if (len > sizeof(struct sctp_event_subscribe))
89785 len = sizeof(struct sctp_event_subscribe);
89786 if (put_user(len, optlen))
89787 return -EFAULT;
89788 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
89789 + subscribe = sctp_sk(sk)->subscribe;
89790 + if (copy_to_user(optval, &subscribe, len))
89791 return -EFAULT;
89792 return 0;
89793 }
89794 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89795 */
89796 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
89797 {
89798 + __u32 autoclose;
89799 +
89800 /* Applicable to UDP-style socket only */
89801 if (sctp_style(sk, TCP))
89802 return -EOPNOTSUPP;
89803 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
89804 len = sizeof(int);
89805 if (put_user(len, optlen))
89806 return -EFAULT;
89807 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
89808 + autoclose = sctp_sk(sk)->autoclose;
89809 + if (copy_to_user(optval, &autoclose, sizeof(int)))
89810 return -EFAULT;
89811 return 0;
89812 }
89813 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
89814 */
89815 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
89816 {
89817 + struct sctp_initmsg initmsg;
89818 +
89819 if (len < sizeof(struct sctp_initmsg))
89820 return -EINVAL;
89821 len = sizeof(struct sctp_initmsg);
89822 if (put_user(len, optlen))
89823 return -EFAULT;
89824 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
89825 + initmsg = sctp_sk(sk)->initmsg;
89826 + if (copy_to_user(optval, &initmsg, len))
89827 return -EFAULT;
89828 return 0;
89829 }
89830 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
89831 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
89832 if (space_left < addrlen)
89833 return -ENOMEM;
89834 + if (addrlen > sizeof(temp) || addrlen < 0)
89835 + return -EFAULT;
89836 if (copy_to_user(to, &temp, addrlen))
89837 return -EFAULT;
89838 to += addrlen;
89839 diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
89840 index 442ad4e..825ea94 100644
89841 --- a/net/sctp/ssnmap.c
89842 +++ b/net/sctp/ssnmap.c
89843 @@ -41,8 +41,6 @@
89844 #include <net/sctp/sctp.h>
89845 #include <net/sctp/sm.h>
89846
89847 -#define MAX_KMALLOC_SIZE 131072
89848 -
89849 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
89850 __u16 out);
89851
89852 @@ -65,7 +63,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
89853 int size;
89854
89855 size = sctp_ssnmap_size(in, out);
89856 - if (size <= MAX_KMALLOC_SIZE)
89857 + if (size <= KMALLOC_MAX_SIZE)
89858 retval = kmalloc(size, gfp);
89859 else
89860 retval = (struct sctp_ssnmap *)
89861 @@ -82,7 +80,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
89862 return retval;
89863
89864 fail_map:
89865 - if (size <= MAX_KMALLOC_SIZE)
89866 + if (size <= KMALLOC_MAX_SIZE)
89867 kfree(retval);
89868 else
89869 free_pages((unsigned long)retval, get_order(size));
89870 @@ -124,7 +122,7 @@ void sctp_ssnmap_free(struct sctp_ssnmap *map)
89871 int size;
89872
89873 size = sctp_ssnmap_size(map->in.len, map->out.len);
89874 - if (size <= MAX_KMALLOC_SIZE)
89875 + if (size <= KMALLOC_MAX_SIZE)
89876 kfree(map);
89877 else
89878 free_pages((unsigned long)map, get_order(size));
89879 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
89880 index bf3c6e8..376d8d0 100644
89881 --- a/net/sctp/sysctl.c
89882 +++ b/net/sctp/sysctl.c
89883 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89884 {
89885 struct net *net = current->nsproxy->net_ns;
89886 char tmp[8];
89887 - ctl_table tbl;
89888 + ctl_table_no_const tbl;
89889 int ret;
89890 int changed = 0;
89891 char *none = "none";
89892 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89893
89894 int sctp_sysctl_net_register(struct net *net)
89895 {
89896 - struct ctl_table *table;
89897 + ctl_table_no_const *table;
89898 int i;
89899
89900 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
89901 diff --git a/net/socket.c b/net/socket.c
89902 index 2ca51c7..ee5feb5 100644
89903 --- a/net/socket.c
89904 +++ b/net/socket.c
89905 @@ -89,6 +89,7 @@
89906 #include <linux/magic.h>
89907 #include <linux/slab.h>
89908 #include <linux/xattr.h>
89909 +#include <linux/in.h>
89910
89911 #include <asm/uaccess.h>
89912 #include <asm/unistd.h>
89913 @@ -106,6 +107,8 @@
89914 #include <linux/sockios.h>
89915 #include <linux/atalk.h>
89916
89917 +#include <linux/grsock.h>
89918 +
89919 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
89920 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
89921 unsigned long nr_segs, loff_t pos);
89922 @@ -322,7 +325,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
89923 &sockfs_dentry_operations, SOCKFS_MAGIC);
89924 }
89925
89926 -static struct vfsmount *sock_mnt __read_mostly;
89927 +struct vfsmount *sock_mnt __read_mostly;
89928
89929 static struct file_system_type sock_fs_type = {
89930 .name = "sockfs",
89931 @@ -1270,6 +1273,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
89932 return -EAFNOSUPPORT;
89933 if (type < 0 || type >= SOCK_MAX)
89934 return -EINVAL;
89935 + if (protocol < 0)
89936 + return -EINVAL;
89937
89938 /* Compatibility.
89939
89940 @@ -1401,6 +1406,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
89941 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
89942 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
89943
89944 + if(!gr_search_socket(family, type, protocol)) {
89945 + retval = -EACCES;
89946 + goto out;
89947 + }
89948 +
89949 + if (gr_handle_sock_all(family, type, protocol)) {
89950 + retval = -EACCES;
89951 + goto out;
89952 + }
89953 +
89954 retval = sock_create(family, type, protocol, &sock);
89955 if (retval < 0)
89956 goto out;
89957 @@ -1528,6 +1543,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89958 if (sock) {
89959 err = move_addr_to_kernel(umyaddr, addrlen, &address);
89960 if (err >= 0) {
89961 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
89962 + err = -EACCES;
89963 + goto error;
89964 + }
89965 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
89966 + if (err)
89967 + goto error;
89968 +
89969 err = security_socket_bind(sock,
89970 (struct sockaddr *)&address,
89971 addrlen);
89972 @@ -1536,6 +1559,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
89973 (struct sockaddr *)
89974 &address, addrlen);
89975 }
89976 +error:
89977 fput_light(sock->file, fput_needed);
89978 }
89979 return err;
89980 @@ -1559,10 +1583,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
89981 if ((unsigned int)backlog > somaxconn)
89982 backlog = somaxconn;
89983
89984 + if (gr_handle_sock_server_other(sock->sk)) {
89985 + err = -EPERM;
89986 + goto error;
89987 + }
89988 +
89989 + err = gr_search_listen(sock);
89990 + if (err)
89991 + goto error;
89992 +
89993 err = security_socket_listen(sock, backlog);
89994 if (!err)
89995 err = sock->ops->listen(sock, backlog);
89996
89997 +error:
89998 fput_light(sock->file, fput_needed);
89999 }
90000 return err;
90001 @@ -1606,6 +1640,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90002 newsock->type = sock->type;
90003 newsock->ops = sock->ops;
90004
90005 + if (gr_handle_sock_server_other(sock->sk)) {
90006 + err = -EPERM;
90007 + sock_release(newsock);
90008 + goto out_put;
90009 + }
90010 +
90011 + err = gr_search_accept(sock);
90012 + if (err) {
90013 + sock_release(newsock);
90014 + goto out_put;
90015 + }
90016 +
90017 /*
90018 * We don't need try_module_get here, as the listening socket (sock)
90019 * has the protocol module (sock->ops->owner) held.
90020 @@ -1651,6 +1697,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90021 fd_install(newfd, newfile);
90022 err = newfd;
90023
90024 + gr_attach_curr_ip(newsock->sk);
90025 +
90026 out_put:
90027 fput_light(sock->file, fput_needed);
90028 out:
90029 @@ -1683,6 +1731,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90030 int, addrlen)
90031 {
90032 struct socket *sock;
90033 + struct sockaddr *sck;
90034 struct sockaddr_storage address;
90035 int err, fput_needed;
90036
90037 @@ -1693,6 +1742,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90038 if (err < 0)
90039 goto out_put;
90040
90041 + sck = (struct sockaddr *)&address;
90042 +
90043 + if (gr_handle_sock_client(sck)) {
90044 + err = -EACCES;
90045 + goto out_put;
90046 + }
90047 +
90048 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90049 + if (err)
90050 + goto out_put;
90051 +
90052 err =
90053 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90054 if (err)
90055 @@ -1774,6 +1834,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90056 * the protocol.
90057 */
90058
90059 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90060 +
90061 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90062 unsigned int, flags, struct sockaddr __user *, addr,
90063 int, addr_len)
90064 @@ -1840,7 +1902,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90065 struct socket *sock;
90066 struct iovec iov;
90067 struct msghdr msg;
90068 - struct sockaddr_storage address;
90069 + struct sockaddr_storage address = { };
90070 int err, err2;
90071 int fput_needed;
90072
90073 @@ -2047,7 +2109,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90074 * checking falls down on this.
90075 */
90076 if (copy_from_user(ctl_buf,
90077 - (void __user __force *)msg_sys->msg_control,
90078 + (void __force_user *)msg_sys->msg_control,
90079 ctl_len))
90080 goto out_freectl;
90081 msg_sys->msg_control = ctl_buf;
90082 @@ -2187,7 +2249,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90083 int err, total_len, len;
90084
90085 /* kernel mode address */
90086 - struct sockaddr_storage addr;
90087 + struct sockaddr_storage addr = { };
90088
90089 /* user mode address pointers */
90090 struct sockaddr __user *uaddr;
90091 @@ -2215,7 +2277,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90092 * kernel msghdr to use the kernel address space)
90093 */
90094
90095 - uaddr = (__force void __user *)msg_sys->msg_name;
90096 + uaddr = (void __force_user *)msg_sys->msg_name;
90097 uaddr_len = COMPAT_NAMELEN(msg);
90098 if (MSG_CMSG_COMPAT & flags) {
90099 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90100 @@ -2838,7 +2900,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90101 }
90102
90103 ifr = compat_alloc_user_space(buf_size);
90104 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
90105 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
90106
90107 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
90108 return -EFAULT;
90109 @@ -2862,12 +2924,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90110 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
90111
90112 if (copy_in_user(rxnfc, compat_rxnfc,
90113 - (void *)(&rxnfc->fs.m_ext + 1) -
90114 - (void *)rxnfc) ||
90115 + (void __user *)(&rxnfc->fs.m_ext + 1) -
90116 + (void __user *)rxnfc) ||
90117 copy_in_user(&rxnfc->fs.ring_cookie,
90118 &compat_rxnfc->fs.ring_cookie,
90119 - (void *)(&rxnfc->fs.location + 1) -
90120 - (void *)&rxnfc->fs.ring_cookie) ||
90121 + (void __user *)(&rxnfc->fs.location + 1) -
90122 + (void __user *)&rxnfc->fs.ring_cookie) ||
90123 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
90124 sizeof(rxnfc->rule_cnt)))
90125 return -EFAULT;
90126 @@ -2879,12 +2941,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90127
90128 if (convert_out) {
90129 if (copy_in_user(compat_rxnfc, rxnfc,
90130 - (const void *)(&rxnfc->fs.m_ext + 1) -
90131 - (const void *)rxnfc) ||
90132 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
90133 + (const void __user *)rxnfc) ||
90134 copy_in_user(&compat_rxnfc->fs.ring_cookie,
90135 &rxnfc->fs.ring_cookie,
90136 - (const void *)(&rxnfc->fs.location + 1) -
90137 - (const void *)&rxnfc->fs.ring_cookie) ||
90138 + (const void __user *)(&rxnfc->fs.location + 1) -
90139 + (const void __user *)&rxnfc->fs.ring_cookie) ||
90140 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
90141 sizeof(rxnfc->rule_cnt)))
90142 return -EFAULT;
90143 @@ -2954,7 +3016,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90144 old_fs = get_fs();
90145 set_fs(KERNEL_DS);
90146 err = dev_ioctl(net, cmd,
90147 - (struct ifreq __user __force *) &kifr);
90148 + (struct ifreq __force_user *) &kifr);
90149 set_fs(old_fs);
90150
90151 return err;
90152 @@ -3063,7 +3125,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90153
90154 old_fs = get_fs();
90155 set_fs(KERNEL_DS);
90156 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90157 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90158 set_fs(old_fs);
90159
90160 if (cmd == SIOCGIFMAP && !err) {
90161 @@ -3168,7 +3230,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90162 ret |= __get_user(rtdev, &(ur4->rt_dev));
90163 if (rtdev) {
90164 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90165 - r4.rt_dev = (char __user __force *)devname;
90166 + r4.rt_dev = (char __force_user *)devname;
90167 devname[15] = 0;
90168 } else
90169 r4.rt_dev = NULL;
90170 @@ -3394,8 +3456,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90171 int __user *uoptlen;
90172 int err;
90173
90174 - uoptval = (char __user __force *) optval;
90175 - uoptlen = (int __user __force *) optlen;
90176 + uoptval = (char __force_user *) optval;
90177 + uoptlen = (int __force_user *) optlen;
90178
90179 set_fs(KERNEL_DS);
90180 if (level == SOL_SOCKET)
90181 @@ -3415,7 +3477,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90182 char __user *uoptval;
90183 int err;
90184
90185 - uoptval = (char __user __force *) optval;
90186 + uoptval = (char __force_user *) optval;
90187
90188 set_fs(KERNEL_DS);
90189 if (level == SOL_SOCKET)
90190 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
90191 index 716aa41..75e88ea 100644
90192 --- a/net/sunrpc/clnt.c
90193 +++ b/net/sunrpc/clnt.c
90194 @@ -303,10 +303,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
90195 err = rpciod_up();
90196 if (err)
90197 goto out_no_rpciod;
90198 +
90199 err = -EINVAL;
90200 - if (!xprt)
90201 - goto out_no_xprt;
90202 -
90203 if (args->version >= program->nrvers)
90204 goto out_err;
90205 version = program->version[args->version];
90206 @@ -381,10 +379,9 @@ out_no_principal:
90207 out_no_stats:
90208 kfree(clnt);
90209 out_err:
90210 - xprt_put(xprt);
90211 -out_no_xprt:
90212 rpciod_down();
90213 out_no_rpciod:
90214 + xprt_put(xprt);
90215 return ERR_PTR(err);
90216 }
90217
90218 @@ -1270,7 +1267,9 @@ call_start(struct rpc_task *task)
90219 (RPC_IS_ASYNC(task) ? "async" : "sync"));
90220
90221 /* Increment call count */
90222 - task->tk_msg.rpc_proc->p_count++;
90223 + pax_open_kernel();
90224 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
90225 + pax_close_kernel();
90226 clnt->cl_stats->rpccnt++;
90227 task->tk_action = call_reserve;
90228 }
90229 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
90230 index f8529fc..ce8c643 100644
90231 --- a/net/sunrpc/sched.c
90232 +++ b/net/sunrpc/sched.c
90233 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
90234 #ifdef RPC_DEBUG
90235 static void rpc_task_set_debuginfo(struct rpc_task *task)
90236 {
90237 - static atomic_t rpc_pid;
90238 + static atomic_unchecked_t rpc_pid;
90239
90240 - task->tk_pid = atomic_inc_return(&rpc_pid);
90241 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
90242 }
90243 #else
90244 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
90245 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
90246 index 2d34b6b..e2d584d 100644
90247 --- a/net/sunrpc/svc.c
90248 +++ b/net/sunrpc/svc.c
90249 @@ -1156,7 +1156,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
90250 svc_putnl(resv, RPC_SUCCESS);
90251
90252 /* Bump per-procedure stats counter */
90253 - procp->pc_count++;
90254 + pax_open_kernel();
90255 + (*(unsigned int *)&procp->pc_count)++;
90256 + pax_close_kernel();
90257
90258 /* Initialize storage for argp and resp */
90259 memset(rqstp->rq_argp, 0, procp->pc_argsize);
90260 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
90261 index 8343737..677025e 100644
90262 --- a/net/sunrpc/xprtrdma/svc_rdma.c
90263 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
90264 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
90265 static unsigned int min_max_inline = 4096;
90266 static unsigned int max_max_inline = 65536;
90267
90268 -atomic_t rdma_stat_recv;
90269 -atomic_t rdma_stat_read;
90270 -atomic_t rdma_stat_write;
90271 -atomic_t rdma_stat_sq_starve;
90272 -atomic_t rdma_stat_rq_starve;
90273 -atomic_t rdma_stat_rq_poll;
90274 -atomic_t rdma_stat_rq_prod;
90275 -atomic_t rdma_stat_sq_poll;
90276 -atomic_t rdma_stat_sq_prod;
90277 +atomic_unchecked_t rdma_stat_recv;
90278 +atomic_unchecked_t rdma_stat_read;
90279 +atomic_unchecked_t rdma_stat_write;
90280 +atomic_unchecked_t rdma_stat_sq_starve;
90281 +atomic_unchecked_t rdma_stat_rq_starve;
90282 +atomic_unchecked_t rdma_stat_rq_poll;
90283 +atomic_unchecked_t rdma_stat_rq_prod;
90284 +atomic_unchecked_t rdma_stat_sq_poll;
90285 +atomic_unchecked_t rdma_stat_sq_prod;
90286
90287 /* Temporary NFS request map and context caches */
90288 struct kmem_cache *svc_rdma_map_cachep;
90289 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
90290 len -= *ppos;
90291 if (len > *lenp)
90292 len = *lenp;
90293 - if (len && copy_to_user(buffer, str_buf, len))
90294 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
90295 return -EFAULT;
90296 *lenp = len;
90297 *ppos += len;
90298 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
90299 {
90300 .procname = "rdma_stat_read",
90301 .data = &rdma_stat_read,
90302 - .maxlen = sizeof(atomic_t),
90303 + .maxlen = sizeof(atomic_unchecked_t),
90304 .mode = 0644,
90305 .proc_handler = read_reset_stat,
90306 },
90307 {
90308 .procname = "rdma_stat_recv",
90309 .data = &rdma_stat_recv,
90310 - .maxlen = sizeof(atomic_t),
90311 + .maxlen = sizeof(atomic_unchecked_t),
90312 .mode = 0644,
90313 .proc_handler = read_reset_stat,
90314 },
90315 {
90316 .procname = "rdma_stat_write",
90317 .data = &rdma_stat_write,
90318 - .maxlen = sizeof(atomic_t),
90319 + .maxlen = sizeof(atomic_unchecked_t),
90320 .mode = 0644,
90321 .proc_handler = read_reset_stat,
90322 },
90323 {
90324 .procname = "rdma_stat_sq_starve",
90325 .data = &rdma_stat_sq_starve,
90326 - .maxlen = sizeof(atomic_t),
90327 + .maxlen = sizeof(atomic_unchecked_t),
90328 .mode = 0644,
90329 .proc_handler = read_reset_stat,
90330 },
90331 {
90332 .procname = "rdma_stat_rq_starve",
90333 .data = &rdma_stat_rq_starve,
90334 - .maxlen = sizeof(atomic_t),
90335 + .maxlen = sizeof(atomic_unchecked_t),
90336 .mode = 0644,
90337 .proc_handler = read_reset_stat,
90338 },
90339 {
90340 .procname = "rdma_stat_rq_poll",
90341 .data = &rdma_stat_rq_poll,
90342 - .maxlen = sizeof(atomic_t),
90343 + .maxlen = sizeof(atomic_unchecked_t),
90344 .mode = 0644,
90345 .proc_handler = read_reset_stat,
90346 },
90347 {
90348 .procname = "rdma_stat_rq_prod",
90349 .data = &rdma_stat_rq_prod,
90350 - .maxlen = sizeof(atomic_t),
90351 + .maxlen = sizeof(atomic_unchecked_t),
90352 .mode = 0644,
90353 .proc_handler = read_reset_stat,
90354 },
90355 {
90356 .procname = "rdma_stat_sq_poll",
90357 .data = &rdma_stat_sq_poll,
90358 - .maxlen = sizeof(atomic_t),
90359 + .maxlen = sizeof(atomic_unchecked_t),
90360 .mode = 0644,
90361 .proc_handler = read_reset_stat,
90362 },
90363 {
90364 .procname = "rdma_stat_sq_prod",
90365 .data = &rdma_stat_sq_prod,
90366 - .maxlen = sizeof(atomic_t),
90367 + .maxlen = sizeof(atomic_unchecked_t),
90368 .mode = 0644,
90369 .proc_handler = read_reset_stat,
90370 },
90371 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90372 index 0ce7552..d074459 100644
90373 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90374 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90375 @@ -501,7 +501,7 @@ next_sge:
90376 svc_rdma_put_context(ctxt, 0);
90377 goto out;
90378 }
90379 - atomic_inc(&rdma_stat_read);
90380 + atomic_inc_unchecked(&rdma_stat_read);
90381
90382 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90383 chl_map->ch[ch_no].count -= read_wr.num_sge;
90384 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90385 dto_q);
90386 list_del_init(&ctxt->dto_q);
90387 } else {
90388 - atomic_inc(&rdma_stat_rq_starve);
90389 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90390 clear_bit(XPT_DATA, &xprt->xpt_flags);
90391 ctxt = NULL;
90392 }
90393 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90394 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90395 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90396 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90397 - atomic_inc(&rdma_stat_recv);
90398 + atomic_inc_unchecked(&rdma_stat_recv);
90399
90400 /* Build up the XDR from the receive buffers. */
90401 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90402 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90403 index c1d124d..acfc59e 100644
90404 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90405 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90406 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90407 write_wr.wr.rdma.remote_addr = to;
90408
90409 /* Post It */
90410 - atomic_inc(&rdma_stat_write);
90411 + atomic_inc_unchecked(&rdma_stat_write);
90412 if (svc_rdma_send(xprt, &write_wr))
90413 goto err;
90414 return 0;
90415 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90416 index 62e4f9b..dd3f2d7 100644
90417 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90418 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90419 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90420 return;
90421
90422 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90423 - atomic_inc(&rdma_stat_rq_poll);
90424 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90425
90426 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90427 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90428 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90429 }
90430
90431 if (ctxt)
90432 - atomic_inc(&rdma_stat_rq_prod);
90433 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90434
90435 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90436 /*
90437 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90438 return;
90439
90440 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90441 - atomic_inc(&rdma_stat_sq_poll);
90442 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90443 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90444 if (wc.status != IB_WC_SUCCESS)
90445 /* Close the transport */
90446 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90447 }
90448
90449 if (ctxt)
90450 - atomic_inc(&rdma_stat_sq_prod);
90451 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90452 }
90453
90454 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90455 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90456 spin_lock_bh(&xprt->sc_lock);
90457 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90458 spin_unlock_bh(&xprt->sc_lock);
90459 - atomic_inc(&rdma_stat_sq_starve);
90460 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90461
90462 /* See if we can opportunistically reap SQ WR to make room */
90463 sq_cq_reap(xprt);
90464 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90465 index 9bc6db0..47ac8c0 100644
90466 --- a/net/sysctl_net.c
90467 +++ b/net/sysctl_net.c
90468 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90469 kgid_t root_gid = make_kgid(net->user_ns, 0);
90470
90471 /* Allow network administrator to have same access as root. */
90472 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90473 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90474 uid_eq(root_uid, current_uid())) {
90475 int mode = (table->mode >> 6) & 7;
90476 return (mode << 6) | (mode << 3) | mode;
90477 diff --git a/net/tipc/link.c b/net/tipc/link.c
90478 index daa6080..02d357f 100644
90479 --- a/net/tipc/link.c
90480 +++ b/net/tipc/link.c
90481 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90482 struct tipc_msg fragm_hdr;
90483 struct sk_buff *buf, *buf_chain, *prev;
90484 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90485 - const unchar *sect_crs;
90486 + const unchar __user *sect_crs;
90487 int curr_sect;
90488 u32 fragm_no;
90489
90490 @@ -1242,7 +1242,7 @@ again:
90491
90492 if (!sect_rest) {
90493 sect_rest = msg_sect[++curr_sect].iov_len;
90494 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90495 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90496 }
90497
90498 if (sect_rest < fragm_rest)
90499 @@ -1261,7 +1261,7 @@ error:
90500 }
90501 } else
90502 skb_copy_to_linear_data_offset(buf, fragm_crs,
90503 - sect_crs, sz);
90504 + (const void __force_kernel *)sect_crs, sz);
90505 sect_crs += sz;
90506 sect_rest -= sz;
90507 fragm_crs += sz;
90508 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90509 index f2db8a8..9245aa4 100644
90510 --- a/net/tipc/msg.c
90511 +++ b/net/tipc/msg.c
90512 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90513 msg_sect[cnt].iov_len);
90514 else
90515 skb_copy_to_linear_data_offset(*buf, pos,
90516 - msg_sect[cnt].iov_base,
90517 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90518 msg_sect[cnt].iov_len);
90519 pos += msg_sect[cnt].iov_len;
90520 }
90521 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90522 index 6b42d47..2ac24d5 100644
90523 --- a/net/tipc/subscr.c
90524 +++ b/net/tipc/subscr.c
90525 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90526 {
90527 struct iovec msg_sect;
90528
90529 - msg_sect.iov_base = (void *)&sub->evt;
90530 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90531 msg_sect.iov_len = sizeof(struct tipc_event);
90532
90533 sub->evt.event = htohl(event, sub->swap);
90534 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90535 index b45eb65..bb4b223 100644
90536 --- a/net/unix/af_unix.c
90537 +++ b/net/unix/af_unix.c
90538 @@ -785,6 +785,12 @@ static struct sock *unix_find_other(struct net *net,
90539 err = -ECONNREFUSED;
90540 if (!S_ISSOCK(inode->i_mode))
90541 goto put_fail;
90542 +
90543 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90544 + err = -EACCES;
90545 + goto put_fail;
90546 + }
90547 +
90548 u = unix_find_socket_byinode(inode);
90549 if (!u)
90550 goto put_fail;
90551 @@ -805,6 +811,13 @@ static struct sock *unix_find_other(struct net *net,
90552 if (u) {
90553 struct dentry *dentry;
90554 dentry = unix_sk(u)->path.dentry;
90555 +
90556 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90557 + err = -EPERM;
90558 + sock_put(u);
90559 + goto fail;
90560 + }
90561 +
90562 if (dentry)
90563 touch_atime(&unix_sk(u)->path);
90564 } else
90565 @@ -838,12 +851,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90566 */
90567 err = security_path_mknod(&path, dentry, mode, 0);
90568 if (!err) {
90569 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90570 + err = -EACCES;
90571 + goto out;
90572 + }
90573 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90574 if (!err) {
90575 res->mnt = mntget(path.mnt);
90576 res->dentry = dget(dentry);
90577 + gr_handle_create(dentry, path.mnt);
90578 }
90579 }
90580 +out:
90581 done_path_create(&path, dentry);
90582 return err;
90583 }
90584 @@ -1995,7 +2014,7 @@ again:
90585 if ((UNIXCB(skb).pid != siocb->scm->pid) ||
90586 (UNIXCB(skb).cred != siocb->scm->cred))
90587 break;
90588 - } else {
90589 + } else if (test_bit(SOCK_PASSCRED, &sock->flags)) {
90590 /* Copy credentials */
90591 scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
90592 check_creds = 1;
90593 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90594 seq_puts(seq, "Num RefCount Protocol Flags Type St "
90595 "Inode Path\n");
90596 else {
90597 - struct sock *s = v;
90598 + struct sock *s = v, *peer;
90599 struct unix_sock *u = unix_sk(s);
90600 unix_state_lock(s);
90601 + peer = unix_peer(s);
90602 + unix_state_unlock(s);
90603 +
90604 + unix_state_double_lock(s, peer);
90605
90606 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
90607 s,
90608 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90609 }
90610 for ( ; i < len; i++)
90611 seq_putc(seq, u->addr->name->sun_path[i]);
90612 - }
90613 - unix_state_unlock(s);
90614 + } else if (peer)
90615 + seq_printf(seq, " P%lu", sock_i_ino(peer));
90616 +
90617 + unix_state_double_unlock(s, peer);
90618 seq_putc(seq, '\n');
90619 }
90620
90621 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
90622 index 8800604..0526440 100644
90623 --- a/net/unix/sysctl_net_unix.c
90624 +++ b/net/unix/sysctl_net_unix.c
90625 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
90626
90627 int __net_init unix_sysctl_register(struct net *net)
90628 {
90629 - struct ctl_table *table;
90630 + ctl_table_no_const *table;
90631
90632 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
90633 if (table == NULL)
90634 diff --git a/net/wireless/trace.h b/net/wireless/trace.h
90635 index 2134576..5d71a5a 100644
90636 --- a/net/wireless/trace.h
90637 +++ b/net/wireless/trace.h
90638 @@ -27,7 +27,8 @@
90639 #define WIPHY_PR_ARG __entry->wiphy_name
90640
90641 #define WDEV_ENTRY __field(u32, id)
90642 -#define WDEV_ASSIGN (__entry->id) = (wdev ? wdev->identifier : 0)
90643 +#define WDEV_ASSIGN (__entry->id) = (!IS_ERR_OR_NULL(wdev) \
90644 + ? wdev->identifier : 0)
90645 #define WDEV_PR_FMT "wdev(%u)"
90646 #define WDEV_PR_ARG (__entry->id)
90647
90648 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
90649 index c8717c1..08539f5 100644
90650 --- a/net/wireless/wext-core.c
90651 +++ b/net/wireless/wext-core.c
90652 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90653 */
90654
90655 /* Support for very large requests */
90656 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
90657 - (user_length > descr->max_tokens)) {
90658 + if (user_length > descr->max_tokens) {
90659 /* Allow userspace to GET more than max so
90660 * we can support any size GET requests.
90661 * There is still a limit : -ENOMEM.
90662 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90663 }
90664 }
90665
90666 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
90667 - /*
90668 - * If this is a GET, but not NOMAX, it means that the extra
90669 - * data is not bounded by userspace, but by max_tokens. Thus
90670 - * set the length to max_tokens. This matches the extra data
90671 - * allocation.
90672 - * The driver should fill it with the number of tokens it
90673 - * provided, and it may check iwp->length rather than having
90674 - * knowledge of max_tokens. If the driver doesn't change the
90675 - * iwp->length, this ioctl just copies back max_token tokens
90676 - * filled with zeroes. Hopefully the driver isn't claiming
90677 - * them to be valid data.
90678 - */
90679 - iwp->length = descr->max_tokens;
90680 - }
90681 -
90682 err = handler(dev, info, (union iwreq_data *) iwp, extra);
90683
90684 iwp->length += essid_compat;
90685 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
90686 index 07c5857..fde4018 100644
90687 --- a/net/xfrm/xfrm_policy.c
90688 +++ b/net/xfrm/xfrm_policy.c
90689 @@ -317,7 +317,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
90690 {
90691 policy->walk.dead = 1;
90692
90693 - atomic_inc(&policy->genid);
90694 + atomic_inc_unchecked(&policy->genid);
90695
90696 if (del_timer(&policy->timer))
90697 xfrm_pol_put(policy);
90698 @@ -601,7 +601,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
90699 hlist_add_head(&policy->bydst, chain);
90700 xfrm_pol_hold(policy);
90701 net->xfrm.policy_count[dir]++;
90702 - atomic_inc(&flow_cache_genid);
90703 + atomic_inc_unchecked(&flow_cache_genid);
90704 rt_genid_bump(net);
90705 if (delpol)
90706 __xfrm_policy_unlink(delpol, dir);
90707 @@ -1550,7 +1550,7 @@ free_dst:
90708 goto out;
90709 }
90710
90711 -static int inline
90712 +static inline int
90713 xfrm_dst_alloc_copy(void **target, const void *src, int size)
90714 {
90715 if (!*target) {
90716 @@ -1562,7 +1562,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
90717 return 0;
90718 }
90719
90720 -static int inline
90721 +static inline int
90722 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90723 {
90724 #ifdef CONFIG_XFRM_SUB_POLICY
90725 @@ -1574,7 +1574,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90726 #endif
90727 }
90728
90729 -static int inline
90730 +static inline int
90731 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
90732 {
90733 #ifdef CONFIG_XFRM_SUB_POLICY
90734 @@ -1668,7 +1668,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
90735
90736 xdst->num_pols = num_pols;
90737 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
90738 - xdst->policy_genid = atomic_read(&pols[0]->genid);
90739 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
90740
90741 return xdst;
90742 }
90743 @@ -2369,7 +2369,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
90744 if (xdst->xfrm_genid != dst->xfrm->genid)
90745 return 0;
90746 if (xdst->num_pols > 0 &&
90747 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
90748 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
90749 return 0;
90750
90751 mtu = dst_mtu(dst->child);
90752 @@ -2457,8 +2457,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
90753 dst_ops->link_failure = xfrm_link_failure;
90754 if (likely(dst_ops->neigh_lookup == NULL))
90755 dst_ops->neigh_lookup = xfrm_neigh_lookup;
90756 - if (likely(afinfo->garbage_collect == NULL))
90757 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90758 + if (likely(afinfo->garbage_collect == NULL)) {
90759 + pax_open_kernel();
90760 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90761 + pax_close_kernel();
90762 + }
90763 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
90764 }
90765 spin_unlock(&xfrm_policy_afinfo_lock);
90766 @@ -2512,7 +2515,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
90767 dst_ops->check = NULL;
90768 dst_ops->negative_advice = NULL;
90769 dst_ops->link_failure = NULL;
90770 - afinfo->garbage_collect = NULL;
90771 + pax_open_kernel();
90772 + *(void **)&afinfo->garbage_collect = NULL;
90773 + pax_close_kernel();
90774 }
90775 return err;
90776 }
90777 @@ -2896,7 +2901,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
90778 sizeof(pol->xfrm_vec[i].saddr));
90779 pol->xfrm_vec[i].encap_family = mp->new_family;
90780 /* flush bundles */
90781 - atomic_inc(&pol->genid);
90782 + atomic_inc_unchecked(&pol->genid);
90783 }
90784 }
90785
90786 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
90787 index 3459692..e7cdb1a 100644
90788 --- a/net/xfrm/xfrm_state.c
90789 +++ b/net/xfrm/xfrm_state.c
90790 @@ -194,11 +194,13 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
90791
90792 if (unlikely(afinfo == NULL))
90793 return -EAFNOSUPPORT;
90794 - typemap = afinfo->type_map;
90795 + typemap = (const struct xfrm_type **)afinfo->type_map;
90796
90797 - if (likely(typemap[type->proto] == NULL))
90798 + if (likely(typemap[type->proto] == NULL)) {
90799 + pax_open_kernel();
90800 typemap[type->proto] = type;
90801 - else
90802 + pax_close_kernel();
90803 + } else
90804 err = -EEXIST;
90805 xfrm_state_unlock_afinfo(afinfo);
90806 return err;
90807 @@ -213,12 +215,15 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
90808
90809 if (unlikely(afinfo == NULL))
90810 return -EAFNOSUPPORT;
90811 - typemap = afinfo->type_map;
90812 + typemap = (const struct xfrm_type **)afinfo->type_map;
90813
90814 if (unlikely(typemap[type->proto] != type))
90815 err = -ENOENT;
90816 - else
90817 + else {
90818 + pax_open_kernel();
90819 typemap[type->proto] = NULL;
90820 + pax_close_kernel();
90821 + }
90822 xfrm_state_unlock_afinfo(afinfo);
90823 return err;
90824 }
90825 @@ -227,7 +232,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
90826 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
90827 {
90828 struct xfrm_state_afinfo *afinfo;
90829 - const struct xfrm_type **typemap;
90830 const struct xfrm_type *type;
90831 int modload_attempted = 0;
90832
90833 @@ -235,9 +239,8 @@ retry:
90834 afinfo = xfrm_state_get_afinfo(family);
90835 if (unlikely(afinfo == NULL))
90836 return NULL;
90837 - typemap = afinfo->type_map;
90838
90839 - type = typemap[proto];
90840 + type = afinfo->type_map[proto];
90841 if (unlikely(type && !try_module_get(type->owner)))
90842 type = NULL;
90843 if (!type && !modload_attempted) {
90844 @@ -270,7 +273,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90845 return -EAFNOSUPPORT;
90846
90847 err = -EEXIST;
90848 - modemap = afinfo->mode_map;
90849 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90850 if (modemap[mode->encap])
90851 goto out;
90852
90853 @@ -278,8 +281,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90854 if (!try_module_get(afinfo->owner))
90855 goto out;
90856
90857 - mode->afinfo = afinfo;
90858 + pax_open_kernel();
90859 + *(const void **)&mode->afinfo = afinfo;
90860 modemap[mode->encap] = mode;
90861 + pax_close_kernel();
90862 err = 0;
90863
90864 out:
90865 @@ -302,9 +307,11 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
90866 return -EAFNOSUPPORT;
90867
90868 err = -ENOENT;
90869 - modemap = afinfo->mode_map;
90870 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90871 if (likely(modemap[mode->encap] == mode)) {
90872 + pax_open_kernel();
90873 modemap[mode->encap] = NULL;
90874 + pax_close_kernel();
90875 module_put(mode->afinfo->owner);
90876 err = 0;
90877 }
90878 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
90879 index 05a6e3d..6716ec9 100644
90880 --- a/net/xfrm/xfrm_sysctl.c
90881 +++ b/net/xfrm/xfrm_sysctl.c
90882 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
90883
90884 int __net_init xfrm_sysctl_init(struct net *net)
90885 {
90886 - struct ctl_table *table;
90887 + ctl_table_no_const *table;
90888
90889 __xfrm_sysctl_init(net);
90890
90891 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
90892 index 0e801c3..5c8ad3b 100644
90893 --- a/scripts/Makefile.build
90894 +++ b/scripts/Makefile.build
90895 @@ -111,7 +111,7 @@ endif
90896 endif
90897
90898 # Do not include host rules unless needed
90899 -ifneq ($(hostprogs-y)$(hostprogs-m),)
90900 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
90901 include scripts/Makefile.host
90902 endif
90903
90904 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
90905 index 686cb0d..9d653bf 100644
90906 --- a/scripts/Makefile.clean
90907 +++ b/scripts/Makefile.clean
90908 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
90909 __clean-files := $(extra-y) $(always) \
90910 $(targets) $(clean-files) \
90911 $(host-progs) \
90912 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
90913 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
90914 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
90915
90916 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
90917
90918 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
90919 index 1ac414f..38575f7 100644
90920 --- a/scripts/Makefile.host
90921 +++ b/scripts/Makefile.host
90922 @@ -31,6 +31,8 @@
90923 # Note: Shared libraries consisting of C++ files are not supported
90924
90925 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
90926 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
90927 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
90928
90929 # C code
90930 # Executables compiled from a single .c file
90931 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
90932 # Shared libaries (only .c supported)
90933 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
90934 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
90935 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
90936 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
90937 # Remove .so files from "xxx-objs"
90938 host-cobjs := $(filter-out %.so,$(host-cobjs))
90939 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
90940
90941 -#Object (.o) files used by the shared libaries
90942 +# Object (.o) files used by the shared libaries
90943 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
90944 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
90945
90946 # output directory for programs/.o files
90947 # hostprogs-y := tools/build may have been specified. Retrieve directory
90948 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
90949 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
90950 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
90951 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
90952 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
90953 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
90954 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
90955 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
90956
90957 obj-dirs += $(host-objdirs)
90958 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
90959 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
90960 $(call if_changed_dep,host-cshobjs)
90961
90962 +# Compile .c file, create position independent .o file
90963 +# host-cxxshobjs -> .o
90964 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
90965 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
90966 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
90967 + $(call if_changed_dep,host-cxxshobjs)
90968 +
90969 # Link a shared library, based on position independent .o files
90970 # *.o -> .so shared library (host-cshlib)
90971 quiet_cmd_host-cshlib = HOSTLLD -shared $@
90972 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
90973 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
90974 $(call if_changed,host-cshlib)
90975
90976 +# Link a shared library, based on position independent .o files
90977 +# *.o -> .so shared library (host-cxxshlib)
90978 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
90979 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
90980 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
90981 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
90982 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
90983 + $(call if_changed,host-cxxshlib)
90984 +
90985 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
90986 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
90987 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
90988
90989 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
90990 index cb1f50c..cef2a7c 100644
90991 --- a/scripts/basic/fixdep.c
90992 +++ b/scripts/basic/fixdep.c
90993 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
90994 /*
90995 * Lookup a value in the configuration string.
90996 */
90997 -static int is_defined_config(const char *name, int len, unsigned int hash)
90998 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
90999 {
91000 struct item *aux;
91001
91002 @@ -211,10 +211,10 @@ static void clear_config(void)
91003 /*
91004 * Record the use of a CONFIG_* word.
91005 */
91006 -static void use_config(const char *m, int slen)
91007 +static void use_config(const char *m, unsigned int slen)
91008 {
91009 unsigned int hash = strhash(m, slen);
91010 - int c, i;
91011 + unsigned int c, i;
91012
91013 if (is_defined_config(m, slen, hash))
91014 return;
91015 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91016
91017 static void parse_config_file(const char *map, size_t len)
91018 {
91019 - const int *end = (const int *) (map + len);
91020 + const unsigned int *end = (const unsigned int *) (map + len);
91021 /* start at +1, so that p can never be < map */
91022 - const int *m = (const int *) map + 1;
91023 + const unsigned int *m = (const unsigned int *) map + 1;
91024 const char *p, *q;
91025
91026 for (; m < end; m++) {
91027 @@ -406,7 +406,7 @@ static void print_deps(void)
91028 static void traps(void)
91029 {
91030 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91031 - int *p = (int *)test;
91032 + unsigned int *p = (unsigned int *)test;
91033
91034 if (*p != INT_CONF) {
91035 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
91036 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91037 new file mode 100644
91038 index 0000000..5e0222d
91039 --- /dev/null
91040 +++ b/scripts/gcc-plugin.sh
91041 @@ -0,0 +1,17 @@
91042 +#!/bin/bash
91043 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91044 +#include "gcc-plugin.h"
91045 +#include "tree.h"
91046 +#include "tm.h"
91047 +#include "rtl.h"
91048 +#ifdef ENABLE_BUILD_WITH_CXX
91049 +#warning $2
91050 +#else
91051 +#warning $1
91052 +#endif
91053 +EOF`
91054 +if [ $? -eq 0 ]
91055 +then
91056 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91057 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91058 +fi
91059 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
91060 index 581ca99..a6ff02e 100644
91061 --- a/scripts/headers_install.pl
91062 +++ b/scripts/headers_install.pl
91063 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
91064 $line =~ s/([\s(])__user\s/$1/g;
91065 $line =~ s/([\s(])__force\s/$1/g;
91066 $line =~ s/([\s(])__iomem\s/$1/g;
91067 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
91068 $line =~ s/\s__attribute_const__\s/ /g;
91069 $line =~ s/\s__attribute_const__$//g;
91070 $line =~ s/\b__packed\b/__attribute__((packed))/g;
91071 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91072 index b3d907e..a4782ab 100644
91073 --- a/scripts/link-vmlinux.sh
91074 +++ b/scripts/link-vmlinux.sh
91075 @@ -152,7 +152,7 @@ else
91076 fi;
91077
91078 # final build of init/
91079 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91080 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91081
91082 kallsymso=""
91083 kallsyms_vmlinux=""
91084 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91085 index df4fc23..0ea719d 100644
91086 --- a/scripts/mod/file2alias.c
91087 +++ b/scripts/mod/file2alias.c
91088 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
91089 unsigned long size, unsigned long id_size,
91090 void *symval)
91091 {
91092 - int i;
91093 + unsigned int i;
91094
91095 if (size % id_size || size < id_size) {
91096 if (cross_build != 0)
91097 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
91098 /* USB is special because the bcdDevice can be matched against a numeric range */
91099 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91100 static void do_usb_entry(struct usb_device_id *id,
91101 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91102 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91103 unsigned char range_lo, unsigned char range_hi,
91104 unsigned char max, struct module *mod)
91105 {
91106 @@ -262,7 +262,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
91107 {
91108 unsigned int devlo, devhi;
91109 unsigned char chi, clo, max;
91110 - int ndigits;
91111 + unsigned int ndigits;
91112
91113 id->match_flags = TO_NATIVE(id->match_flags);
91114 id->idVendor = TO_NATIVE(id->idVendor);
91115 @@ -507,7 +507,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91116 for (i = 0; i < count; i++) {
91117 const char *id = (char *)devs[i].id;
91118 char acpi_id[sizeof(devs[0].id)];
91119 - int j;
91120 + unsigned int j;
91121
91122 buf_printf(&mod->dev_table_buf,
91123 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91124 @@ -537,7 +537,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91125
91126 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91127 const char *id = (char *)card->devs[j].id;
91128 - int i2, j2;
91129 + unsigned int i2, j2;
91130 int dup = 0;
91131
91132 if (!id[0])
91133 @@ -563,7 +563,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91134 /* add an individual alias for every device entry */
91135 if (!dup) {
91136 char acpi_id[sizeof(card->devs[0].id)];
91137 - int k;
91138 + unsigned int k;
91139
91140 buf_printf(&mod->dev_table_buf,
91141 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91142 @@ -888,7 +888,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91143 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
91144 char *alias)
91145 {
91146 - int i, j;
91147 + unsigned int i, j;
91148
91149 sprintf(alias, "dmi*");
91150
91151 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91152 index ff36c50..7ab4fa9 100644
91153 --- a/scripts/mod/modpost.c
91154 +++ b/scripts/mod/modpost.c
91155 @@ -929,6 +929,7 @@ enum mismatch {
91156 ANY_INIT_TO_ANY_EXIT,
91157 ANY_EXIT_TO_ANY_INIT,
91158 EXPORT_TO_INIT_EXIT,
91159 + DATA_TO_TEXT
91160 };
91161
91162 struct sectioncheck {
91163 @@ -1043,6 +1044,12 @@ const struct sectioncheck sectioncheck[] = {
91164 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91165 .mismatch = EXPORT_TO_INIT_EXIT,
91166 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
91167 +},
91168 +/* Do not reference code from writable data */
91169 +{
91170 + .fromsec = { DATA_SECTIONS, NULL },
91171 + .tosec = { TEXT_SECTIONS, NULL },
91172 + .mismatch = DATA_TO_TEXT
91173 }
91174 };
91175
91176 @@ -1165,10 +1172,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
91177 continue;
91178 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
91179 continue;
91180 - if (sym->st_value == addr)
91181 - return sym;
91182 /* Find a symbol nearby - addr are maybe negative */
91183 d = sym->st_value - addr;
91184 + if (d == 0)
91185 + return sym;
91186 if (d < 0)
91187 d = addr - sym->st_value;
91188 if (d < distance) {
91189 @@ -1447,6 +1454,14 @@ static void report_sec_mismatch(const char *modname,
91190 tosym, prl_to, prl_to, tosym);
91191 free(prl_to);
91192 break;
91193 + case DATA_TO_TEXT:
91194 +#if 0
91195 + fprintf(stderr,
91196 + "The %s %s:%s references\n"
91197 + "the %s %s:%s%s\n",
91198 + from, fromsec, fromsym, to, tosec, tosym, to_p);
91199 +#endif
91200 + break;
91201 }
91202 fprintf(stderr, "\n");
91203 }
91204 @@ -1681,7 +1696,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
91205 static void check_sec_ref(struct module *mod, const char *modname,
91206 struct elf_info *elf)
91207 {
91208 - int i;
91209 + unsigned int i;
91210 Elf_Shdr *sechdrs = elf->sechdrs;
91211
91212 /* Walk through all sections */
91213 @@ -1779,7 +1794,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
91214 va_end(ap);
91215 }
91216
91217 -void buf_write(struct buffer *buf, const char *s, int len)
91218 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
91219 {
91220 if (buf->size - buf->pos < len) {
91221 buf->size += len + SZ;
91222 @@ -1997,7 +2012,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
91223 if (fstat(fileno(file), &st) < 0)
91224 goto close_write;
91225
91226 - if (st.st_size != b->pos)
91227 + if (st.st_size != (off_t)b->pos)
91228 goto close_write;
91229
91230 tmp = NOFAIL(malloc(b->pos));
91231 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
91232 index 51207e4..f7d603d 100644
91233 --- a/scripts/mod/modpost.h
91234 +++ b/scripts/mod/modpost.h
91235 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
91236
91237 struct buffer {
91238 char *p;
91239 - int pos;
91240 - int size;
91241 + unsigned int pos;
91242 + unsigned int size;
91243 };
91244
91245 void __attribute__((format(printf, 2, 3)))
91246 buf_printf(struct buffer *buf, const char *fmt, ...);
91247
91248 void
91249 -buf_write(struct buffer *buf, const char *s, int len);
91250 +buf_write(struct buffer *buf, const char *s, unsigned int len);
91251
91252 struct module {
91253 struct module *next;
91254 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
91255 index 9dfcd6d..099068e 100644
91256 --- a/scripts/mod/sumversion.c
91257 +++ b/scripts/mod/sumversion.c
91258 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
91259 goto out;
91260 }
91261
91262 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
91263 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
91264 warn("writing sum in %s failed: %s\n",
91265 filename, strerror(errno));
91266 goto out;
91267 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
91268 index acb8650..b8c5f02 100644
91269 --- a/scripts/package/builddeb
91270 +++ b/scripts/package/builddeb
91271 @@ -246,6 +246,7 @@ fi
91272 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
91273 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
91274 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
91275 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
91276 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
91277 mkdir -p "$destdir"
91278 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
91279 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
91280 index 68bb4ef..2f419e1 100644
91281 --- a/scripts/pnmtologo.c
91282 +++ b/scripts/pnmtologo.c
91283 @@ -244,14 +244,14 @@ static void write_header(void)
91284 fprintf(out, " * Linux logo %s\n", logoname);
91285 fputs(" */\n\n", out);
91286 fputs("#include <linux/linux_logo.h>\n\n", out);
91287 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
91288 + fprintf(out, "static unsigned char %s_data[] = {\n",
91289 logoname);
91290 }
91291
91292 static void write_footer(void)
91293 {
91294 fputs("\n};\n\n", out);
91295 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
91296 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
91297 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
91298 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
91299 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
91300 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
91301 fputs("\n};\n\n", out);
91302
91303 /* write logo clut */
91304 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
91305 + fprintf(out, "static unsigned char %s_clut[] = {\n",
91306 logoname);
91307 write_hex_cnt = 0;
91308 for (i = 0; i < logo_clutsize; i++) {
91309 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
91310 index e4fd45b..2eeb5c4 100644
91311 --- a/scripts/sortextable.h
91312 +++ b/scripts/sortextable.h
91313 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
91314 const char *secstrtab;
91315 const char *strtab;
91316 char *extab_image;
91317 - int extab_index = 0;
91318 - int i;
91319 - int idx;
91320 + unsigned int extab_index = 0;
91321 + unsigned int i;
91322 + unsigned int idx;
91323
91324 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91325 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91326 diff --git a/security/Kconfig b/security/Kconfig
91327 index e9c6ac7..20df9f1 100644
91328 --- a/security/Kconfig
91329 +++ b/security/Kconfig
91330 @@ -4,6 +4,944 @@
91331
91332 menu "Security options"
91333
91334 +menu "Grsecurity"
91335 +
91336 + config ARCH_TRACK_EXEC_LIMIT
91337 + bool
91338 +
91339 + config PAX_KERNEXEC_PLUGIN
91340 + bool
91341 +
91342 + config PAX_PER_CPU_PGD
91343 + bool
91344 +
91345 + config TASK_SIZE_MAX_SHIFT
91346 + int
91347 + depends on X86_64
91348 + default 47 if !PAX_PER_CPU_PGD
91349 + default 42 if PAX_PER_CPU_PGD
91350 +
91351 + config PAX_ENABLE_PAE
91352 + bool
91353 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91354 +
91355 + config PAX_USERCOPY_SLABS
91356 + bool
91357 +
91358 +config GRKERNSEC
91359 + bool "Grsecurity"
91360 + select CRYPTO
91361 + select CRYPTO_SHA256
91362 + select PROC_FS
91363 + select STOP_MACHINE
91364 + help
91365 + If you say Y here, you will be able to configure many features
91366 + that will enhance the security of your system. It is highly
91367 + recommended that you say Y here and read through the help
91368 + for each option so that you fully understand the features and
91369 + can evaluate their usefulness for your machine.
91370 +
91371 +choice
91372 + prompt "Configuration Method"
91373 + depends on GRKERNSEC
91374 + default GRKERNSEC_CONFIG_CUSTOM
91375 + help
91376 +
91377 +config GRKERNSEC_CONFIG_AUTO
91378 + bool "Automatic"
91379 + help
91380 + If you choose this configuration method, you'll be able to answer a small
91381 + number of simple questions about how you plan to use this kernel.
91382 + The settings of grsecurity and PaX will be automatically configured for
91383 + the highest commonly-used settings within the provided constraints.
91384 +
91385 + If you require additional configuration, custom changes can still be made
91386 + from the "custom configuration" menu.
91387 +
91388 +config GRKERNSEC_CONFIG_CUSTOM
91389 + bool "Custom"
91390 + help
91391 + If you choose this configuration method, you'll be able to configure all
91392 + grsecurity and PaX settings manually. Via this method, no options are
91393 + automatically enabled.
91394 +
91395 +endchoice
91396 +
91397 +choice
91398 + prompt "Usage Type"
91399 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91400 + default GRKERNSEC_CONFIG_SERVER
91401 + help
91402 +
91403 +config GRKERNSEC_CONFIG_SERVER
91404 + bool "Server"
91405 + help
91406 + Choose this option if you plan to use this kernel on a server.
91407 +
91408 +config GRKERNSEC_CONFIG_DESKTOP
91409 + bool "Desktop"
91410 + help
91411 + Choose this option if you plan to use this kernel on a desktop.
91412 +
91413 +endchoice
91414 +
91415 +choice
91416 + prompt "Virtualization Type"
91417 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91418 + default GRKERNSEC_CONFIG_VIRT_NONE
91419 + help
91420 +
91421 +config GRKERNSEC_CONFIG_VIRT_NONE
91422 + bool "None"
91423 + help
91424 + Choose this option if this kernel will be run on bare metal.
91425 +
91426 +config GRKERNSEC_CONFIG_VIRT_GUEST
91427 + bool "Guest"
91428 + help
91429 + Choose this option if this kernel will be run as a VM guest.
91430 +
91431 +config GRKERNSEC_CONFIG_VIRT_HOST
91432 + bool "Host"
91433 + help
91434 + Choose this option if this kernel will be run as a VM host.
91435 +
91436 +endchoice
91437 +
91438 +choice
91439 + prompt "Virtualization Hardware"
91440 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91441 + help
91442 +
91443 +config GRKERNSEC_CONFIG_VIRT_EPT
91444 + bool "EPT/RVI Processor Support"
91445 + depends on X86
91446 + help
91447 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91448 + hardware virtualization. This allows for additional kernel hardening protections
91449 + to operate without additional performance impact.
91450 +
91451 + To see if your Intel processor supports EPT, see:
91452 + http://ark.intel.com/Products/VirtualizationTechnology
91453 + (Most Core i3/5/7 support EPT)
91454 +
91455 + To see if your AMD processor supports RVI, see:
91456 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91457 +
91458 +config GRKERNSEC_CONFIG_VIRT_SOFT
91459 + bool "First-gen/No Hardware Virtualization"
91460 + help
91461 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91462 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91463 +
91464 +endchoice
91465 +
91466 +choice
91467 + prompt "Virtualization Software"
91468 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91469 + help
91470 +
91471 +config GRKERNSEC_CONFIG_VIRT_XEN
91472 + bool "Xen"
91473 + help
91474 + Choose this option if this kernel is running as a Xen guest or host.
91475 +
91476 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91477 + bool "VMWare"
91478 + help
91479 + Choose this option if this kernel is running as a VMWare guest or host.
91480 +
91481 +config GRKERNSEC_CONFIG_VIRT_KVM
91482 + bool "KVM"
91483 + help
91484 + Choose this option if this kernel is running as a KVM guest or host.
91485 +
91486 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91487 + bool "VirtualBox"
91488 + help
91489 + Choose this option if this kernel is running as a VirtualBox guest or host.
91490 +
91491 +endchoice
91492 +
91493 +choice
91494 + prompt "Required Priorities"
91495 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91496 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91497 + help
91498 +
91499 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91500 + bool "Performance"
91501 + help
91502 + Choose this option if performance is of highest priority for this deployment
91503 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91504 + clearing of structures intended for userland, and freed memory sanitizing will
91505 + be disabled.
91506 +
91507 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91508 + bool "Security"
91509 + help
91510 + Choose this option if security is of highest priority for this deployment of
91511 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91512 + for userland, and freed memory sanitizing will be enabled for this kernel.
91513 + In a worst-case scenario, these features can introduce a 20% performance hit
91514 + (UDEREF on x64 contributing half of this hit).
91515 +
91516 +endchoice
91517 +
91518 +menu "Default Special Groups"
91519 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91520 +
91521 +config GRKERNSEC_PROC_GID
91522 + int "GID exempted from /proc restrictions"
91523 + default 1001
91524 + help
91525 + Setting this GID determines which group will be exempted from
91526 + grsecurity's /proc restrictions, allowing users of the specified
91527 + group to view network statistics and the existence of other users'
91528 + processes on the system. This GID may also be chosen at boot time
91529 + via "grsec_proc_gid=" on the kernel commandline.
91530 +
91531 +config GRKERNSEC_TPE_UNTRUSTED_GID
91532 + int "GID for TPE-untrusted users"
91533 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91534 + default 1005
91535 + help
91536 + Setting this GID determines which group untrusted users should
91537 + be added to. These users will be placed under grsecurity's Trusted Path
91538 + Execution mechanism, preventing them from executing their own binaries.
91539 + The users will only be able to execute binaries in directories owned and
91540 + writable only by the root user. If the sysctl option is enabled, a sysctl
91541 + option with name "tpe_gid" is created.
91542 +
91543 +config GRKERNSEC_TPE_TRUSTED_GID
91544 + int "GID for TPE-trusted users"
91545 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91546 + default 1005
91547 + help
91548 + Setting this GID determines what group TPE restrictions will be
91549 + *disabled* for. If the sysctl option is enabled, a sysctl option
91550 + with name "tpe_gid" is created.
91551 +
91552 +config GRKERNSEC_SYMLINKOWN_GID
91553 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91554 + depends on GRKERNSEC_CONFIG_SERVER
91555 + default 1006
91556 + help
91557 + Setting this GID determines what group kernel-enforced
91558 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91559 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91560 +
91561 +
91562 +endmenu
91563 +
91564 +menu "Customize Configuration"
91565 +depends on GRKERNSEC
91566 +
91567 +menu "PaX"
91568 +
91569 +config PAX
91570 + bool "Enable various PaX features"
91571 + default y if GRKERNSEC_CONFIG_AUTO
91572 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91573 + help
91574 + This allows you to enable various PaX features. PaX adds
91575 + intrusion prevention mechanisms to the kernel that reduce
91576 + the risks posed by exploitable memory corruption bugs.
91577 +
91578 +menu "PaX Control"
91579 + depends on PAX
91580 +
91581 +config PAX_SOFTMODE
91582 + bool 'Support soft mode'
91583 + help
91584 + Enabling this option will allow you to run PaX in soft mode, that
91585 + is, PaX features will not be enforced by default, only on executables
91586 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91587 + support as they are the only way to mark executables for soft mode use.
91588 +
91589 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91590 + line option on boot. Furthermore you can control various PaX features
91591 + at runtime via the entries in /proc/sys/kernel/pax.
91592 +
91593 +config PAX_EI_PAX
91594 + bool 'Use legacy ELF header marking'
91595 + default y if GRKERNSEC_CONFIG_AUTO
91596 + help
91597 + Enabling this option will allow you to control PaX features on
91598 + a per executable basis via the 'chpax' utility available at
91599 + http://pax.grsecurity.net/. The control flags will be read from
91600 + an otherwise reserved part of the ELF header. This marking has
91601 + numerous drawbacks (no support for soft-mode, toolchain does not
91602 + know about the non-standard use of the ELF header) therefore it
91603 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
91604 + support.
91605 +
91606 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
91607 + support as well, they will override the legacy EI_PAX marks.
91608 +
91609 + If you enable none of the marking options then all applications
91610 + will run with PaX enabled on them by default.
91611 +
91612 +config PAX_PT_PAX_FLAGS
91613 + bool 'Use ELF program header marking'
91614 + default y if GRKERNSEC_CONFIG_AUTO
91615 + help
91616 + Enabling this option will allow you to control PaX features on
91617 + a per executable basis via the 'paxctl' utility available at
91618 + http://pax.grsecurity.net/. The control flags will be read from
91619 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
91620 + has the benefits of supporting both soft mode and being fully
91621 + integrated into the toolchain (the binutils patch is available
91622 + from http://pax.grsecurity.net).
91623 +
91624 + Note that if you enable the legacy EI_PAX marking support as well,
91625 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
91626 +
91627 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91628 + must make sure that the marks are the same if a binary has both marks.
91629 +
91630 + If you enable none of the marking options then all applications
91631 + will run with PaX enabled on them by default.
91632 +
91633 +config PAX_XATTR_PAX_FLAGS
91634 + bool 'Use filesystem extended attributes marking'
91635 + default y if GRKERNSEC_CONFIG_AUTO
91636 + select CIFS_XATTR if CIFS
91637 + select EXT2_FS_XATTR if EXT2_FS
91638 + select EXT3_FS_XATTR if EXT3_FS
91639 + select EXT4_FS_XATTR if EXT4_FS
91640 + select JFFS2_FS_XATTR if JFFS2_FS
91641 + select REISERFS_FS_XATTR if REISERFS_FS
91642 + select SQUASHFS_XATTR if SQUASHFS
91643 + select TMPFS_XATTR if TMPFS
91644 + select UBIFS_FS_XATTR if UBIFS_FS
91645 + help
91646 + Enabling this option will allow you to control PaX features on
91647 + a per executable basis via the 'setfattr' utility. The control
91648 + flags will be read from the user.pax.flags extended attribute of
91649 + the file. This marking has the benefit of supporting binary-only
91650 + applications that self-check themselves (e.g., skype) and would
91651 + not tolerate chpax/paxctl changes. The main drawback is that
91652 + extended attributes are not supported by some filesystems (e.g.,
91653 + isofs, udf, vfat) so copying files through such filesystems will
91654 + lose the extended attributes and these PaX markings.
91655 +
91656 + Note that if you enable the legacy EI_PAX marking support as well,
91657 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
91658 +
91659 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91660 + must make sure that the marks are the same if a binary has both marks.
91661 +
91662 + If you enable none of the marking options then all applications
91663 + will run with PaX enabled on them by default.
91664 +
91665 +choice
91666 + prompt 'MAC system integration'
91667 + default PAX_HAVE_ACL_FLAGS
91668 + help
91669 + Mandatory Access Control systems have the option of controlling
91670 + PaX flags on a per executable basis, choose the method supported
91671 + by your particular system.
91672 +
91673 + - "none": if your MAC system does not interact with PaX,
91674 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
91675 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
91676 +
91677 + NOTE: this option is for developers/integrators only.
91678 +
91679 + config PAX_NO_ACL_FLAGS
91680 + bool 'none'
91681 +
91682 + config PAX_HAVE_ACL_FLAGS
91683 + bool 'direct'
91684 +
91685 + config PAX_HOOK_ACL_FLAGS
91686 + bool 'hook'
91687 +endchoice
91688 +
91689 +endmenu
91690 +
91691 +menu "Non-executable pages"
91692 + depends on PAX
91693 +
91694 +config PAX_NOEXEC
91695 + bool "Enforce non-executable pages"
91696 + default y if GRKERNSEC_CONFIG_AUTO
91697 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
91698 + help
91699 + By design some architectures do not allow for protecting memory
91700 + pages against execution or even if they do, Linux does not make
91701 + use of this feature. In practice this means that if a page is
91702 + readable (such as the stack or heap) it is also executable.
91703 +
91704 + There is a well known exploit technique that makes use of this
91705 + fact and a common programming mistake where an attacker can
91706 + introduce code of his choice somewhere in the attacked program's
91707 + memory (typically the stack or the heap) and then execute it.
91708 +
91709 + If the attacked program was running with different (typically
91710 + higher) privileges than that of the attacker, then he can elevate
91711 + his own privilege level (e.g. get a root shell, write to files for
91712 + which he does not have write access to, etc).
91713 +
91714 + Enabling this option will let you choose from various features
91715 + that prevent the injection and execution of 'foreign' code in
91716 + a program.
91717 +
91718 + This will also break programs that rely on the old behaviour and
91719 + expect that dynamically allocated memory via the malloc() family
91720 + of functions is executable (which it is not). Notable examples
91721 + are the XFree86 4.x server, the java runtime and wine.
91722 +
91723 +config PAX_PAGEEXEC
91724 + bool "Paging based non-executable pages"
91725 + default y if GRKERNSEC_CONFIG_AUTO
91726 + 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)
91727 + select S390_SWITCH_AMODE if S390
91728 + select S390_EXEC_PROTECT if S390
91729 + select ARCH_TRACK_EXEC_LIMIT if X86_32
91730 + help
91731 + This implementation is based on the paging feature of the CPU.
91732 + On i386 without hardware non-executable bit support there is a
91733 + variable but usually low performance impact, however on Intel's
91734 + P4 core based CPUs it is very high so you should not enable this
91735 + for kernels meant to be used on such CPUs.
91736 +
91737 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
91738 + with hardware non-executable bit support there is no performance
91739 + impact, on ppc the impact is negligible.
91740 +
91741 + Note that several architectures require various emulations due to
91742 + badly designed userland ABIs, this will cause a performance impact
91743 + but will disappear as soon as userland is fixed. For example, ppc
91744 + userland MUST have been built with secure-plt by a recent toolchain.
91745 +
91746 +config PAX_SEGMEXEC
91747 + bool "Segmentation based non-executable pages"
91748 + default y if GRKERNSEC_CONFIG_AUTO
91749 + depends on PAX_NOEXEC && X86_32
91750 + help
91751 + This implementation is based on the segmentation feature of the
91752 + CPU and has a very small performance impact, however applications
91753 + will be limited to a 1.5 GB address space instead of the normal
91754 + 3 GB.
91755 +
91756 +config PAX_EMUTRAMP
91757 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
91758 + default y if PARISC
91759 + help
91760 + There are some programs and libraries that for one reason or
91761 + another attempt to execute special small code snippets from
91762 + non-executable memory pages. Most notable examples are the
91763 + signal handler return code generated by the kernel itself and
91764 + the GCC trampolines.
91765 +
91766 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
91767 + such programs will no longer work under your kernel.
91768 +
91769 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
91770 + utilities to enable trampoline emulation for the affected programs
91771 + yet still have the protection provided by the non-executable pages.
91772 +
91773 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
91774 + your system will not even boot.
91775 +
91776 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
91777 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
91778 + for the affected files.
91779 +
91780 + NOTE: enabling this feature *may* open up a loophole in the
91781 + protection provided by non-executable pages that an attacker
91782 + could abuse. Therefore the best solution is to not have any
91783 + files on your system that would require this option. This can
91784 + be achieved by not using libc5 (which relies on the kernel
91785 + signal handler return code) and not using or rewriting programs
91786 + that make use of the nested function implementation of GCC.
91787 + Skilled users can just fix GCC itself so that it implements
91788 + nested function calls in a way that does not interfere with PaX.
91789 +
91790 +config PAX_EMUSIGRT
91791 + bool "Automatically emulate sigreturn trampolines"
91792 + depends on PAX_EMUTRAMP && PARISC
91793 + default y
91794 + help
91795 + Enabling this option will have the kernel automatically detect
91796 + and emulate signal return trampolines executing on the stack
91797 + that would otherwise lead to task termination.
91798 +
91799 + This solution is intended as a temporary one for users with
91800 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
91801 + Modula-3 runtime, etc) or executables linked to such, basically
91802 + everything that does not specify its own SA_RESTORER function in
91803 + normal executable memory like glibc 2.1+ does.
91804 +
91805 + On parisc you MUST enable this option, otherwise your system will
91806 + not even boot.
91807 +
91808 + NOTE: this feature cannot be disabled on a per executable basis
91809 + and since it *does* open up a loophole in the protection provided
91810 + by non-executable pages, the best solution is to not have any
91811 + files on your system that would require this option.
91812 +
91813 +config PAX_MPROTECT
91814 + bool "Restrict mprotect()"
91815 + default y if GRKERNSEC_CONFIG_AUTO
91816 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
91817 + help
91818 + Enabling this option will prevent programs from
91819 + - changing the executable status of memory pages that were
91820 + not originally created as executable,
91821 + - making read-only executable pages writable again,
91822 + - creating executable pages from anonymous memory,
91823 + - making read-only-after-relocations (RELRO) data pages writable again.
91824 +
91825 + You should say Y here to complete the protection provided by
91826 + the enforcement of non-executable pages.
91827 +
91828 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91829 + this feature on a per file basis.
91830 +
91831 +config PAX_MPROTECT_COMPAT
91832 + bool "Use legacy/compat protection demoting (read help)"
91833 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91834 + depends on PAX_MPROTECT
91835 + help
91836 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
91837 + by sending the proper error code to the application. For some broken
91838 + userland, this can cause problems with Python or other applications. The
91839 + current implementation however allows for applications like clamav to
91840 + detect if JIT compilation/execution is allowed and to fall back gracefully
91841 + to an interpreter-based mode if it does not. While we encourage everyone
91842 + to use the current implementation as-is and push upstream to fix broken
91843 + userland (note that the RWX logging option can assist with this), in some
91844 + environments this may not be possible. Having to disable MPROTECT
91845 + completely on certain binaries reduces the security benefit of PaX,
91846 + so this option is provided for those environments to revert to the old
91847 + behavior.
91848 +
91849 +config PAX_ELFRELOCS
91850 + bool "Allow ELF text relocations (read help)"
91851 + depends on PAX_MPROTECT
91852 + default n
91853 + help
91854 + Non-executable pages and mprotect() restrictions are effective
91855 + in preventing the introduction of new executable code into an
91856 + attacked task's address space. There remain only two venues
91857 + for this kind of attack: if the attacker can execute already
91858 + existing code in the attacked task then he can either have it
91859 + create and mmap() a file containing his code or have it mmap()
91860 + an already existing ELF library that does not have position
91861 + independent code in it and use mprotect() on it to make it
91862 + writable and copy his code there. While protecting against
91863 + the former approach is beyond PaX, the latter can be prevented
91864 + by having only PIC ELF libraries on one's system (which do not
91865 + need to relocate their code). If you are sure this is your case,
91866 + as is the case with all modern Linux distributions, then leave
91867 + this option disabled. You should say 'n' here.
91868 +
91869 +config PAX_ETEXECRELOCS
91870 + bool "Allow ELF ET_EXEC text relocations"
91871 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
91872 + select PAX_ELFRELOCS
91873 + default y
91874 + help
91875 + On some architectures there are incorrectly created applications
91876 + that require text relocations and would not work without enabling
91877 + this option. If you are an alpha, ia64 or parisc user, you should
91878 + enable this option and disable it once you have made sure that
91879 + none of your applications need it.
91880 +
91881 +config PAX_EMUPLT
91882 + bool "Automatically emulate ELF PLT"
91883 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
91884 + default y
91885 + help
91886 + Enabling this option will have the kernel automatically detect
91887 + and emulate the Procedure Linkage Table entries in ELF files.
91888 + On some architectures such entries are in writable memory, and
91889 + become non-executable leading to task termination. Therefore
91890 + it is mandatory that you enable this option on alpha, parisc,
91891 + sparc and sparc64, otherwise your system would not even boot.
91892 +
91893 + NOTE: this feature *does* open up a loophole in the protection
91894 + provided by the non-executable pages, therefore the proper
91895 + solution is to modify the toolchain to produce a PLT that does
91896 + not need to be writable.
91897 +
91898 +config PAX_DLRESOLVE
91899 + bool 'Emulate old glibc resolver stub'
91900 + depends on PAX_EMUPLT && SPARC
91901 + default n
91902 + help
91903 + This option is needed if userland has an old glibc (before 2.4)
91904 + that puts a 'save' instruction into the runtime generated resolver
91905 + stub that needs special emulation.
91906 +
91907 +config PAX_KERNEXEC
91908 + bool "Enforce non-executable kernel pages"
91909 + 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))
91910 + depends on ((X86 && (!X86_32 || X86_WP_WORKS_OK)) || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
91911 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
91912 + select PAX_KERNEXEC_PLUGIN if X86_64
91913 + help
91914 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
91915 + that is, enabling this option will make it harder to inject
91916 + and execute 'foreign' code in kernel memory itself.
91917 +
91918 +choice
91919 + prompt "Return Address Instrumentation Method"
91920 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
91921 + depends on PAX_KERNEXEC_PLUGIN
91922 + help
91923 + Select the method used to instrument function pointer dereferences.
91924 + Note that binary modules cannot be instrumented by this approach.
91925 +
91926 + Note that the implementation requires a gcc with plugin support,
91927 + i.e., gcc 4.5 or newer. You may need to install the supporting
91928 + headers explicitly in addition to the normal gcc package.
91929 +
91930 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
91931 + bool "bts"
91932 + help
91933 + This method is compatible with binary only modules but has
91934 + a higher runtime overhead.
91935 +
91936 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
91937 + bool "or"
91938 + depends on !PARAVIRT
91939 + help
91940 + This method is incompatible with binary only modules but has
91941 + a lower runtime overhead.
91942 +endchoice
91943 +
91944 +config PAX_KERNEXEC_PLUGIN_METHOD
91945 + string
91946 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
91947 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
91948 + default ""
91949 +
91950 +config PAX_KERNEXEC_MODULE_TEXT
91951 + int "Minimum amount of memory reserved for module code"
91952 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
91953 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91954 + depends on PAX_KERNEXEC && X86_32 && MODULES
91955 + help
91956 + Due to implementation details the kernel must reserve a fixed
91957 + amount of memory for module code at compile time that cannot be
91958 + changed at runtime. Here you can specify the minimum amount
91959 + in MB that will be reserved. Due to the same implementation
91960 + details this size will always be rounded up to the next 2/4 MB
91961 + boundary (depends on PAE) so the actually available memory for
91962 + module code will usually be more than this minimum.
91963 +
91964 + The default 4 MB should be enough for most users but if you have
91965 + an excessive number of modules (e.g., most distribution configs
91966 + compile many drivers as modules) or use huge modules such as
91967 + nvidia's kernel driver, you will need to adjust this amount.
91968 + A good rule of thumb is to look at your currently loaded kernel
91969 + modules and add up their sizes.
91970 +
91971 +endmenu
91972 +
91973 +menu "Address Space Layout Randomization"
91974 + depends on PAX
91975 +
91976 +config PAX_ASLR
91977 + bool "Address Space Layout Randomization"
91978 + default y if GRKERNSEC_CONFIG_AUTO
91979 + help
91980 + Many if not most exploit techniques rely on the knowledge of
91981 + certain addresses in the attacked program. The following options
91982 + will allow the kernel to apply a certain amount of randomization
91983 + to specific parts of the program thereby forcing an attacker to
91984 + guess them in most cases. Any failed guess will most likely crash
91985 + the attacked program which allows the kernel to detect such attempts
91986 + and react on them. PaX itself provides no reaction mechanisms,
91987 + instead it is strongly encouraged that you make use of Nergal's
91988 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
91989 + (http://www.grsecurity.net/) built-in crash detection features or
91990 + develop one yourself.
91991 +
91992 + By saying Y here you can choose to randomize the following areas:
91993 + - top of the task's kernel stack
91994 + - top of the task's userland stack
91995 + - base address for mmap() requests that do not specify one
91996 + (this includes all libraries)
91997 + - base address of the main executable
91998 +
91999 + It is strongly recommended to say Y here as address space layout
92000 + randomization has negligible impact on performance yet it provides
92001 + a very effective protection.
92002 +
92003 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92004 + this feature on a per file basis.
92005 +
92006 +config PAX_RANDKSTACK
92007 + bool "Randomize kernel stack base"
92008 + default y if GRKERNSEC_CONFIG_AUTO
92009 + depends on X86_TSC && X86
92010 + help
92011 + By saying Y here the kernel will randomize every task's kernel
92012 + stack on every system call. This will not only force an attacker
92013 + to guess it but also prevent him from making use of possible
92014 + leaked information about it.
92015 +
92016 + Since the kernel stack is a rather scarce resource, randomization
92017 + may cause unexpected stack overflows, therefore you should very
92018 + carefully test your system. Note that once enabled in the kernel
92019 + configuration, this feature cannot be disabled on a per file basis.
92020 +
92021 +config PAX_RANDUSTACK
92022 + bool "Randomize user stack base"
92023 + default y if GRKERNSEC_CONFIG_AUTO
92024 + depends on PAX_ASLR
92025 + help
92026 + By saying Y here the kernel will randomize every task's userland
92027 + stack. The randomization is done in two steps where the second
92028 + one may apply a big amount of shift to the top of the stack and
92029 + cause problems for programs that want to use lots of memory (more
92030 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92031 + For this reason the second step can be controlled by 'chpax' or
92032 + 'paxctl' on a per file basis.
92033 +
92034 +config PAX_RANDMMAP
92035 + bool "Randomize mmap() base"
92036 + default y if GRKERNSEC_CONFIG_AUTO
92037 + depends on PAX_ASLR
92038 + help
92039 + By saying Y here the kernel will use a randomized base address for
92040 + mmap() requests that do not specify one themselves. As a result
92041 + all dynamically loaded libraries will appear at random addresses
92042 + and therefore be harder to exploit by a technique where an attacker
92043 + attempts to execute library code for his purposes (e.g. spawn a
92044 + shell from an exploited program that is running at an elevated
92045 + privilege level).
92046 +
92047 + Furthermore, if a program is relinked as a dynamic ELF file, its
92048 + base address will be randomized as well, completing the full
92049 + randomization of the address space layout. Attacking such programs
92050 + becomes a guess game. You can find an example of doing this at
92051 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92052 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92053 +
92054 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92055 + feature on a per file basis.
92056 +
92057 +endmenu
92058 +
92059 +menu "Miscellaneous hardening features"
92060 +
92061 +config PAX_MEMORY_SANITIZE
92062 + bool "Sanitize all freed memory"
92063 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92064 + depends on !HIBERNATION
92065 + help
92066 + By saying Y here the kernel will erase memory pages as soon as they
92067 + are freed. This in turn reduces the lifetime of data stored in the
92068 + pages, making it less likely that sensitive information such as
92069 + passwords, cryptographic secrets, etc stay in memory for too long.
92070 +
92071 + This is especially useful for programs whose runtime is short, long
92072 + lived processes and the kernel itself benefit from this as long as
92073 + they operate on whole memory pages and ensure timely freeing of pages
92074 + that may hold sensitive information.
92075 +
92076 + The tradeoff is performance impact, on a single CPU system kernel
92077 + compilation sees a 3% slowdown, other systems and workloads may vary
92078 + and you are advised to test this feature on your expected workload
92079 + before deploying it.
92080 +
92081 + Note that this feature does not protect data stored in live pages,
92082 + e.g., process memory swapped to disk may stay there for a long time.
92083 +
92084 +config PAX_MEMORY_STACKLEAK
92085 + bool "Sanitize kernel stack"
92086 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92087 + depends on X86
92088 + help
92089 + By saying Y here the kernel will erase the kernel stack before it
92090 + returns from a system call. This in turn reduces the information
92091 + that a kernel stack leak bug can reveal.
92092 +
92093 + Note that such a bug can still leak information that was put on
92094 + the stack by the current system call (the one eventually triggering
92095 + the bug) but traces of earlier system calls on the kernel stack
92096 + cannot leak anymore.
92097 +
92098 + The tradeoff is performance impact: on a single CPU system kernel
92099 + compilation sees a 1% slowdown, other systems and workloads may vary
92100 + and you are advised to test this feature on your expected workload
92101 + before deploying it.
92102 +
92103 + Note that the full feature requires a gcc with plugin support,
92104 + i.e., gcc 4.5 or newer. You may need to install the supporting
92105 + headers explicitly in addition to the normal gcc package. Using
92106 + older gcc versions means that functions with large enough stack
92107 + frames may leave uninitialized memory behind that may be exposed
92108 + to a later syscall leaking the stack.
92109 +
92110 +config PAX_MEMORY_STRUCTLEAK
92111 + bool "Forcibly initialize local variables copied to userland"
92112 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92113 + help
92114 + By saying Y here the kernel will zero initialize some local
92115 + variables that are going to be copied to userland. This in
92116 + turn prevents unintended information leakage from the kernel
92117 + stack should later code forget to explicitly set all parts of
92118 + the copied variable.
92119 +
92120 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92121 + at a much smaller coverage.
92122 +
92123 + Note that the implementation requires a gcc with plugin support,
92124 + i.e., gcc 4.5 or newer. You may need to install the supporting
92125 + headers explicitly in addition to the normal gcc package.
92126 +
92127 +config PAX_MEMORY_UDEREF
92128 + bool "Prevent invalid userland pointer dereference"
92129 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92130 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92131 + select PAX_PER_CPU_PGD if X86_64
92132 + help
92133 + By saying Y here the kernel will be prevented from dereferencing
92134 + userland pointers in contexts where the kernel expects only kernel
92135 + pointers. This is both a useful runtime debugging feature and a
92136 + security measure that prevents exploiting a class of kernel bugs.
92137 +
92138 + The tradeoff is that some virtualization solutions may experience
92139 + a huge slowdown and therefore you should not enable this feature
92140 + for kernels meant to run in such environments. Whether a given VM
92141 + solution is affected or not is best determined by simply trying it
92142 + out, the performance impact will be obvious right on boot as this
92143 + mechanism engages from very early on. A good rule of thumb is that
92144 + VMs running on CPUs without hardware virtualization support (i.e.,
92145 + the majority of IA-32 CPUs) will likely experience the slowdown.
92146 +
92147 +config PAX_REFCOUNT
92148 + bool "Prevent various kernel object reference counter overflows"
92149 + default y if GRKERNSEC_CONFIG_AUTO
92150 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92151 + help
92152 + By saying Y here the kernel will detect and prevent overflowing
92153 + various (but not all) kinds of object reference counters. Such
92154 + overflows can normally occur due to bugs only and are often, if
92155 + not always, exploitable.
92156 +
92157 + The tradeoff is that data structures protected by an overflowed
92158 + refcount will never be freed and therefore will leak memory. Note
92159 + that this leak also happens even without this protection but in
92160 + that case the overflow can eventually trigger the freeing of the
92161 + data structure while it is still being used elsewhere, resulting
92162 + in the exploitable situation that this feature prevents.
92163 +
92164 + Since this has a negligible performance impact, you should enable
92165 + this feature.
92166 +
92167 +config PAX_CONSTIFY_PLUGIN
92168 + bool "Automatically constify eligible structures"
92169 + default y
92170 + depends on !UML
92171 + help
92172 + By saying Y here the compiler will automatically constify a class
92173 + of types that contain only function pointers. This reduces the
92174 + kernel's attack surface and also produces a better memory layout.
92175 +
92176 + Note that the implementation requires a gcc with plugin support,
92177 + i.e., gcc 4.5 or newer. You may need to install the supporting
92178 + headers explicitly in addition to the normal gcc package.
92179 +
92180 + Note that if some code really has to modify constified variables
92181 + then the source code will have to be patched to allow it. Examples
92182 + can be found in PaX itself (the no_const attribute) and for some
92183 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
92184 +
92185 +config PAX_USERCOPY
92186 + bool "Harden heap object copies between kernel and userland"
92187 + default y if GRKERNSEC_CONFIG_AUTO
92188 + depends on ARM || IA64 || PPC || SPARC || X86
92189 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
92190 + select PAX_USERCOPY_SLABS
92191 + help
92192 + By saying Y here the kernel will enforce the size of heap objects
92193 + when they are copied in either direction between the kernel and
92194 + userland, even if only a part of the heap object is copied.
92195 +
92196 + Specifically, this checking prevents information leaking from the
92197 + kernel heap during kernel to userland copies (if the kernel heap
92198 + object is otherwise fully initialized) and prevents kernel heap
92199 + overflows during userland to kernel copies.
92200 +
92201 + Note that the current implementation provides the strictest bounds
92202 + checks for the SLUB allocator.
92203 +
92204 + Enabling this option also enables per-slab cache protection against
92205 + data in a given cache being copied into/out of via userland
92206 + accessors. Though the whitelist of regions will be reduced over
92207 + time, it notably protects important data structures like task structs.
92208 +
92209 + If frame pointers are enabled on x86, this option will also restrict
92210 + copies into and out of the kernel stack to local variables within a
92211 + single frame.
92212 +
92213 + Since this has a negligible performance impact, you should enable
92214 + this feature.
92215 +
92216 +
92217 +config PAX_USERCOPY_DEBUG
92218 + bool
92219 + depends on X86 && PAX_USERCOPY
92220 + default n
92221 +
92222 +config PAX_SIZE_OVERFLOW
92223 + bool "Prevent various integer overflows in function size parameters"
92224 + default y if GRKERNSEC_CONFIG_AUTO
92225 + depends on X86
92226 + help
92227 + By saying Y here the kernel recomputes expressions of function
92228 + arguments marked by a size_overflow attribute with double integer
92229 + precision (DImode/TImode for 32/64 bit integer types).
92230 +
92231 + The recomputed argument is checked against TYPE_MAX and an event
92232 + is logged on overflow and the triggering process is killed.
92233 +
92234 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
92235 +
92236 + Note that the implementation requires a gcc with plugin support,
92237 + i.e., gcc 4.5 or newer. You may need to install the supporting
92238 + headers explicitly in addition to the normal gcc package.
92239 +
92240 +config PAX_LATENT_ENTROPY
92241 + bool "Generate some entropy during boot"
92242 + default y if GRKERNSEC_CONFIG_AUTO
92243 + help
92244 + By saying Y here the kernel will instrument early boot code to
92245 + extract some entropy from both original and artificially created
92246 + program state. This will help especially embedded systems where
92247 + there is little 'natural' source of entropy normally. The cost
92248 + is some slowdown of the boot process.
92249 +
92250 + When pax_extra_latent_entropy is passed on the kernel command line,
92251 + entropy will be extracted from up to the first 4GB of RAM while the
92252 + runtime memory allocator is being initialized. This costs even more
92253 + slowdown of the boot process.
92254 +
92255 + Note that the implementation requires a gcc with plugin support,
92256 + i.e., gcc 4.5 or newer. You may need to install the supporting
92257 + headers explicitly in addition to the normal gcc package.
92258 +
92259 + Note that entropy extracted this way is not cryptographically
92260 + secure!
92261 +
92262 +endmenu
92263 +
92264 +endmenu
92265 +
92266 +source grsecurity/Kconfig
92267 +
92268 +endmenu
92269 +
92270 +endmenu
92271 +
92272 source security/keys/Kconfig
92273
92274 config SECURITY_DMESG_RESTRICT
92275 @@ -103,7 +1041,7 @@ config INTEL_TXT
92276 config LSM_MMAP_MIN_ADDR
92277 int "Low address space for LSM to protect from user allocation"
92278 depends on SECURITY && SECURITY_SELINUX
92279 - default 32768 if ARM
92280 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92281 default 65536
92282 help
92283 This is the portion of low virtual memory which should be protected
92284 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
92285 index 8c2a7f6..b133ac9 100644
92286 --- a/security/apparmor/lsm.c
92287 +++ b/security/apparmor/lsm.c
92288 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
92289 return error;
92290 }
92291
92292 -static struct security_operations apparmor_ops = {
92293 +static struct security_operations apparmor_ops __read_only = {
92294 .name = "apparmor",
92295
92296 .ptrace_access_check = apparmor_ptrace_access_check,
92297 diff --git a/security/commoncap.c b/security/commoncap.c
92298 index 7ee08c7..8d1a9d6 100644
92299 --- a/security/commoncap.c
92300 +++ b/security/commoncap.c
92301 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
92302 return 0;
92303 }
92304
92305 +/* returns:
92306 + 1 for suid privilege
92307 + 2 for sgid privilege
92308 + 3 for fscap privilege
92309 +*/
92310 +int is_privileged_binary(const struct dentry *dentry)
92311 +{
92312 + struct cpu_vfs_cap_data capdata;
92313 + struct inode *inode = dentry->d_inode;
92314 +
92315 + if (!inode || S_ISDIR(inode->i_mode))
92316 + return 0;
92317 +
92318 + if (inode->i_mode & S_ISUID)
92319 + return 1;
92320 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
92321 + return 2;
92322 +
92323 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
92324 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
92325 + return 3;
92326 + }
92327 +
92328 + return 0;
92329 +}
92330 +
92331 /*
92332 * Attempt to get the on-exec apply capability sets for an executable file from
92333 * its xattrs and, if present, apply them to the proposed credentials being
92334 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
92335 const struct cred *cred = current_cred();
92336 kuid_t root_uid = make_kuid(cred->user_ns, 0);
92337
92338 + if (gr_acl_enable_at_secure())
92339 + return 1;
92340 +
92341 if (!uid_eq(cred->uid, root_uid)) {
92342 if (bprm->cap_effective)
92343 return 1;
92344 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
92345 index 079a85d..12e93f8 100644
92346 --- a/security/integrity/ima/ima.h
92347 +++ b/security/integrity/ima/ima.h
92348 @@ -96,8 +96,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92349 extern spinlock_t ima_queue_lock;
92350
92351 struct ima_h_table {
92352 - atomic_long_t len; /* number of stored measurements in the list */
92353 - atomic_long_t violations;
92354 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
92355 + atomic_long_unchecked_t violations;
92356 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
92357 };
92358 extern struct ima_h_table ima_htable;
92359 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
92360 index 0cea3db..2f0ef77 100644
92361 --- a/security/integrity/ima/ima_api.c
92362 +++ b/security/integrity/ima/ima_api.c
92363 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92364 int result;
92365
92366 /* can overflow, only indicator */
92367 - atomic_long_inc(&ima_htable.violations);
92368 + atomic_long_inc_unchecked(&ima_htable.violations);
92369
92370 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
92371 if (!entry) {
92372 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
92373 index 38477c9..87a60c7 100644
92374 --- a/security/integrity/ima/ima_fs.c
92375 +++ b/security/integrity/ima/ima_fs.c
92376 @@ -28,12 +28,12 @@
92377 static int valid_policy = 1;
92378 #define TMPBUFLEN 12
92379 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
92380 - loff_t *ppos, atomic_long_t *val)
92381 + loff_t *ppos, atomic_long_unchecked_t *val)
92382 {
92383 char tmpbuf[TMPBUFLEN];
92384 ssize_t len;
92385
92386 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
92387 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
92388 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
92389 }
92390
92391 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
92392 index 55a6271..ad829c3 100644
92393 --- a/security/integrity/ima/ima_queue.c
92394 +++ b/security/integrity/ima/ima_queue.c
92395 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
92396 INIT_LIST_HEAD(&qe->later);
92397 list_add_tail_rcu(&qe->later, &ima_measurements);
92398
92399 - atomic_long_inc(&ima_htable.len);
92400 + atomic_long_inc_unchecked(&ima_htable.len);
92401 key = ima_hash_key(entry->digest);
92402 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
92403 return 0;
92404 diff --git a/security/keys/compat.c b/security/keys/compat.c
92405 index d65fa7f..cbfe366 100644
92406 --- a/security/keys/compat.c
92407 +++ b/security/keys/compat.c
92408 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
92409 if (ret == 0)
92410 goto no_payload_free;
92411
92412 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92413 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92414 err:
92415 if (iov != iovstack)
92416 kfree(iov);
92417 diff --git a/security/keys/key.c b/security/keys/key.c
92418 index 8fb7c7b..ba3610d 100644
92419 --- a/security/keys/key.c
92420 +++ b/security/keys/key.c
92421 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
92422
92423 atomic_set(&key->usage, 1);
92424 init_rwsem(&key->sem);
92425 - lockdep_set_class(&key->sem, &type->lock_class);
92426 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
92427 key->type = type;
92428 key->user = user;
92429 key->quotalen = quotalen;
92430 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
92431 struct key_type *p;
92432 int ret;
92433
92434 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
92435 + pax_open_kernel();
92436 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
92437 + pax_close_kernel();
92438
92439 ret = -EEXIST;
92440 down_write(&key_types_sem);
92441 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
92442 }
92443
92444 /* store the type */
92445 - list_add(&ktype->link, &key_types_list);
92446 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
92447
92448 pr_notice("Key type %s registered\n", ktype->name);
92449 ret = 0;
92450 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
92451 void unregister_key_type(struct key_type *ktype)
92452 {
92453 down_write(&key_types_sem);
92454 - list_del_init(&ktype->link);
92455 + pax_list_del_init((struct list_head *)&ktype->link);
92456 downgrade_write(&key_types_sem);
92457 key_gc_keytype(ktype);
92458 pr_notice("Key type %s unregistered\n", ktype->name);
92459 @@ -1084,10 +1086,10 @@ void __init key_init(void)
92460 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
92461
92462 /* add the special key types */
92463 - list_add_tail(&key_type_keyring.link, &key_types_list);
92464 - list_add_tail(&key_type_dead.link, &key_types_list);
92465 - list_add_tail(&key_type_user.link, &key_types_list);
92466 - list_add_tail(&key_type_logon.link, &key_types_list);
92467 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
92468 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
92469 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
92470 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
92471
92472 /* record the root user tracking */
92473 rb_link_node(&root_key_user.node,
92474 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
92475 index 4b5c948..2054dc1 100644
92476 --- a/security/keys/keyctl.c
92477 +++ b/security/keys/keyctl.c
92478 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
92479 /*
92480 * Copy the iovec data from userspace
92481 */
92482 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92483 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
92484 unsigned ioc)
92485 {
92486 for (; ioc > 0; ioc--) {
92487 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92488 * If successful, 0 will be returned.
92489 */
92490 long keyctl_instantiate_key_common(key_serial_t id,
92491 - const struct iovec *payload_iov,
92492 + const struct iovec __user *payload_iov,
92493 unsigned ioc,
92494 size_t plen,
92495 key_serial_t ringid)
92496 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
92497 [0].iov_len = plen
92498 };
92499
92500 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
92501 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
92502 }
92503
92504 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
92505 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
92506 if (ret == 0)
92507 goto no_payload_free;
92508
92509 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92510 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92511 err:
92512 if (iov != iovstack)
92513 kfree(iov);
92514 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
92515 index 6ece7f2..ecdb55c 100644
92516 --- a/security/keys/keyring.c
92517 +++ b/security/keys/keyring.c
92518 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
92519 ret = -EFAULT;
92520
92521 for (loop = 0; loop < klist->nkeys; loop++) {
92522 + key_serial_t serial;
92523 key = rcu_deref_link_locked(klist, loop,
92524 keyring);
92525 + serial = key->serial;
92526
92527 tmp = sizeof(key_serial_t);
92528 if (tmp > buflen)
92529 tmp = buflen;
92530
92531 - if (copy_to_user(buffer,
92532 - &key->serial,
92533 - tmp) != 0)
92534 + if (copy_to_user(buffer, &serial, tmp))
92535 goto error;
92536
92537 buflen -= tmp;
92538 diff --git a/security/min_addr.c b/security/min_addr.c
92539 index f728728..6457a0c 100644
92540 --- a/security/min_addr.c
92541 +++ b/security/min_addr.c
92542 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
92543 */
92544 static void update_mmap_min_addr(void)
92545 {
92546 +#ifndef SPARC
92547 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
92548 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
92549 mmap_min_addr = dac_mmap_min_addr;
92550 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
92551 #else
92552 mmap_min_addr = dac_mmap_min_addr;
92553 #endif
92554 +#endif
92555 }
92556
92557 /*
92558 diff --git a/security/security.c b/security/security.c
92559 index 7b88c6a..1e3ea8f 100644
92560 --- a/security/security.c
92561 +++ b/security/security.c
92562 @@ -20,6 +20,7 @@
92563 #include <linux/ima.h>
92564 #include <linux/evm.h>
92565 #include <linux/fsnotify.h>
92566 +#include <linux/mm.h>
92567 #include <linux/mman.h>
92568 #include <linux/mount.h>
92569 #include <linux/personality.h>
92570 @@ -32,8 +33,8 @@
92571 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
92572 CONFIG_DEFAULT_SECURITY;
92573
92574 -static struct security_operations *security_ops;
92575 -static struct security_operations default_security_ops = {
92576 +static struct security_operations *security_ops __read_only;
92577 +static struct security_operations default_security_ops __read_only = {
92578 .name = "default",
92579 };
92580
92581 @@ -74,7 +75,9 @@ int __init security_init(void)
92582
92583 void reset_security_ops(void)
92584 {
92585 + pax_open_kernel();
92586 security_ops = &default_security_ops;
92587 + pax_close_kernel();
92588 }
92589
92590 /* Save user chosen LSM */
92591 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
92592 index ef26e96..642fb78 100644
92593 --- a/security/selinux/hooks.c
92594 +++ b/security/selinux/hooks.c
92595 @@ -95,8 +95,6 @@
92596
92597 #define NUM_SEL_MNT_OPTS 5
92598
92599 -extern struct security_operations *security_ops;
92600 -
92601 /* SECMARK reference count */
92602 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
92603
92604 @@ -5501,7 +5499,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
92605
92606 #endif
92607
92608 -static struct security_operations selinux_ops = {
92609 +static struct security_operations selinux_ops __read_only = {
92610 .name = "selinux",
92611
92612 .ptrace_access_check = selinux_ptrace_access_check,
92613 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
92614 index 65f67cb..3f141ef 100644
92615 --- a/security/selinux/include/xfrm.h
92616 +++ b/security/selinux/include/xfrm.h
92617 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
92618
92619 static inline void selinux_xfrm_notify_policyload(void)
92620 {
92621 - atomic_inc(&flow_cache_genid);
92622 + atomic_inc_unchecked(&flow_cache_genid);
92623 rt_genid_bump(&init_net);
92624 }
92625 #else
92626 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
92627 index 38be92c..21f49ee 100644
92628 --- a/security/smack/smack_lsm.c
92629 +++ b/security/smack/smack_lsm.c
92630 @@ -3398,7 +3398,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
92631 return 0;
92632 }
92633
92634 -struct security_operations smack_ops = {
92635 +struct security_operations smack_ops __read_only = {
92636 .name = "smack",
92637
92638 .ptrace_access_check = smack_ptrace_access_check,
92639 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
92640 index 390c646..f2f8db3 100644
92641 --- a/security/tomoyo/mount.c
92642 +++ b/security/tomoyo/mount.c
92643 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
92644 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
92645 need_dev = -1; /* dev_name is a directory */
92646 } else {
92647 + if (!capable(CAP_SYS_ADMIN)) {
92648 + error = -EPERM;
92649 + goto out;
92650 + }
92651 fstype = get_fs_type(type);
92652 if (!fstype) {
92653 error = -ENODEV;
92654 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
92655 index a2ee362..5754f34 100644
92656 --- a/security/tomoyo/tomoyo.c
92657 +++ b/security/tomoyo/tomoyo.c
92658 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
92659 * tomoyo_security_ops is a "struct security_operations" which is used for
92660 * registering TOMOYO.
92661 */
92662 -static struct security_operations tomoyo_security_ops = {
92663 +static struct security_operations tomoyo_security_ops __read_only = {
92664 .name = "tomoyo",
92665 .cred_alloc_blank = tomoyo_cred_alloc_blank,
92666 .cred_prepare = tomoyo_cred_prepare,
92667 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
92668 index 20ef514..4182bed 100644
92669 --- a/security/yama/Kconfig
92670 +++ b/security/yama/Kconfig
92671 @@ -1,6 +1,6 @@
92672 config SECURITY_YAMA
92673 bool "Yama support"
92674 - depends on SECURITY
92675 + depends on SECURITY && !GRKERNSEC
92676 select SECURITYFS
92677 select SECURITY_PATH
92678 default n
92679 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
92680 index 23414b9..f8c115e 100644
92681 --- a/security/yama/yama_lsm.c
92682 +++ b/security/yama/yama_lsm.c
92683 @@ -347,10 +347,8 @@ int yama_ptrace_traceme(struct task_struct *parent)
92684 /* Only disallow PTRACE_TRACEME on more aggressive settings. */
92685 switch (ptrace_scope) {
92686 case YAMA_SCOPE_CAPABILITY:
92687 - rcu_read_lock();
92688 - if (!ns_capable(__task_cred(parent)->user_ns, CAP_SYS_PTRACE))
92689 + if (!has_ns_capability(parent, current_user_ns(), CAP_SYS_PTRACE))
92690 rc = -EPERM;
92691 - rcu_read_unlock();
92692 break;
92693 case YAMA_SCOPE_NO_ATTACH:
92694 rc = -EPERM;
92695 @@ -367,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
92696 }
92697
92698 #ifndef CONFIG_SECURITY_YAMA_STACKED
92699 -static struct security_operations yama_ops = {
92700 +static struct security_operations yama_ops __read_only = {
92701 .name = "yama",
92702
92703 .ptrace_access_check = yama_ptrace_access_check,
92704 @@ -378,28 +376,24 @@ static struct security_operations yama_ops = {
92705 #endif
92706
92707 #ifdef CONFIG_SYSCTL
92708 +static int zero __read_only;
92709 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
92710 +
92711 static int yama_dointvec_minmax(struct ctl_table *table, int write,
92712 void __user *buffer, size_t *lenp, loff_t *ppos)
92713 {
92714 - int rc;
92715 + ctl_table_no_const yama_table;
92716
92717 if (write && !capable(CAP_SYS_PTRACE))
92718 return -EPERM;
92719
92720 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
92721 - if (rc)
92722 - return rc;
92723 -
92724 + yama_table = *table;
92725 /* Lock the max value if it ever gets set. */
92726 - if (write && *(int *)table->data == *(int *)table->extra2)
92727 - table->extra1 = table->extra2;
92728 -
92729 - return rc;
92730 + if (ptrace_scope == max_scope)
92731 + yama_table.extra1 = &max_scope;
92732 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
92733 }
92734
92735 -static int zero;
92736 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
92737 -
92738 struct ctl_path yama_sysctl_path[] = {
92739 { .procname = "kernel", },
92740 { .procname = "yama", },
92741 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
92742 index 4cedc69..e59d8a3 100644
92743 --- a/sound/aoa/codecs/onyx.c
92744 +++ b/sound/aoa/codecs/onyx.c
92745 @@ -54,7 +54,7 @@ struct onyx {
92746 spdif_locked:1,
92747 analog_locked:1,
92748 original_mute:2;
92749 - int open_count;
92750 + local_t open_count;
92751 struct codec_info *codec_info;
92752
92753 /* mutex serializes concurrent access to the device
92754 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
92755 struct onyx *onyx = cii->codec_data;
92756
92757 mutex_lock(&onyx->mutex);
92758 - onyx->open_count++;
92759 + local_inc(&onyx->open_count);
92760 mutex_unlock(&onyx->mutex);
92761
92762 return 0;
92763 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
92764 struct onyx *onyx = cii->codec_data;
92765
92766 mutex_lock(&onyx->mutex);
92767 - onyx->open_count--;
92768 - if (!onyx->open_count)
92769 + if (local_dec_and_test(&onyx->open_count))
92770 onyx->spdif_locked = onyx->analog_locked = 0;
92771 mutex_unlock(&onyx->mutex);
92772
92773 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
92774 index ffd2025..df062c9 100644
92775 --- a/sound/aoa/codecs/onyx.h
92776 +++ b/sound/aoa/codecs/onyx.h
92777 @@ -11,6 +11,7 @@
92778 #include <linux/i2c.h>
92779 #include <asm/pmac_low_i2c.h>
92780 #include <asm/prom.h>
92781 +#include <asm/local.h>
92782
92783 /* PCM3052 register definitions */
92784
92785 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
92786 index 4c1cc51..16040040 100644
92787 --- a/sound/core/oss/pcm_oss.c
92788 +++ b/sound/core/oss/pcm_oss.c
92789 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
92790 if (in_kernel) {
92791 mm_segment_t fs;
92792 fs = snd_enter_user();
92793 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92794 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92795 snd_leave_user(fs);
92796 } else {
92797 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92798 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92799 }
92800 if (ret != -EPIPE && ret != -ESTRPIPE)
92801 break;
92802 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
92803 if (in_kernel) {
92804 mm_segment_t fs;
92805 fs = snd_enter_user();
92806 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92807 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92808 snd_leave_user(fs);
92809 } else {
92810 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92811 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92812 }
92813 if (ret == -EPIPE) {
92814 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
92815 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
92816 struct snd_pcm_plugin_channel *channels;
92817 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
92818 if (!in_kernel) {
92819 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
92820 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
92821 return -EFAULT;
92822 buf = runtime->oss.buffer;
92823 }
92824 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
92825 }
92826 } else {
92827 tmp = snd_pcm_oss_write2(substream,
92828 - (const char __force *)buf,
92829 + (const char __force_kernel *)buf,
92830 runtime->oss.period_bytes, 0);
92831 if (tmp <= 0)
92832 goto err;
92833 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
92834 struct snd_pcm_runtime *runtime = substream->runtime;
92835 snd_pcm_sframes_t frames, frames1;
92836 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
92837 - char __user *final_dst = (char __force __user *)buf;
92838 + char __user *final_dst = (char __force_user *)buf;
92839 if (runtime->oss.plugin_first) {
92840 struct snd_pcm_plugin_channel *channels;
92841 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
92842 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
92843 xfer += tmp;
92844 runtime->oss.buffer_used -= tmp;
92845 } else {
92846 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
92847 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
92848 runtime->oss.period_bytes, 0);
92849 if (tmp <= 0)
92850 goto err;
92851 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
92852 size1);
92853 size1 /= runtime->channels; /* frames */
92854 fs = snd_enter_user();
92855 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
92856 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
92857 snd_leave_user(fs);
92858 }
92859 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
92860 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
92861 index af49721..e85058e 100644
92862 --- a/sound/core/pcm_compat.c
92863 +++ b/sound/core/pcm_compat.c
92864 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
92865 int err;
92866
92867 fs = snd_enter_user();
92868 - err = snd_pcm_delay(substream, &delay);
92869 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
92870 snd_leave_user(fs);
92871 if (err < 0)
92872 return err;
92873 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
92874 index 09b4286..8620fac 100644
92875 --- a/sound/core/pcm_native.c
92876 +++ b/sound/core/pcm_native.c
92877 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
92878 switch (substream->stream) {
92879 case SNDRV_PCM_STREAM_PLAYBACK:
92880 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
92881 - (void __user *)arg);
92882 + (void __force_user *)arg);
92883 break;
92884 case SNDRV_PCM_STREAM_CAPTURE:
92885 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
92886 - (void __user *)arg);
92887 + (void __force_user *)arg);
92888 break;
92889 default:
92890 result = -EINVAL;
92891 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
92892 index 040c60e..989a19a 100644
92893 --- a/sound/core/seq/seq_device.c
92894 +++ b/sound/core/seq/seq_device.c
92895 @@ -64,7 +64,7 @@ struct ops_list {
92896 int argsize; /* argument size */
92897
92898 /* operators */
92899 - struct snd_seq_dev_ops ops;
92900 + struct snd_seq_dev_ops *ops;
92901
92902 /* registered devices */
92903 struct list_head dev_list; /* list of devices */
92904 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
92905
92906 mutex_lock(&ops->reg_mutex);
92907 /* copy driver operators */
92908 - ops->ops = *entry;
92909 + ops->ops = entry;
92910 ops->driver |= DRIVER_LOADED;
92911 ops->argsize = argsize;
92912
92913 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
92914 dev->name, ops->id, ops->argsize, dev->argsize);
92915 return -EINVAL;
92916 }
92917 - if (ops->ops.init_device(dev) >= 0) {
92918 + if (ops->ops->init_device(dev) >= 0) {
92919 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
92920 ops->num_init_devices++;
92921 } else {
92922 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
92923 dev->name, ops->id, ops->argsize, dev->argsize);
92924 return -EINVAL;
92925 }
92926 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
92927 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
92928 dev->status = SNDRV_SEQ_DEVICE_FREE;
92929 dev->driver_data = NULL;
92930 ops->num_init_devices--;
92931 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
92932 index 4e0dd22..7a1f32c 100644
92933 --- a/sound/drivers/mts64.c
92934 +++ b/sound/drivers/mts64.c
92935 @@ -29,6 +29,7 @@
92936 #include <sound/initval.h>
92937 #include <sound/rawmidi.h>
92938 #include <sound/control.h>
92939 +#include <asm/local.h>
92940
92941 #define CARD_NAME "Miditerminal 4140"
92942 #define DRIVER_NAME "MTS64"
92943 @@ -67,7 +68,7 @@ struct mts64 {
92944 struct pardevice *pardev;
92945 int pardev_claimed;
92946
92947 - int open_count;
92948 + local_t open_count;
92949 int current_midi_output_port;
92950 int current_midi_input_port;
92951 u8 mode[MTS64_NUM_INPUT_PORTS];
92952 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
92953 {
92954 struct mts64 *mts = substream->rmidi->private_data;
92955
92956 - if (mts->open_count == 0) {
92957 + if (local_read(&mts->open_count) == 0) {
92958 /* We don't need a spinlock here, because this is just called
92959 if the device has not been opened before.
92960 So there aren't any IRQs from the device */
92961 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
92962
92963 msleep(50);
92964 }
92965 - ++(mts->open_count);
92966 + local_inc(&mts->open_count);
92967
92968 return 0;
92969 }
92970 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
92971 struct mts64 *mts = substream->rmidi->private_data;
92972 unsigned long flags;
92973
92974 - --(mts->open_count);
92975 - if (mts->open_count == 0) {
92976 + if (local_dec_return(&mts->open_count) == 0) {
92977 /* We need the spinlock_irqsave here because we can still
92978 have IRQs at this point */
92979 spin_lock_irqsave(&mts->lock, flags);
92980 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
92981
92982 msleep(500);
92983
92984 - } else if (mts->open_count < 0)
92985 - mts->open_count = 0;
92986 + } else if (local_read(&mts->open_count) < 0)
92987 + local_set(&mts->open_count, 0);
92988
92989 return 0;
92990 }
92991 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
92992 index b953fb4..1999c01 100644
92993 --- a/sound/drivers/opl4/opl4_lib.c
92994 +++ b/sound/drivers/opl4/opl4_lib.c
92995 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
92996 MODULE_DESCRIPTION("OPL4 driver");
92997 MODULE_LICENSE("GPL");
92998
92999 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
93000 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
93001 {
93002 int timeout = 10;
93003 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
93004 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
93005 index 991018d..8984740 100644
93006 --- a/sound/drivers/portman2x4.c
93007 +++ b/sound/drivers/portman2x4.c
93008 @@ -48,6 +48,7 @@
93009 #include <sound/initval.h>
93010 #include <sound/rawmidi.h>
93011 #include <sound/control.h>
93012 +#include <asm/local.h>
93013
93014 #define CARD_NAME "Portman 2x4"
93015 #define DRIVER_NAME "portman"
93016 @@ -85,7 +86,7 @@ struct portman {
93017 struct pardevice *pardev;
93018 int pardev_claimed;
93019
93020 - int open_count;
93021 + local_t open_count;
93022 int mode[PORTMAN_NUM_INPUT_PORTS];
93023 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
93024 };
93025 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
93026 index ea995af..f1bfa37 100644
93027 --- a/sound/firewire/amdtp.c
93028 +++ b/sound/firewire/amdtp.c
93029 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
93030 ptr = s->pcm_buffer_pointer + data_blocks;
93031 if (ptr >= pcm->runtime->buffer_size)
93032 ptr -= pcm->runtime->buffer_size;
93033 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
93034 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
93035
93036 s->pcm_period_pointer += data_blocks;
93037 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
93038 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
93039 */
93040 void amdtp_out_stream_update(struct amdtp_out_stream *s)
93041 {
93042 - ACCESS_ONCE(s->source_node_id_field) =
93043 + ACCESS_ONCE_RW(s->source_node_id_field) =
93044 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
93045 }
93046 EXPORT_SYMBOL(amdtp_out_stream_update);
93047 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
93048 index b680c5e..061b7a0 100644
93049 --- a/sound/firewire/amdtp.h
93050 +++ b/sound/firewire/amdtp.h
93051 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
93052 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
93053 struct snd_pcm_substream *pcm)
93054 {
93055 - ACCESS_ONCE(s->pcm) = pcm;
93056 + ACCESS_ONCE_RW(s->pcm) = pcm;
93057 }
93058
93059 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
93060 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
93061 index d428ffe..751ef78 100644
93062 --- a/sound/firewire/isight.c
93063 +++ b/sound/firewire/isight.c
93064 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
93065 ptr += count;
93066 if (ptr >= runtime->buffer_size)
93067 ptr -= runtime->buffer_size;
93068 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
93069 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
93070
93071 isight->period_counter += count;
93072 if (isight->period_counter >= runtime->period_size) {
93073 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
93074 if (err < 0)
93075 return err;
93076
93077 - ACCESS_ONCE(isight->pcm_active) = true;
93078 + ACCESS_ONCE_RW(isight->pcm_active) = true;
93079
93080 return 0;
93081 }
93082 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
93083 {
93084 struct isight *isight = substream->private_data;
93085
93086 - ACCESS_ONCE(isight->pcm_active) = false;
93087 + ACCESS_ONCE_RW(isight->pcm_active) = false;
93088
93089 mutex_lock(&isight->mutex);
93090 isight_stop_streaming(isight);
93091 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
93092
93093 switch (cmd) {
93094 case SNDRV_PCM_TRIGGER_START:
93095 - ACCESS_ONCE(isight->pcm_running) = true;
93096 + ACCESS_ONCE_RW(isight->pcm_running) = true;
93097 break;
93098 case SNDRV_PCM_TRIGGER_STOP:
93099 - ACCESS_ONCE(isight->pcm_running) = false;
93100 + ACCESS_ONCE_RW(isight->pcm_running) = false;
93101 break;
93102 default:
93103 return -EINVAL;
93104 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
93105 index 844a555..985ab83 100644
93106 --- a/sound/firewire/scs1x.c
93107 +++ b/sound/firewire/scs1x.c
93108 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
93109 {
93110 struct scs *scs = stream->rmidi->private_data;
93111
93112 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
93113 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
93114 if (up) {
93115 scs->output_idle = false;
93116 tasklet_schedule(&scs->tasklet);
93117 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
93118 {
93119 struct scs *scs = stream->rmidi->private_data;
93120
93121 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
93122 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
93123 }
93124
93125 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
93126 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
93127
93128 snd_card_disconnect(scs->card);
93129
93130 - ACCESS_ONCE(scs->output) = NULL;
93131 - ACCESS_ONCE(scs->input) = NULL;
93132 + ACCESS_ONCE_RW(scs->output) = NULL;
93133 + ACCESS_ONCE_RW(scs->input) = NULL;
93134
93135 wait_event(scs->idle_wait, scs->output_idle);
93136
93137 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
93138 index 048439a..3be9f6f 100644
93139 --- a/sound/oss/sb_audio.c
93140 +++ b/sound/oss/sb_audio.c
93141 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
93142 buf16 = (signed short *)(localbuf + localoffs);
93143 while (c)
93144 {
93145 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93146 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93147 if (copy_from_user(lbuf8,
93148 userbuf+useroffs + p,
93149 locallen))
93150 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
93151 index 7d8803a..559f8d0 100644
93152 --- a/sound/oss/swarm_cs4297a.c
93153 +++ b/sound/oss/swarm_cs4297a.c
93154 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
93155 {
93156 struct cs4297a_state *s;
93157 u32 pwr, id;
93158 - mm_segment_t fs;
93159 int rval;
93160 #ifndef CONFIG_BCM_CS4297A_CSWARM
93161 u64 cfg;
93162 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
93163 if (!rval) {
93164 char *sb1250_duart_present;
93165
93166 +#if 0
93167 + mm_segment_t fs;
93168 fs = get_fs();
93169 set_fs(KERNEL_DS);
93170 -#if 0
93171 val = SOUND_MASK_LINE;
93172 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
93173 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
93174 val = initvol[i].vol;
93175 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
93176 }
93177 + set_fs(fs);
93178 // cs4297a_write_ac97(s, 0x18, 0x0808);
93179 #else
93180 // cs4297a_write_ac97(s, 0x5e, 0x180);
93181 cs4297a_write_ac97(s, 0x02, 0x0808);
93182 cs4297a_write_ac97(s, 0x18, 0x0808);
93183 #endif
93184 - set_fs(fs);
93185
93186 list_add(&s->list, &cs4297a_devs);
93187
93188 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
93189 index 4631a23..001ae57 100644
93190 --- a/sound/pci/ymfpci/ymfpci.h
93191 +++ b/sound/pci/ymfpci/ymfpci.h
93192 @@ -358,7 +358,7 @@ struct snd_ymfpci {
93193 spinlock_t reg_lock;
93194 spinlock_t voice_lock;
93195 wait_queue_head_t interrupt_sleep;
93196 - atomic_t interrupt_sleep_count;
93197 + atomic_unchecked_t interrupt_sleep_count;
93198 struct snd_info_entry *proc_entry;
93199 const struct firmware *dsp_microcode;
93200 const struct firmware *controller_microcode;
93201 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
93202 index 22056c5..25d3244 100644
93203 --- a/sound/pci/ymfpci/ymfpci_main.c
93204 +++ b/sound/pci/ymfpci/ymfpci_main.c
93205 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
93206 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
93207 break;
93208 }
93209 - if (atomic_read(&chip->interrupt_sleep_count)) {
93210 - atomic_set(&chip->interrupt_sleep_count, 0);
93211 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93212 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93213 wake_up(&chip->interrupt_sleep);
93214 }
93215 __end:
93216 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
93217 continue;
93218 init_waitqueue_entry(&wait, current);
93219 add_wait_queue(&chip->interrupt_sleep, &wait);
93220 - atomic_inc(&chip->interrupt_sleep_count);
93221 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
93222 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
93223 remove_wait_queue(&chip->interrupt_sleep, &wait);
93224 }
93225 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
93226 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
93227 spin_unlock(&chip->reg_lock);
93228
93229 - if (atomic_read(&chip->interrupt_sleep_count)) {
93230 - atomic_set(&chip->interrupt_sleep_count, 0);
93231 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93232 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93233 wake_up(&chip->interrupt_sleep);
93234 }
93235 }
93236 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
93237 spin_lock_init(&chip->reg_lock);
93238 spin_lock_init(&chip->voice_lock);
93239 init_waitqueue_head(&chip->interrupt_sleep);
93240 - atomic_set(&chip->interrupt_sleep_count, 0);
93241 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93242 chip->card = card;
93243 chip->pci = pci;
93244 chip->irq = -1;
93245 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
93246 new file mode 100644
93247 index 0000000..50f2f2f
93248 --- /dev/null
93249 +++ b/tools/gcc/.gitignore
93250 @@ -0,0 +1 @@
93251 +size_overflow_hash.h
93252 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
93253 new file mode 100644
93254 index 0000000..144dbee
93255 --- /dev/null
93256 +++ b/tools/gcc/Makefile
93257 @@ -0,0 +1,45 @@
93258 +#CC := gcc
93259 +#PLUGIN_SOURCE_FILES := pax_plugin.c
93260 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
93261 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
93262 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
93263 +
93264 +ifeq ($(PLUGINCC),$(HOSTCC))
93265 +HOSTLIBS := hostlibs
93266 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
93267 +else
93268 +HOSTLIBS := hostcxxlibs
93269 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
93270 +endif
93271 +
93272 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
93273 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
93274 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
93275 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
93276 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
93277 +$(HOSTLIBS)-y += colorize_plugin.so
93278 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
93279 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
93280 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
93281 +
93282 +always := $($(HOSTLIBS)-y)
93283 +
93284 +constify_plugin-objs := constify_plugin.o
93285 +stackleak_plugin-objs := stackleak_plugin.o
93286 +kallocstat_plugin-objs := kallocstat_plugin.o
93287 +kernexec_plugin-objs := kernexec_plugin.o
93288 +checker_plugin-objs := checker_plugin.o
93289 +colorize_plugin-objs := colorize_plugin.o
93290 +size_overflow_plugin-objs := size_overflow_plugin.o
93291 +latent_entropy_plugin-objs := latent_entropy_plugin.o
93292 +structleak_plugin-objs := structleak_plugin.o
93293 +
93294 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
93295 +
93296 +quiet_cmd_build_size_overflow_hash = GENHASH $@
93297 + cmd_build_size_overflow_hash = \
93298 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
93299 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
93300 + $(call if_changed,build_size_overflow_hash)
93301 +
93302 +targets += size_overflow_hash.h
93303 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
93304 new file mode 100644
93305 index 0000000..d41b5af
93306 --- /dev/null
93307 +++ b/tools/gcc/checker_plugin.c
93308 @@ -0,0 +1,171 @@
93309 +/*
93310 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
93311 + * Licensed under the GPL v2
93312 + *
93313 + * Note: the choice of the license means that the compilation process is
93314 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93315 + * but for the kernel it doesn't matter since it doesn't link against
93316 + * any of the gcc libraries
93317 + *
93318 + * gcc plugin to implement various sparse (source code checker) features
93319 + *
93320 + * TODO:
93321 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
93322 + *
93323 + * BUGS:
93324 + * - none known
93325 + */
93326 +#include "gcc-plugin.h"
93327 +#include "config.h"
93328 +#include "system.h"
93329 +#include "coretypes.h"
93330 +#include "tree.h"
93331 +#include "tree-pass.h"
93332 +#include "flags.h"
93333 +#include "intl.h"
93334 +#include "toplev.h"
93335 +#include "plugin.h"
93336 +//#include "expr.h" where are you...
93337 +#include "diagnostic.h"
93338 +#include "plugin-version.h"
93339 +#include "tm.h"
93340 +#include "function.h"
93341 +#include "basic-block.h"
93342 +#include "gimple.h"
93343 +#include "rtl.h"
93344 +#include "emit-rtl.h"
93345 +#include "tree-flow.h"
93346 +#include "target.h"
93347 +
93348 +extern void c_register_addr_space (const char *str, addr_space_t as);
93349 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
93350 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
93351 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
93352 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
93353 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
93354 +
93355 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93356 +extern rtx emit_move_insn(rtx x, rtx y);
93357 +
93358 +int plugin_is_GPL_compatible;
93359 +
93360 +static struct plugin_info checker_plugin_info = {
93361 + .version = "201111150100",
93362 +};
93363 +
93364 +#define ADDR_SPACE_KERNEL 0
93365 +#define ADDR_SPACE_FORCE_KERNEL 1
93366 +#define ADDR_SPACE_USER 2
93367 +#define ADDR_SPACE_FORCE_USER 3
93368 +#define ADDR_SPACE_IOMEM 0
93369 +#define ADDR_SPACE_FORCE_IOMEM 0
93370 +#define ADDR_SPACE_PERCPU 0
93371 +#define ADDR_SPACE_FORCE_PERCPU 0
93372 +#define ADDR_SPACE_RCU 0
93373 +#define ADDR_SPACE_FORCE_RCU 0
93374 +
93375 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
93376 +{
93377 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
93378 +}
93379 +
93380 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
93381 +{
93382 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
93383 +}
93384 +
93385 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
93386 +{
93387 + return default_addr_space_valid_pointer_mode(mode, as);
93388 +}
93389 +
93390 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
93391 +{
93392 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
93393 +}
93394 +
93395 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
93396 +{
93397 + return default_addr_space_legitimize_address(x, oldx, mode, as);
93398 +}
93399 +
93400 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
93401 +{
93402 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
93403 + return true;
93404 +
93405 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
93406 + return true;
93407 +
93408 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
93409 + return true;
93410 +
93411 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
93412 + return true;
93413 +
93414 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
93415 + return true;
93416 +
93417 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
93418 + return true;
93419 +
93420 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
93421 + return true;
93422 +
93423 + return subset == superset;
93424 +}
93425 +
93426 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
93427 +{
93428 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
93429 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
93430 +
93431 + return op;
93432 +}
93433 +
93434 +static void register_checker_address_spaces(void *event_data, void *data)
93435 +{
93436 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
93437 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
93438 + c_register_addr_space("__user", ADDR_SPACE_USER);
93439 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
93440 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
93441 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
93442 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
93443 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
93444 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
93445 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
93446 +
93447 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
93448 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
93449 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
93450 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
93451 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
93452 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
93453 + targetm.addr_space.convert = checker_addr_space_convert;
93454 +}
93455 +
93456 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93457 +{
93458 + const char * const plugin_name = plugin_info->base_name;
93459 + const int argc = plugin_info->argc;
93460 + const struct plugin_argument * const argv = plugin_info->argv;
93461 + int i;
93462 +
93463 + if (!plugin_default_version_check(version, &gcc_version)) {
93464 + error(G_("incompatible gcc/plugin versions"));
93465 + return 1;
93466 + }
93467 +
93468 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
93469 +
93470 + for (i = 0; i < argc; ++i)
93471 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93472 +
93473 + if (TARGET_64BIT == 0)
93474 + return 0;
93475 +
93476 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
93477 +
93478 + return 0;
93479 +}
93480 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
93481 new file mode 100644
93482 index 0000000..414fe5e
93483 --- /dev/null
93484 +++ b/tools/gcc/colorize_plugin.c
93485 @@ -0,0 +1,151 @@
93486 +/*
93487 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
93488 + * Licensed under the GPL v2
93489 + *
93490 + * Note: the choice of the license means that the compilation process is
93491 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93492 + * but for the kernel it doesn't matter since it doesn't link against
93493 + * any of the gcc libraries
93494 + *
93495 + * gcc plugin to colorize diagnostic output
93496 + *
93497 + */
93498 +
93499 +#include "gcc-plugin.h"
93500 +#include "config.h"
93501 +#include "system.h"
93502 +#include "coretypes.h"
93503 +#include "tree.h"
93504 +#include "tree-pass.h"
93505 +#include "flags.h"
93506 +#include "intl.h"
93507 +#include "toplev.h"
93508 +#include "plugin.h"
93509 +#include "diagnostic.h"
93510 +#include "plugin-version.h"
93511 +#include "tm.h"
93512 +
93513 +int plugin_is_GPL_compatible;
93514 +
93515 +static struct plugin_info colorize_plugin_info = {
93516 + .version = "201302112000",
93517 + .help = NULL,
93518 +};
93519 +
93520 +#define GREEN "\033[32m\033[2m"
93521 +#define LIGHTGREEN "\033[32m\033[1m"
93522 +#define YELLOW "\033[33m\033[2m"
93523 +#define LIGHTYELLOW "\033[33m\033[1m"
93524 +#define RED "\033[31m\033[2m"
93525 +#define LIGHTRED "\033[31m\033[1m"
93526 +#define BLUE "\033[34m\033[2m"
93527 +#define LIGHTBLUE "\033[34m\033[1m"
93528 +#define BRIGHT "\033[m\033[1m"
93529 +#define NORMAL "\033[m"
93530 +
93531 +static diagnostic_starter_fn old_starter;
93532 +static diagnostic_finalizer_fn old_finalizer;
93533 +
93534 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93535 +{
93536 + const char *color;
93537 + char *newprefix;
93538 +
93539 + switch (diagnostic->kind) {
93540 + case DK_NOTE:
93541 + color = LIGHTBLUE;
93542 + break;
93543 +
93544 + case DK_PEDWARN:
93545 + case DK_WARNING:
93546 + color = LIGHTYELLOW;
93547 + break;
93548 +
93549 + case DK_ERROR:
93550 + case DK_FATAL:
93551 + case DK_ICE:
93552 + case DK_PERMERROR:
93553 + case DK_SORRY:
93554 + color = LIGHTRED;
93555 + break;
93556 +
93557 + default:
93558 + color = NORMAL;
93559 + }
93560 +
93561 + old_starter(context, diagnostic);
93562 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
93563 + return;
93564 + pp_destroy_prefix(context->printer);
93565 + pp_set_prefix(context->printer, newprefix);
93566 +}
93567 +
93568 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93569 +{
93570 + old_finalizer(context, diagnostic);
93571 +}
93572 +
93573 +static void colorize_arm(void)
93574 +{
93575 + old_starter = diagnostic_starter(global_dc);
93576 + old_finalizer = diagnostic_finalizer(global_dc);
93577 +
93578 + diagnostic_starter(global_dc) = start_colorize;
93579 + diagnostic_finalizer(global_dc) = finalize_colorize;
93580 +}
93581 +
93582 +static unsigned int execute_colorize_rearm(void)
93583 +{
93584 + if (diagnostic_starter(global_dc) == start_colorize)
93585 + return 0;
93586 +
93587 + colorize_arm();
93588 + return 0;
93589 +}
93590 +
93591 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
93592 + .pass = {
93593 + .type = SIMPLE_IPA_PASS,
93594 + .name = "colorize_rearm",
93595 +#if BUILDING_GCC_VERSION >= 4008
93596 + .optinfo_flags = OPTGROUP_NONE,
93597 +#endif
93598 + .gate = NULL,
93599 + .execute = execute_colorize_rearm,
93600 + .sub = NULL,
93601 + .next = NULL,
93602 + .static_pass_number = 0,
93603 + .tv_id = TV_NONE,
93604 + .properties_required = 0,
93605 + .properties_provided = 0,
93606 + .properties_destroyed = 0,
93607 + .todo_flags_start = 0,
93608 + .todo_flags_finish = 0
93609 + }
93610 +};
93611 +
93612 +static void colorize_start_unit(void *gcc_data, void *user_data)
93613 +{
93614 + colorize_arm();
93615 +}
93616 +
93617 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93618 +{
93619 + const char * const plugin_name = plugin_info->base_name;
93620 + struct register_pass_info colorize_rearm_pass_info = {
93621 + .pass = &pass_ipa_colorize_rearm.pass,
93622 + .reference_pass_name = "*free_lang_data",
93623 + .ref_pass_instance_number = 1,
93624 + .pos_op = PASS_POS_INSERT_AFTER
93625 + };
93626 +
93627 + if (!plugin_default_version_check(version, &gcc_version)) {
93628 + error(G_("incompatible gcc/plugin versions"));
93629 + return 1;
93630 + }
93631 +
93632 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
93633 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
93634 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
93635 + return 0;
93636 +}
93637 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
93638 new file mode 100644
93639 index 0000000..bee0acb
93640 --- /dev/null
93641 +++ b/tools/gcc/constify_plugin.c
93642 @@ -0,0 +1,518 @@
93643 +/*
93644 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
93645 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
93646 + * Licensed under the GPL v2, or (at your option) v3
93647 + *
93648 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
93649 + *
93650 + * Homepage:
93651 + * http://www.grsecurity.net/~ephox/const_plugin/
93652 + *
93653 + * Usage:
93654 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
93655 + * $ gcc -fplugin=constify_plugin.so test.c -O2
93656 + */
93657 +
93658 +#include "gcc-plugin.h"
93659 +#include "config.h"
93660 +#include "system.h"
93661 +#include "coretypes.h"
93662 +#include "tree.h"
93663 +#include "tree-pass.h"
93664 +#include "flags.h"
93665 +#include "intl.h"
93666 +#include "toplev.h"
93667 +#include "plugin.h"
93668 +#include "diagnostic.h"
93669 +#include "plugin-version.h"
93670 +#include "tm.h"
93671 +#include "function.h"
93672 +#include "basic-block.h"
93673 +#include "gimple.h"
93674 +#include "rtl.h"
93675 +#include "emit-rtl.h"
93676 +#include "tree-flow.h"
93677 +#include "target.h"
93678 +#include "langhooks.h"
93679 +
93680 +// should come from c-tree.h if only it were installed for gcc 4.5...
93681 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
93682 +
93683 +// unused type flag in all versions 4.5-4.8
93684 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
93685 +
93686 +int plugin_is_GPL_compatible;
93687 +
93688 +static struct plugin_info const_plugin_info = {
93689 + .version = "201303270300",
93690 + .help = "no-constify\tturn off constification\n",
93691 +};
93692 +
93693 +typedef struct {
93694 + bool has_fptr_field;
93695 + bool has_writable_field;
93696 + bool has_do_const_field;
93697 + bool has_no_const_field;
93698 +} constify_info;
93699 +
93700 +static const_tree get_field_type(const_tree field)
93701 +{
93702 + return strip_array_types(TREE_TYPE(field));
93703 +}
93704 +
93705 +static bool is_fptr(const_tree field)
93706 +{
93707 + const_tree ptr = get_field_type(field);
93708 +
93709 + if (TREE_CODE(ptr) != POINTER_TYPE)
93710 + return false;
93711 +
93712 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
93713 +}
93714 +
93715 +/*
93716 + * determine whether the given structure type meets the requirements for automatic constification,
93717 + * including the constification attributes on nested structure types
93718 + */
93719 +static void constifiable(const_tree node, constify_info *cinfo)
93720 +{
93721 + const_tree field;
93722 +
93723 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93724 +
93725 + // e.g., pointer to structure fields while still constructing the structure type
93726 + if (TYPE_FIELDS(node) == NULL_TREE)
93727 + return;
93728 +
93729 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
93730 + const_tree type = get_field_type(field);
93731 + enum tree_code code = TREE_CODE(type);
93732 +
93733 + if (node == type)
93734 + continue;
93735 +
93736 + if (is_fptr(field))
93737 + cinfo->has_fptr_field = true;
93738 + else if (!TREE_READONLY(field))
93739 + cinfo->has_writable_field = true;
93740 +
93741 + if (code == RECORD_TYPE || code == UNION_TYPE) {
93742 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93743 + cinfo->has_do_const_field = true;
93744 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
93745 + cinfo->has_no_const_field = true;
93746 + else
93747 + constifiable(type, cinfo);
93748 + }
93749 + }
93750 +}
93751 +
93752 +static bool constified(const_tree node)
93753 +{
93754 + constify_info cinfo = {
93755 + .has_fptr_field = false,
93756 + .has_writable_field = false,
93757 + .has_do_const_field = false,
93758 + .has_no_const_field = false
93759 + };
93760 +
93761 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93762 +
93763 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
93764 + gcc_assert(!TYPE_READONLY(node));
93765 + return false;
93766 + }
93767 +
93768 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
93769 + gcc_assert(TYPE_READONLY(node));
93770 + return true;
93771 + }
93772 +
93773 + constifiable(node, &cinfo);
93774 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
93775 + return false;
93776 +
93777 + return TYPE_READONLY(node);
93778 +}
93779 +
93780 +static void deconstify_tree(tree node);
93781 +
93782 +static void deconstify_type(tree type)
93783 +{
93784 + tree field;
93785 +
93786 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
93787 +
93788 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
93789 + const_tree fieldtype = get_field_type(field);
93790 +
93791 + // special case handling of simple ptr-to-same-array-type members
93792 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
93793 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
93794 +
93795 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
93796 + continue;
93797 + if (TREE_TYPE(TREE_TYPE(field)) == type)
93798 + continue;
93799 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
93800 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
93801 + TREE_TYPE(TREE_TYPE(field)) = type;
93802 + }
93803 + continue;
93804 + }
93805 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
93806 + continue;
93807 + if (!constified(fieldtype))
93808 + continue;
93809 +
93810 + deconstify_tree(field);
93811 + TREE_READONLY(field) = 0;
93812 + }
93813 + TYPE_READONLY(type) = 0;
93814 + C_TYPE_FIELDS_READONLY(type) = 0;
93815 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93816 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
93817 +}
93818 +
93819 +static void deconstify_tree(tree node)
93820 +{
93821 + tree old_type, new_type, field;
93822 +
93823 + old_type = TREE_TYPE(node);
93824 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
93825 + node = TREE_TYPE(node) = copy_node(old_type);
93826 + old_type = TREE_TYPE(old_type);
93827 + }
93828 +
93829 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
93830 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
93831 +
93832 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
93833 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
93834 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
93835 + DECL_FIELD_CONTEXT(field) = new_type;
93836 +
93837 + deconstify_type(new_type);
93838 +
93839 + TREE_TYPE(node) = new_type;
93840 +}
93841 +
93842 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93843 +{
93844 + tree type;
93845 + constify_info cinfo = {
93846 + .has_fptr_field = false,
93847 + .has_writable_field = false,
93848 + .has_do_const_field = false,
93849 + .has_no_const_field = false
93850 + };
93851 +
93852 + *no_add_attrs = true;
93853 + if (TREE_CODE(*node) == FUNCTION_DECL) {
93854 + error("%qE attribute does not apply to functions", name);
93855 + return NULL_TREE;
93856 + }
93857 +
93858 + if (TREE_CODE(*node) == PARM_DECL) {
93859 + error("%qE attribute does not apply to function parameters", name);
93860 + return NULL_TREE;
93861 + }
93862 +
93863 + if (TREE_CODE(*node) == VAR_DECL) {
93864 + error("%qE attribute does not apply to variables", name);
93865 + return NULL_TREE;
93866 + }
93867 +
93868 + if (TYPE_P(*node)) {
93869 + *no_add_attrs = false;
93870 + type = *node;
93871 + } else {
93872 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
93873 + type = TREE_TYPE(*node);
93874 + }
93875 +
93876 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
93877 + error("%qE attribute applies to struct and union types only", name);
93878 + return NULL_TREE;
93879 + }
93880 +
93881 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
93882 + error("%qE attribute is already applied to the type", name);
93883 + return NULL_TREE;
93884 + }
93885 +
93886 + if (TYPE_P(*node)) {
93887 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93888 + error("%qE attribute is incompatible with 'do_const'", name);
93889 + return NULL_TREE;
93890 + }
93891 +
93892 + constifiable(type, &cinfo);
93893 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
93894 + deconstify_tree(*node);
93895 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
93896 + return NULL_TREE;
93897 + }
93898 +
93899 + error("%qE attribute used on type that is not constified", name);
93900 + return NULL_TREE;
93901 +}
93902 +
93903 +static void constify_type(tree type)
93904 +{
93905 + TYPE_READONLY(type) = 1;
93906 + C_TYPE_FIELDS_READONLY(type) = 1;
93907 + TYPE_CONSTIFY_VISITED(type) = 1;
93908 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
93909 +}
93910 +
93911 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93912 +{
93913 + *no_add_attrs = true;
93914 + if (!TYPE_P(*node)) {
93915 + error("%qE attribute applies to types only", name);
93916 + return NULL_TREE;
93917 + }
93918 +
93919 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
93920 + error("%qE attribute applies to struct and union types only", name);
93921 + return NULL_TREE;
93922 + }
93923 +
93924 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
93925 + error("%qE attribute is already applied to the type", name);
93926 + return NULL_TREE;
93927 + }
93928 +
93929 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
93930 + error("%qE attribute is incompatible with 'no_const'", name);
93931 + return NULL_TREE;
93932 + }
93933 +
93934 + *no_add_attrs = false;
93935 + return NULL_TREE;
93936 +}
93937 +
93938 +static struct attribute_spec no_const_attr = {
93939 + .name = "no_const",
93940 + .min_length = 0,
93941 + .max_length = 0,
93942 + .decl_required = false,
93943 + .type_required = false,
93944 + .function_type_required = false,
93945 + .handler = handle_no_const_attribute,
93946 +#if BUILDING_GCC_VERSION >= 4007
93947 + .affects_type_identity = true
93948 +#endif
93949 +};
93950 +
93951 +static struct attribute_spec do_const_attr = {
93952 + .name = "do_const",
93953 + .min_length = 0,
93954 + .max_length = 0,
93955 + .decl_required = false,
93956 + .type_required = false,
93957 + .function_type_required = false,
93958 + .handler = handle_do_const_attribute,
93959 +#if BUILDING_GCC_VERSION >= 4007
93960 + .affects_type_identity = true
93961 +#endif
93962 +};
93963 +
93964 +static void register_attributes(void *event_data, void *data)
93965 +{
93966 + register_attribute(&no_const_attr);
93967 + register_attribute(&do_const_attr);
93968 +}
93969 +
93970 +static void finish_type(void *event_data, void *data)
93971 +{
93972 + tree type = (tree)event_data;
93973 + constify_info cinfo = {
93974 + .has_fptr_field = false,
93975 + .has_writable_field = false,
93976 + .has_do_const_field = false,
93977 + .has_no_const_field = false
93978 + };
93979 +
93980 + if (type == NULL_TREE || type == error_mark_node)
93981 + return;
93982 +
93983 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
93984 + return;
93985 +
93986 + constifiable(type, &cinfo);
93987 +
93988 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
93989 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93990 + return;
93991 + if (cinfo.has_writable_field)
93992 + return;
93993 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
93994 + return;
93995 + }
93996 +
93997 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
93998 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
93999 + deconstify_type(type);
94000 + TYPE_CONSTIFY_VISITED(type) = 1;
94001 + } else
94002 + error("'no_const' attribute used on type that is not constified");
94003 + return;
94004 + }
94005 +
94006 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94007 + constify_type(type);
94008 + return;
94009 + }
94010 +
94011 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
94012 + constify_type(type);
94013 + return;
94014 + }
94015 +
94016 + deconstify_type(type);
94017 + TYPE_CONSTIFY_VISITED(type) = 1;
94018 +}
94019 +
94020 +static unsigned int check_local_variables(void)
94021 +{
94022 + unsigned int ret = 0;
94023 + tree var;
94024 +
94025 +#if BUILDING_GCC_VERSION == 4005
94026 + tree vars;
94027 +#else
94028 + unsigned int i;
94029 +#endif
94030 +
94031 +#if BUILDING_GCC_VERSION == 4005
94032 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
94033 + var = TREE_VALUE(vars);
94034 +#else
94035 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
94036 +#endif
94037 + tree type = TREE_TYPE(var);
94038 +
94039 + gcc_assert(DECL_P(var));
94040 + if (is_global_var(var))
94041 + continue;
94042 +
94043 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94044 + continue;
94045 +
94046 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94047 + continue;
94048 +
94049 + if (!TYPE_CONSTIFY_VISITED(type))
94050 + continue;
94051 +
94052 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
94053 + ret = 1;
94054 + }
94055 + return ret;
94056 +}
94057 +
94058 +static struct gimple_opt_pass pass_local_variable = {
94059 + {
94060 + .type = GIMPLE_PASS,
94061 + .name = "check_local_variables",
94062 +#if BUILDING_GCC_VERSION >= 4008
94063 + .optinfo_flags = OPTGROUP_NONE,
94064 +#endif
94065 + .gate = NULL,
94066 + .execute = check_local_variables,
94067 + .sub = NULL,
94068 + .next = NULL,
94069 + .static_pass_number = 0,
94070 + .tv_id = TV_NONE,
94071 + .properties_required = 0,
94072 + .properties_provided = 0,
94073 + .properties_destroyed = 0,
94074 + .todo_flags_start = 0,
94075 + .todo_flags_finish = 0
94076 + }
94077 +};
94078 +
94079 +static struct {
94080 + const char *name;
94081 + const char *asm_op;
94082 +} sections[] = {
94083 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
94084 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
94085 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
94086 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
94087 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
94088 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
94089 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
94090 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
94091 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
94092 +};
94093 +
94094 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
94095 +
94096 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
94097 +{
94098 + size_t i;
94099 +
94100 + for (i = 0; i < ARRAY_SIZE(sections); i++)
94101 + if (!strcmp(sections[i].name, name))
94102 + return 0;
94103 + return old_section_type_flags(decl, name, reloc);
94104 +}
94105 +
94106 +static void constify_start_unit(void *gcc_data, void *user_data)
94107 +{
94108 +// size_t i;
94109 +
94110 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
94111 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
94112 +// sections[i].section = get_section(sections[i].name, 0, NULL);
94113 +
94114 + old_section_type_flags = targetm.section_type_flags;
94115 + targetm.section_type_flags = constify_section_type_flags;
94116 +}
94117 +
94118 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94119 +{
94120 + const char * const plugin_name = plugin_info->base_name;
94121 + const int argc = plugin_info->argc;
94122 + const struct plugin_argument * const argv = plugin_info->argv;
94123 + int i;
94124 + bool constify = true;
94125 +
94126 + struct register_pass_info local_variable_pass_info = {
94127 + .pass = &pass_local_variable.pass,
94128 + .reference_pass_name = "ssa",
94129 + .ref_pass_instance_number = 1,
94130 + .pos_op = PASS_POS_INSERT_BEFORE
94131 + };
94132 +
94133 + if (!plugin_default_version_check(version, &gcc_version)) {
94134 + error(G_("incompatible gcc/plugin versions"));
94135 + return 1;
94136 + }
94137 +
94138 + for (i = 0; i < argc; ++i) {
94139 + if (!(strcmp(argv[i].key, "no-constify"))) {
94140 + constify = false;
94141 + continue;
94142 + }
94143 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94144 + }
94145 +
94146 + if (strcmp(lang_hooks.name, "GNU C")) {
94147 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
94148 + constify = false;
94149 + }
94150 +
94151 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
94152 + if (constify) {
94153 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
94154 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
94155 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
94156 + }
94157 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94158 +
94159 + return 0;
94160 +}
94161 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
94162 new file mode 100644
94163 index 0000000..e518932
94164 --- /dev/null
94165 +++ b/tools/gcc/generate_size_overflow_hash.sh
94166 @@ -0,0 +1,94 @@
94167 +#!/bin/bash
94168 +
94169 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
94170 +
94171 +header1="size_overflow_hash.h"
94172 +database="size_overflow_hash.data"
94173 +n=65536
94174 +
94175 +usage() {
94176 +cat <<EOF
94177 +usage: $0 options
94178 +OPTIONS:
94179 + -h|--help help
94180 + -o header file
94181 + -d database file
94182 + -n hash array size
94183 +EOF
94184 + return 0
94185 +}
94186 +
94187 +while true
94188 +do
94189 + case "$1" in
94190 + -h|--help) usage && exit 0;;
94191 + -n) n=$2; shift 2;;
94192 + -o) header1="$2"; shift 2;;
94193 + -d) database="$2"; shift 2;;
94194 + --) shift 1; break ;;
94195 + *) break ;;
94196 + esac
94197 +done
94198 +
94199 +create_defines() {
94200 + for i in `seq 0 31`
94201 + do
94202 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
94203 + done
94204 + echo >> "$header1"
94205 +}
94206 +
94207 +create_structs() {
94208 + rm -f "$header1"
94209 +
94210 + create_defines
94211 +
94212 + cat "$database" | while read data
94213 + do
94214 + data_array=($data)
94215 + struct_hash_name="${data_array[0]}"
94216 + funcn="${data_array[1]}"
94217 + params="${data_array[2]}"
94218 + next="${data_array[4]}"
94219 +
94220 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
94221 +
94222 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
94223 + echo -en "\t.param\t= " >> "$header1"
94224 + line=
94225 + for param_num in ${params//-/ };
94226 + do
94227 + line="${line}PARAM"$param_num"|"
94228 + done
94229 +
94230 + echo -e "${line%?},\n};\n" >> "$header1"
94231 + done
94232 +}
94233 +
94234 +create_headers() {
94235 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
94236 +}
94237 +
94238 +create_array_elements() {
94239 + index=0
94240 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
94241 + do
94242 + data_array=($data)
94243 + i="${data_array[3]}"
94244 + hash="${data_array[0]}"
94245 + while [[ $index -lt $i ]]
94246 + do
94247 + echo -e "\t["$index"]\t= NULL," >> "$header1"
94248 + index=$(($index + 1))
94249 + done
94250 + index=$(($index + 1))
94251 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
94252 + done
94253 + echo '};' >> $header1
94254 +}
94255 +
94256 +create_structs
94257 +create_headers
94258 +create_array_elements
94259 +
94260 +exit 0
94261 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
94262 new file mode 100644
94263 index 0000000..568b360
94264 --- /dev/null
94265 +++ b/tools/gcc/kallocstat_plugin.c
94266 @@ -0,0 +1,170 @@
94267 +/*
94268 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94269 + * Licensed under the GPL v2
94270 + *
94271 + * Note: the choice of the license means that the compilation process is
94272 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94273 + * but for the kernel it doesn't matter since it doesn't link against
94274 + * any of the gcc libraries
94275 + *
94276 + * gcc plugin to find the distribution of k*alloc sizes
94277 + *
94278 + * TODO:
94279 + *
94280 + * BUGS:
94281 + * - none known
94282 + */
94283 +#include "gcc-plugin.h"
94284 +#include "config.h"
94285 +#include "system.h"
94286 +#include "coretypes.h"
94287 +#include "tree.h"
94288 +#include "tree-pass.h"
94289 +#include "flags.h"
94290 +#include "intl.h"
94291 +#include "toplev.h"
94292 +#include "plugin.h"
94293 +//#include "expr.h" where are you...
94294 +#include "diagnostic.h"
94295 +#include "plugin-version.h"
94296 +#include "tm.h"
94297 +#include "function.h"
94298 +#include "basic-block.h"
94299 +#include "gimple.h"
94300 +#include "rtl.h"
94301 +#include "emit-rtl.h"
94302 +
94303 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94304 +
94305 +int plugin_is_GPL_compatible;
94306 +
94307 +static const char * const kalloc_functions[] = {
94308 + "__kmalloc",
94309 + "kmalloc",
94310 + "kmalloc_large",
94311 + "kmalloc_node",
94312 + "kmalloc_order",
94313 + "kmalloc_order_trace",
94314 + "kmalloc_slab",
94315 + "kzalloc",
94316 + "kzalloc_node",
94317 +};
94318 +
94319 +static struct plugin_info kallocstat_plugin_info = {
94320 + .version = "201302112000",
94321 +};
94322 +
94323 +static unsigned int execute_kallocstat(void);
94324 +
94325 +static struct gimple_opt_pass kallocstat_pass = {
94326 + .pass = {
94327 + .type = GIMPLE_PASS,
94328 + .name = "kallocstat",
94329 +#if BUILDING_GCC_VERSION >= 4008
94330 + .optinfo_flags = OPTGROUP_NONE,
94331 +#endif
94332 + .gate = NULL,
94333 + .execute = execute_kallocstat,
94334 + .sub = NULL,
94335 + .next = NULL,
94336 + .static_pass_number = 0,
94337 + .tv_id = TV_NONE,
94338 + .properties_required = 0,
94339 + .properties_provided = 0,
94340 + .properties_destroyed = 0,
94341 + .todo_flags_start = 0,
94342 + .todo_flags_finish = 0
94343 + }
94344 +};
94345 +
94346 +static bool is_kalloc(const char *fnname)
94347 +{
94348 + size_t i;
94349 +
94350 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
94351 + if (!strcmp(fnname, kalloc_functions[i]))
94352 + return true;
94353 + return false;
94354 +}
94355 +
94356 +static unsigned int execute_kallocstat(void)
94357 +{
94358 + basic_block bb;
94359 +
94360 + // 1. loop through BBs and GIMPLE statements
94361 + FOR_EACH_BB(bb) {
94362 + gimple_stmt_iterator gsi;
94363 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94364 + // gimple match:
94365 + tree fndecl, size;
94366 + gimple call_stmt;
94367 + const char *fnname;
94368 +
94369 + // is it a call
94370 + call_stmt = gsi_stmt(gsi);
94371 + if (!is_gimple_call(call_stmt))
94372 + continue;
94373 + fndecl = gimple_call_fndecl(call_stmt);
94374 + if (fndecl == NULL_TREE)
94375 + continue;
94376 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
94377 + continue;
94378 +
94379 + // is it a call to k*alloc
94380 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
94381 + if (!is_kalloc(fnname))
94382 + continue;
94383 +
94384 + // is the size arg the result of a simple const assignment
94385 + size = gimple_call_arg(call_stmt, 0);
94386 + while (true) {
94387 + gimple def_stmt;
94388 + expanded_location xloc;
94389 + size_t size_val;
94390 +
94391 + if (TREE_CODE(size) != SSA_NAME)
94392 + break;
94393 + def_stmt = SSA_NAME_DEF_STMT(size);
94394 + if (!def_stmt || !is_gimple_assign(def_stmt))
94395 + break;
94396 + if (gimple_num_ops(def_stmt) != 2)
94397 + break;
94398 + size = gimple_assign_rhs1(def_stmt);
94399 + if (!TREE_CONSTANT(size))
94400 + continue;
94401 + xloc = expand_location(gimple_location(def_stmt));
94402 + if (!xloc.file)
94403 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
94404 + size_val = TREE_INT_CST_LOW(size);
94405 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
94406 + break;
94407 + }
94408 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94409 +//debug_tree(gimple_call_fn(call_stmt));
94410 +//print_node(stderr, "pax", fndecl, 4);
94411 + }
94412 + }
94413 +
94414 + return 0;
94415 +}
94416 +
94417 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94418 +{
94419 + const char * const plugin_name = plugin_info->base_name;
94420 + struct register_pass_info kallocstat_pass_info = {
94421 + .pass = &kallocstat_pass.pass,
94422 + .reference_pass_name = "ssa",
94423 + .ref_pass_instance_number = 1,
94424 + .pos_op = PASS_POS_INSERT_AFTER
94425 + };
94426 +
94427 + if (!plugin_default_version_check(version, &gcc_version)) {
94428 + error(G_("incompatible gcc/plugin versions"));
94429 + return 1;
94430 + }
94431 +
94432 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
94433 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
94434 +
94435 + return 0;
94436 +}
94437 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
94438 new file mode 100644
94439 index 0000000..0408e06
94440 --- /dev/null
94441 +++ b/tools/gcc/kernexec_plugin.c
94442 @@ -0,0 +1,465 @@
94443 +/*
94444 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94445 + * Licensed under the GPL v2
94446 + *
94447 + * Note: the choice of the license means that the compilation process is
94448 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94449 + * but for the kernel it doesn't matter since it doesn't link against
94450 + * any of the gcc libraries
94451 + *
94452 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
94453 + *
94454 + * TODO:
94455 + *
94456 + * BUGS:
94457 + * - none known
94458 + */
94459 +#include "gcc-plugin.h"
94460 +#include "config.h"
94461 +#include "system.h"
94462 +#include "coretypes.h"
94463 +#include "tree.h"
94464 +#include "tree-pass.h"
94465 +#include "flags.h"
94466 +#include "intl.h"
94467 +#include "toplev.h"
94468 +#include "plugin.h"
94469 +//#include "expr.h" where are you...
94470 +#include "diagnostic.h"
94471 +#include "plugin-version.h"
94472 +#include "tm.h"
94473 +#include "function.h"
94474 +#include "basic-block.h"
94475 +#include "gimple.h"
94476 +#include "rtl.h"
94477 +#include "emit-rtl.h"
94478 +#include "tree-flow.h"
94479 +
94480 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94481 +extern rtx emit_move_insn(rtx x, rtx y);
94482 +
94483 +#if BUILDING_GCC_VERSION <= 4006
94484 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
94485 +#endif
94486 +
94487 +#if BUILDING_GCC_VERSION >= 4008
94488 +#define TODO_dump_func 0
94489 +#endif
94490 +
94491 +int plugin_is_GPL_compatible;
94492 +
94493 +static struct plugin_info kernexec_plugin_info = {
94494 + .version = "201302112000",
94495 + .help = "method=[bts|or]\tinstrumentation method\n"
94496 +};
94497 +
94498 +static unsigned int execute_kernexec_reload(void);
94499 +static unsigned int execute_kernexec_fptr(void);
94500 +static unsigned int execute_kernexec_retaddr(void);
94501 +static bool kernexec_cmodel_check(void);
94502 +
94503 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
94504 +static void (*kernexec_instrument_retaddr)(rtx);
94505 +
94506 +static struct gimple_opt_pass kernexec_reload_pass = {
94507 + .pass = {
94508 + .type = GIMPLE_PASS,
94509 + .name = "kernexec_reload",
94510 +#if BUILDING_GCC_VERSION >= 4008
94511 + .optinfo_flags = OPTGROUP_NONE,
94512 +#endif
94513 + .gate = kernexec_cmodel_check,
94514 + .execute = execute_kernexec_reload,
94515 + .sub = NULL,
94516 + .next = NULL,
94517 + .static_pass_number = 0,
94518 + .tv_id = TV_NONE,
94519 + .properties_required = 0,
94520 + .properties_provided = 0,
94521 + .properties_destroyed = 0,
94522 + .todo_flags_start = 0,
94523 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94524 + }
94525 +};
94526 +
94527 +static struct gimple_opt_pass kernexec_fptr_pass = {
94528 + .pass = {
94529 + .type = GIMPLE_PASS,
94530 + .name = "kernexec_fptr",
94531 +#if BUILDING_GCC_VERSION >= 4008
94532 + .optinfo_flags = OPTGROUP_NONE,
94533 +#endif
94534 + .gate = kernexec_cmodel_check,
94535 + .execute = execute_kernexec_fptr,
94536 + .sub = NULL,
94537 + .next = NULL,
94538 + .static_pass_number = 0,
94539 + .tv_id = TV_NONE,
94540 + .properties_required = 0,
94541 + .properties_provided = 0,
94542 + .properties_destroyed = 0,
94543 + .todo_flags_start = 0,
94544 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94545 + }
94546 +};
94547 +
94548 +static struct rtl_opt_pass kernexec_retaddr_pass = {
94549 + .pass = {
94550 + .type = RTL_PASS,
94551 + .name = "kernexec_retaddr",
94552 +#if BUILDING_GCC_VERSION >= 4008
94553 + .optinfo_flags = OPTGROUP_NONE,
94554 +#endif
94555 + .gate = kernexec_cmodel_check,
94556 + .execute = execute_kernexec_retaddr,
94557 + .sub = NULL,
94558 + .next = NULL,
94559 + .static_pass_number = 0,
94560 + .tv_id = TV_NONE,
94561 + .properties_required = 0,
94562 + .properties_provided = 0,
94563 + .properties_destroyed = 0,
94564 + .todo_flags_start = 0,
94565 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
94566 + }
94567 +};
94568 +
94569 +static bool kernexec_cmodel_check(void)
94570 +{
94571 + tree section;
94572 +
94573 + if (ix86_cmodel != CM_KERNEL)
94574 + return false;
94575 +
94576 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
94577 + if (!section || !TREE_VALUE(section))
94578 + return true;
94579 +
94580 + section = TREE_VALUE(TREE_VALUE(section));
94581 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
94582 + return true;
94583 +
94584 + return false;
94585 +}
94586 +
94587 +/*
94588 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
94589 + */
94590 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
94591 +{
94592 + gimple asm_movabs_stmt;
94593 +
94594 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
94595 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
94596 + gimple_asm_set_volatile(asm_movabs_stmt, true);
94597 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
94598 + update_stmt(asm_movabs_stmt);
94599 +}
94600 +
94601 +/*
94602 + * find all asm() stmts that clobber r10 and add a reload of r10
94603 + */
94604 +static unsigned int execute_kernexec_reload(void)
94605 +{
94606 + basic_block bb;
94607 +
94608 + // 1. loop through BBs and GIMPLE statements
94609 + FOR_EACH_BB(bb) {
94610 + gimple_stmt_iterator gsi;
94611 +
94612 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94613 + // gimple match: __asm__ ("" : : : "r10");
94614 + gimple asm_stmt;
94615 + size_t nclobbers;
94616 +
94617 + // is it an asm ...
94618 + asm_stmt = gsi_stmt(gsi);
94619 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
94620 + continue;
94621 +
94622 + // ... clobbering r10
94623 + nclobbers = gimple_asm_nclobbers(asm_stmt);
94624 + while (nclobbers--) {
94625 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
94626 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
94627 + continue;
94628 + kernexec_reload_fptr_mask(&gsi);
94629 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
94630 + break;
94631 + }
94632 + }
94633 + }
94634 +
94635 + return 0;
94636 +}
94637 +
94638 +/*
94639 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
94640 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
94641 + */
94642 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
94643 +{
94644 + gimple assign_intptr, assign_new_fptr, call_stmt;
94645 + tree intptr, old_fptr, new_fptr, kernexec_mask;
94646 +
94647 + call_stmt = gsi_stmt(*gsi);
94648 + old_fptr = gimple_call_fn(call_stmt);
94649 +
94650 + // create temporary unsigned long variable used for bitops and cast fptr to it
94651 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
94652 +#if BUILDING_GCC_VERSION <= 4007
94653 + add_referenced_var(intptr);
94654 + mark_sym_for_renaming(intptr);
94655 +#endif
94656 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
94657 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94658 + update_stmt(assign_intptr);
94659 +
94660 + // apply logical or to temporary unsigned long and bitmask
94661 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
94662 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
94663 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
94664 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94665 + update_stmt(assign_intptr);
94666 +
94667 + // cast temporary unsigned long back to a temporary fptr variable
94668 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
94669 +#if BUILDING_GCC_VERSION <= 4007
94670 + add_referenced_var(new_fptr);
94671 + mark_sym_for_renaming(new_fptr);
94672 +#endif
94673 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
94674 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
94675 + update_stmt(assign_new_fptr);
94676 +
94677 + // replace call stmt fn with the new fptr
94678 + gimple_call_set_fn(call_stmt, new_fptr);
94679 + update_stmt(call_stmt);
94680 +}
94681 +
94682 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
94683 +{
94684 + gimple asm_or_stmt, call_stmt;
94685 + tree old_fptr, new_fptr, input, output;
94686 +#if BUILDING_GCC_VERSION <= 4007
94687 + VEC(tree, gc) *inputs = NULL;
94688 + VEC(tree, gc) *outputs = NULL;
94689 +#else
94690 + vec<tree, va_gc> *inputs = NULL;
94691 + vec<tree, va_gc> *outputs = NULL;
94692 +#endif
94693 +
94694 + call_stmt = gsi_stmt(*gsi);
94695 + old_fptr = gimple_call_fn(call_stmt);
94696 +
94697 + // create temporary fptr variable
94698 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
94699 +#if BUILDING_GCC_VERSION <= 4007
94700 + add_referenced_var(new_fptr);
94701 + mark_sym_for_renaming(new_fptr);
94702 +#endif
94703 +
94704 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
94705 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
94706 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
94707 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
94708 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
94709 +#if BUILDING_GCC_VERSION <= 4007
94710 + VEC_safe_push(tree, gc, inputs, input);
94711 + VEC_safe_push(tree, gc, outputs, output);
94712 +#else
94713 + vec_safe_push(inputs, input);
94714 + vec_safe_push(outputs, output);
94715 +#endif
94716 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
94717 + gimple_asm_set_volatile(asm_or_stmt, true);
94718 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
94719 + update_stmt(asm_or_stmt);
94720 +
94721 + // replace call stmt fn with the new fptr
94722 + gimple_call_set_fn(call_stmt, new_fptr);
94723 + update_stmt(call_stmt);
94724 +}
94725 +
94726 +/*
94727 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
94728 + */
94729 +static unsigned int execute_kernexec_fptr(void)
94730 +{
94731 + basic_block bb;
94732 +
94733 + // 1. loop through BBs and GIMPLE statements
94734 + FOR_EACH_BB(bb) {
94735 + gimple_stmt_iterator gsi;
94736 +
94737 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94738 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
94739 + tree fn;
94740 + gimple call_stmt;
94741 +
94742 + // is it a call ...
94743 + call_stmt = gsi_stmt(gsi);
94744 + if (!is_gimple_call(call_stmt))
94745 + continue;
94746 + fn = gimple_call_fn(call_stmt);
94747 + if (TREE_CODE(fn) == ADDR_EXPR)
94748 + continue;
94749 + if (TREE_CODE(fn) != SSA_NAME)
94750 + gcc_unreachable();
94751 +
94752 + // ... through a function pointer
94753 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
94754 + fn = SSA_NAME_VAR(fn);
94755 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
94756 + debug_tree(fn);
94757 + gcc_unreachable();
94758 + }
94759 + }
94760 + fn = TREE_TYPE(fn);
94761 + if (TREE_CODE(fn) != POINTER_TYPE)
94762 + continue;
94763 + fn = TREE_TYPE(fn);
94764 + if (TREE_CODE(fn) != FUNCTION_TYPE)
94765 + continue;
94766 +
94767 + kernexec_instrument_fptr(&gsi);
94768 +
94769 +//debug_tree(gimple_call_fn(call_stmt));
94770 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94771 + }
94772 + }
94773 +
94774 + return 0;
94775 +}
94776 +
94777 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
94778 +static void kernexec_instrument_retaddr_bts(rtx insn)
94779 +{
94780 + rtx btsq;
94781 + rtvec argvec, constraintvec, labelvec;
94782 + int line;
94783 +
94784 + // create asm volatile("btsq $63,(%%rsp)":::)
94785 + argvec = rtvec_alloc(0);
94786 + constraintvec = rtvec_alloc(0);
94787 + labelvec = rtvec_alloc(0);
94788 + line = expand_location(RTL_LOCATION(insn)).line;
94789 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94790 + MEM_VOLATILE_P(btsq) = 1;
94791 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
94792 + emit_insn_before(btsq, insn);
94793 +}
94794 +
94795 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
94796 +static void kernexec_instrument_retaddr_or(rtx insn)
94797 +{
94798 + rtx orq;
94799 + rtvec argvec, constraintvec, labelvec;
94800 + int line;
94801 +
94802 + // create asm volatile("orq %%r10,(%%rsp)":::)
94803 + argvec = rtvec_alloc(0);
94804 + constraintvec = rtvec_alloc(0);
94805 + labelvec = rtvec_alloc(0);
94806 + line = expand_location(RTL_LOCATION(insn)).line;
94807 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94808 + MEM_VOLATILE_P(orq) = 1;
94809 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
94810 + emit_insn_before(orq, insn);
94811 +}
94812 +
94813 +/*
94814 + * find all asm level function returns and forcibly set the highest bit of the return address
94815 + */
94816 +static unsigned int execute_kernexec_retaddr(void)
94817 +{
94818 + rtx insn;
94819 +
94820 + // 1. find function returns
94821 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
94822 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
94823 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
94824 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
94825 + rtx body;
94826 +
94827 + // is it a retn
94828 + if (!JUMP_P(insn))
94829 + continue;
94830 + body = PATTERN(insn);
94831 + if (GET_CODE(body) == PARALLEL)
94832 + body = XVECEXP(body, 0, 0);
94833 + if (!ANY_RETURN_P(body))
94834 + continue;
94835 + kernexec_instrument_retaddr(insn);
94836 + }
94837 +
94838 +// print_simple_rtl(stderr, get_insns());
94839 +// print_rtl(stderr, get_insns());
94840 +
94841 + return 0;
94842 +}
94843 +
94844 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94845 +{
94846 + const char * const plugin_name = plugin_info->base_name;
94847 + const int argc = plugin_info->argc;
94848 + const struct plugin_argument * const argv = plugin_info->argv;
94849 + int i;
94850 + struct register_pass_info kernexec_reload_pass_info = {
94851 + .pass = &kernexec_reload_pass.pass,
94852 + .reference_pass_name = "ssa",
94853 + .ref_pass_instance_number = 1,
94854 + .pos_op = PASS_POS_INSERT_AFTER
94855 + };
94856 + struct register_pass_info kernexec_fptr_pass_info = {
94857 + .pass = &kernexec_fptr_pass.pass,
94858 + .reference_pass_name = "ssa",
94859 + .ref_pass_instance_number = 1,
94860 + .pos_op = PASS_POS_INSERT_AFTER
94861 + };
94862 + struct register_pass_info kernexec_retaddr_pass_info = {
94863 + .pass = &kernexec_retaddr_pass.pass,
94864 + .reference_pass_name = "pro_and_epilogue",
94865 + .ref_pass_instance_number = 1,
94866 + .pos_op = PASS_POS_INSERT_AFTER
94867 + };
94868 +
94869 + if (!plugin_default_version_check(version, &gcc_version)) {
94870 + error(G_("incompatible gcc/plugin versions"));
94871 + return 1;
94872 + }
94873 +
94874 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
94875 +
94876 + if (TARGET_64BIT == 0)
94877 + return 0;
94878 +
94879 + for (i = 0; i < argc; ++i) {
94880 + if (!strcmp(argv[i].key, "method")) {
94881 + if (!argv[i].value) {
94882 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94883 + continue;
94884 + }
94885 + if (!strcmp(argv[i].value, "bts")) {
94886 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
94887 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
94888 + } else if (!strcmp(argv[i].value, "or")) {
94889 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
94890 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
94891 + fix_register("r10", 1, 1);
94892 + } else
94893 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
94894 + continue;
94895 + }
94896 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94897 + }
94898 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
94899 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
94900 +
94901 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
94902 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
94903 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
94904 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
94905 +
94906 + return 0;
94907 +}
94908 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
94909 new file mode 100644
94910 index 0000000..b5395ba
94911 --- /dev/null
94912 +++ b/tools/gcc/latent_entropy_plugin.c
94913 @@ -0,0 +1,327 @@
94914 +/*
94915 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
94916 + * Licensed under the GPL v2
94917 + *
94918 + * Note: the choice of the license means that the compilation process is
94919 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94920 + * but for the kernel it doesn't matter since it doesn't link against
94921 + * any of the gcc libraries
94922 + *
94923 + * gcc plugin to help generate a little bit of entropy from program state,
94924 + * used during boot in the kernel
94925 + *
94926 + * TODO:
94927 + * - add ipa pass to identify not explicitly marked candidate functions
94928 + * - mix in more program state (function arguments/return values, loop variables, etc)
94929 + * - more instrumentation control via attribute parameters
94930 + *
94931 + * BUGS:
94932 + * - LTO needs -flto-partition=none for now
94933 + */
94934 +#include "gcc-plugin.h"
94935 +#include "config.h"
94936 +#include "system.h"
94937 +#include "coretypes.h"
94938 +#include "tree.h"
94939 +#include "tree-pass.h"
94940 +#include "flags.h"
94941 +#include "intl.h"
94942 +#include "toplev.h"
94943 +#include "plugin.h"
94944 +//#include "expr.h" where are you...
94945 +#include "diagnostic.h"
94946 +#include "plugin-version.h"
94947 +#include "tm.h"
94948 +#include "function.h"
94949 +#include "basic-block.h"
94950 +#include "gimple.h"
94951 +#include "rtl.h"
94952 +#include "emit-rtl.h"
94953 +#include "tree-flow.h"
94954 +#include "langhooks.h"
94955 +
94956 +#if BUILDING_GCC_VERSION >= 4008
94957 +#define TODO_dump_func 0
94958 +#endif
94959 +
94960 +int plugin_is_GPL_compatible;
94961 +
94962 +static tree latent_entropy_decl;
94963 +
94964 +static struct plugin_info latent_entropy_plugin_info = {
94965 + .version = "201303102320",
94966 + .help = NULL
94967 +};
94968 +
94969 +static unsigned int execute_latent_entropy(void);
94970 +static bool gate_latent_entropy(void);
94971 +
94972 +static struct gimple_opt_pass latent_entropy_pass = {
94973 + .pass = {
94974 + .type = GIMPLE_PASS,
94975 + .name = "latent_entropy",
94976 +#if BUILDING_GCC_VERSION >= 4008
94977 + .optinfo_flags = OPTGROUP_NONE,
94978 +#endif
94979 + .gate = gate_latent_entropy,
94980 + .execute = execute_latent_entropy,
94981 + .sub = NULL,
94982 + .next = NULL,
94983 + .static_pass_number = 0,
94984 + .tv_id = TV_NONE,
94985 + .properties_required = PROP_gimple_leh | PROP_cfg,
94986 + .properties_provided = 0,
94987 + .properties_destroyed = 0,
94988 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
94989 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
94990 + }
94991 +};
94992 +
94993 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94994 +{
94995 + if (TREE_CODE(*node) != FUNCTION_DECL) {
94996 + *no_add_attrs = true;
94997 + error("%qE attribute only applies to functions", name);
94998 + }
94999 + return NULL_TREE;
95000 +}
95001 +
95002 +static struct attribute_spec latent_entropy_attr = {
95003 + .name = "latent_entropy",
95004 + .min_length = 0,
95005 + .max_length = 0,
95006 + .decl_required = true,
95007 + .type_required = false,
95008 + .function_type_required = false,
95009 + .handler = handle_latent_entropy_attribute,
95010 +#if BUILDING_GCC_VERSION >= 4007
95011 + .affects_type_identity = false
95012 +#endif
95013 +};
95014 +
95015 +static void register_attributes(void *event_data, void *data)
95016 +{
95017 + register_attribute(&latent_entropy_attr);
95018 +}
95019 +
95020 +static bool gate_latent_entropy(void)
95021 +{
95022 + tree latent_entropy_attr;
95023 +
95024 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
95025 + return latent_entropy_attr != NULL_TREE;
95026 +}
95027 +
95028 +static unsigned HOST_WIDE_INT seed;
95029 +static unsigned HOST_WIDE_INT get_random_const(void)
95030 +{
95031 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
95032 + return seed;
95033 +}
95034 +
95035 +static enum tree_code get_op(tree *rhs)
95036 +{
95037 + static enum tree_code op;
95038 + unsigned HOST_WIDE_INT random_const;
95039 +
95040 + random_const = get_random_const();
95041 +
95042 + switch (op) {
95043 + case BIT_XOR_EXPR:
95044 + op = PLUS_EXPR;
95045 + break;
95046 +
95047 + case PLUS_EXPR:
95048 + if (rhs) {
95049 + op = LROTATE_EXPR;
95050 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
95051 + break;
95052 + }
95053 +
95054 + case LROTATE_EXPR:
95055 + default:
95056 + op = BIT_XOR_EXPR;
95057 + break;
95058 + }
95059 + if (rhs)
95060 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
95061 + return op;
95062 +}
95063 +
95064 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
95065 +{
95066 + gimple_stmt_iterator gsi;
95067 + gimple assign;
95068 + tree addxorrol, rhs;
95069 + enum tree_code op;
95070 +
95071 + op = get_op(&rhs);
95072 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
95073 + assign = gimple_build_assign(local_entropy, addxorrol);
95074 +#if BUILDING_GCC_VERSION <= 4007
95075 + find_referenced_vars_in(assign);
95076 +#endif
95077 +//debug_bb(bb);
95078 + gsi = gsi_after_labels(bb);
95079 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
95080 + update_stmt(assign);
95081 +}
95082 +
95083 +static void perturb_latent_entropy(basic_block bb, tree rhs)
95084 +{
95085 + gimple_stmt_iterator gsi;
95086 + gimple assign;
95087 + tree addxorrol, temp;
95088 +
95089 + // 1. create temporary copy of latent_entropy
95090 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
95091 +#if BUILDING_GCC_VERSION <= 4007
95092 + add_referenced_var(temp);
95093 + mark_sym_for_renaming(temp);
95094 +#endif
95095 +
95096 + // 2. read...
95097 + assign = gimple_build_assign(temp, latent_entropy_decl);
95098 +#if BUILDING_GCC_VERSION <= 4007
95099 + find_referenced_vars_in(assign);
95100 +#endif
95101 + gsi = gsi_after_labels(bb);
95102 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95103 + update_stmt(assign);
95104 +
95105 + // 3. ...modify...
95106 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
95107 + assign = gimple_build_assign(temp, addxorrol);
95108 +#if BUILDING_GCC_VERSION <= 4007
95109 + find_referenced_vars_in(assign);
95110 +#endif
95111 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95112 + update_stmt(assign);
95113 +
95114 + // 4. ...write latent_entropy
95115 + assign = gimple_build_assign(latent_entropy_decl, temp);
95116 +#if BUILDING_GCC_VERSION <= 4007
95117 + find_referenced_vars_in(assign);
95118 +#endif
95119 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95120 + update_stmt(assign);
95121 +}
95122 +
95123 +static unsigned int execute_latent_entropy(void)
95124 +{
95125 + basic_block bb;
95126 + gimple assign;
95127 + gimple_stmt_iterator gsi;
95128 + tree local_entropy;
95129 +
95130 + if (!latent_entropy_decl) {
95131 + struct varpool_node *node;
95132 +
95133 +#if BUILDING_GCC_VERSION <= 4007
95134 + for (node = varpool_nodes; node; node = node->next) {
95135 + tree var = node->decl;
95136 +#else
95137 + FOR_EACH_VARIABLE(node) {
95138 + tree var = node->symbol.decl;
95139 +#endif
95140 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
95141 + continue;
95142 + latent_entropy_decl = var;
95143 +// debug_tree(var);
95144 + break;
95145 + }
95146 + if (!latent_entropy_decl) {
95147 +// debug_tree(current_function_decl);
95148 + return 0;
95149 + }
95150 + }
95151 +
95152 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
95153 +
95154 + // 1. create local entropy variable
95155 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
95156 +#if BUILDING_GCC_VERSION <= 4007
95157 + add_referenced_var(local_entropy);
95158 + mark_sym_for_renaming(local_entropy);
95159 +#endif
95160 +
95161 + // 2. initialize local entropy variable
95162 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
95163 + if (dom_info_available_p(CDI_DOMINATORS))
95164 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
95165 + gsi = gsi_start_bb(bb);
95166 +
95167 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
95168 +// gimple_set_location(assign, loc);
95169 +#if BUILDING_GCC_VERSION <= 4007
95170 + find_referenced_vars_in(assign);
95171 +#endif
95172 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95173 + update_stmt(assign);
95174 + bb = bb->next_bb;
95175 +
95176 + // 3. instrument each BB with an operation on the local entropy variable
95177 + while (bb != EXIT_BLOCK_PTR) {
95178 + perturb_local_entropy(bb, local_entropy);
95179 + bb = bb->next_bb;
95180 + };
95181 +
95182 + // 4. mix local entropy into the global entropy variable
95183 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
95184 + return 0;
95185 +}
95186 +
95187 +static void start_unit_callback(void *gcc_data, void *user_data)
95188 +{
95189 + tree latent_entropy_type;
95190 +
95191 +#if BUILDING_GCC_VERSION >= 4007
95192 + seed = get_random_seed(false);
95193 +#else
95194 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
95195 + seed *= seed;
95196 +#endif
95197 +
95198 + if (in_lto_p)
95199 + return;
95200 +
95201 + // extern volatile u64 latent_entropy
95202 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
95203 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
95204 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
95205 +
95206 + TREE_STATIC(latent_entropy_decl) = 1;
95207 + TREE_PUBLIC(latent_entropy_decl) = 1;
95208 + TREE_USED(latent_entropy_decl) = 1;
95209 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
95210 + DECL_EXTERNAL(latent_entropy_decl) = 1;
95211 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
95212 + DECL_INITIAL(latent_entropy_decl) = NULL;
95213 + lang_hooks.decls.pushdecl(latent_entropy_decl);
95214 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
95215 +// varpool_finalize_decl(latent_entropy_decl);
95216 +// varpool_mark_needed_node(latent_entropy_decl);
95217 +}
95218 +
95219 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95220 +{
95221 + const char * const plugin_name = plugin_info->base_name;
95222 + struct register_pass_info latent_entropy_pass_info = {
95223 + .pass = &latent_entropy_pass.pass,
95224 + .reference_pass_name = "optimized",
95225 + .ref_pass_instance_number = 1,
95226 + .pos_op = PASS_POS_INSERT_BEFORE
95227 + };
95228 +
95229 + if (!plugin_default_version_check(version, &gcc_version)) {
95230 + error(G_("incompatible gcc/plugin versions"));
95231 + return 1;
95232 + }
95233 +
95234 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
95235 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
95236 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
95237 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95238 +
95239 + return 0;
95240 +}
95241 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
95242 new file mode 100644
95243 index 0000000..ddd5b2e
95244 --- /dev/null
95245 +++ b/tools/gcc/size_overflow_hash.data
95246 @@ -0,0 +1,5876 @@
95247 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
95248 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
95249 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
95250 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
95251 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
95252 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
95253 +padzero_55 padzero 1 55 &sel_read_policyvers_55
95254 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
95255 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
95256 +DepcaSignature_80 DepcaSignature 2 80 NULL nohasharray
95257 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 &DepcaSignature_80
95258 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
95259 +load_msg_95 load_msg 2 95 NULL
95260 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
95261 +init_q_132 init_q 4 132 NULL
95262 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
95263 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
95264 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
95265 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
95266 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
95267 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
95268 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
95269 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
95270 +br_port_info_size_268 br_port_info_size 0 268 NULL
95271 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
95272 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
95273 +syslog_print_307 syslog_print 2 307 NULL
95274 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
95275 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
95276 +next_node_allowed_318 next_node_allowed 1 318 NULL
95277 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
95278 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
95279 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
95280 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
95281 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
95282 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
95283 +pidlist_resize_496 pidlist_resize 2 496 NULL
95284 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
95285 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
95286 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
95287 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
95288 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
95289 +dle_count_543 dle_count 0 543 NULL
95290 +devres_alloc_551 devres_alloc 2 551 NULL
95291 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
95292 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
95293 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
95294 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
95295 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
95296 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
95297 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
95298 +isp1760_register_628 isp1760_register 1-2 628 NULL
95299 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
95300 +unlink_queued_645 unlink_queued 3-4 645 NULL
95301 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
95302 +ceph_copy_user_to_page_vector_656 ceph_copy_user_to_page_vector 4-3 656 NULL
95303 +div_u64_rem_672 div_u64_rem 0 672 NULL
95304 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
95305 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
95306 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
95307 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
95308 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
95309 +wm8962_gpio_direction_out_738 wm8962_gpio_direction_out 2 738 NULL
95310 +dvb_video_write_754 dvb_video_write 3 754 NULL
95311 +iwl_read_targ_mem_772 iwl_read_targ_mem 0 772 NULL
95312 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
95313 +if_writecmd_815 if_writecmd 2 815 NULL
95314 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
95315 +read_fifo_826 read_fifo 3 826 NULL
95316 +read_tree_block_841 read_tree_block 3 841 NULL
95317 +um_idi_read_850 um_idi_read 3 850 NULL
95318 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
95319 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
95320 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
95321 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
95322 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
95323 +readw_931 readw 0 931 NULL
95324 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
95325 +ieee80211_ie_build_vht_cap_956 ieee80211_ie_build_vht_cap 0 956 NULL nohasharray
95326 +__nodes_weight_956 __nodes_weight 2-0 956 &ieee80211_ie_build_vht_cap_956
95327 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
95328 +hdlcdev_rx_997 hdlcdev_rx 3 997 NULL
95329 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
95330 +lp872x_select_buck_vout_addr_1045 lp872x_select_buck_vout_addr 0 1045 NULL
95331 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
95332 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
95333 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
95334 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
95335 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
95336 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
95337 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
95338 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
95339 +store_risefalltime_1109 store_risefalltime 5 1109 NULL
95340 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
95341 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
95342 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
95343 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
95344 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
95345 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
95346 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
95347 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
95348 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
95349 +thin_status_1239 thin_status 5 1239 NULL
95350 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
95351 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
95352 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
95353 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
95354 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
95355 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
95356 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
95357 +ffs_1322 ffs 0 1322 NULL
95358 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
95359 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
95360 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
95361 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
95362 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
95363 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
95364 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
95365 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
95366 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
95367 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
95368 +zone_page_state_1393 zone_page_state 0 1393 NULL
95369 +file_read_actor_1401 file_read_actor 4 1401 NULL
95370 +lm3533_als_get_threshold_reg_1404 lm3533_als_get_threshold_reg 0-1 1404 NULL
95371 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
95372 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
95373 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
95374 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
95375 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
95376 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
95377 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
95378 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
95379 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
95380 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
95381 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
95382 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
95383 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
95384 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
95385 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
95386 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
95387 +rmap_add_1677 rmap_add 3 1677 NULL
95388 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
95389 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
95390 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
95391 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
95392 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
95393 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
95394 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
95395 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
95396 +cosa_write_1774 cosa_write 3 1774 NULL
95397 +update_macheader_1775 update_macheader 7 1775 NULL
95398 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
95399 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
95400 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
95401 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
95402 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
95403 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
95404 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
95405 +read_swap_header_1957 read_swap_header 0 1957 NULL
95406 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
95407 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
95408 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
95409 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
95410 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
95411 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
95412 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
95413 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
95414 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
95415 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
95416 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
95417 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
95418 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
95419 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
95420 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
95421 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
95422 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
95423 +audit_expand_2098 audit_expand 2 2098 NULL
95424 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
95425 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
95426 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
95427 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
95428 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
95429 +pcf50633_write_block_2124 pcf50633_write_block 3-2 2124 NULL
95430 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
95431 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL nohasharray
95432 +multipath_status_2151 multipath_status 5 2151 &mlx4_init_icm_table_2151
95433 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
95434 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
95435 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
95436 +u32_array_read_2219 u32_array_read 3 2219 NULL
95437 +vhci_write_2224 vhci_write 3 2224 NULL
95438 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
95439 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
95440 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
95441 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
95442 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
95443 +do_update_counters_2259 do_update_counters 4 2259 NULL
95444 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
95445 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
95446 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
95447 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
95448 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
95449 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
95450 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
95451 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
95452 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
95453 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
95454 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
95455 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
95456 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
95457 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
95458 +raid1_size_2419 raid1_size 0-2 2419 NULL
95459 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
95460 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
95461 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
95462 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
95463 +nfs4_alloc_slots_2454 nfs4_alloc_slots 1 2454 NULL nohasharray
95464 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 &nfs4_alloc_slots_2454
95465 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
95466 +update_pmkid_2481 update_pmkid 4 2481 NULL
95467 +wiphy_new_2482 wiphy_new 2 2482 NULL
95468 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
95469 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
95470 +dm_write_2513 dm_write 3 2513 NULL
95471 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
95472 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
95473 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
95474 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
95475 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
95476 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
95477 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
95478 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
95479 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
95480 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
95481 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
95482 +__next_cpu_2782 __next_cpu 1 2782 NULL
95483 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
95484 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
95485 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
95486 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
95487 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
95488 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
95489 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
95490 +__swab64p_2875 __swab64p 0 2875 NULL
95491 +nla_padlen_2883 nla_padlen 1 2883 NULL
95492 +cmm_write_2896 cmm_write 3 2896 NULL
95493 +rbd_req_sync_read_2915 rbd_req_sync_read 4-5 2915 NULL
95494 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
95495 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
95496 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
95497 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
95498 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
95499 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
95500 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
95501 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
95502 +depth_write_3021 depth_write 3 3021 NULL
95503 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
95504 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
95505 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
95506 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
95507 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
95508 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
95509 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
95510 +free_coherent_3082 free_coherent 4-2 3082 NULL
95511 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
95512 +rb_alloc_3102 rb_alloc 1 3102 NULL
95513 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
95514 +print_time_3132 print_time 0 3132 NULL
95515 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
95516 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
95517 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
95518 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
95519 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
95520 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
95521 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
95522 +alloc_context_3194 alloc_context 1 3194 NULL
95523 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
95524 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
95525 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
95526 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
95527 +key_key_read_3241 key_key_read 3 3241 NULL
95528 +number_3243 number 0 3243 NULL
95529 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
95530 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
95531 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
95532 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
95533 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
95534 +de600_read_byte_3332 de600_read_byte 0 3332 NULL
95535 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
95536 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
95537 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
95538 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
95539 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
95540 +scnprintf_3360 scnprintf 0-2 3360 NULL nohasharray
95541 +tps65090_clr_bits_3360 tps65090_clr_bits 2 3360 &scnprintf_3360
95542 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
95543 +send_stream_3397 send_stream 4 3397 NULL
95544 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
95545 +msix_map_region_3411 msix_map_region 3 3411 NULL
95546 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
95547 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
95548 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
95549 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
95550 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
95551 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
95552 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
95553 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
95554 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
95555 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
95556 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
95557 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
95558 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
95559 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
95560 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
95561 +evtchn_read_3569 evtchn_read 3 3569 NULL
95562 +vc_resize_3585 vc_resize 2-3 3585 NULL
95563 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
95564 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
95565 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
95566 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
95567 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
95568 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
95569 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
95570 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
95571 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
95572 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
95573 +create_irq_3703 create_irq 0 3703 NULL nohasharray
95574 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
95575 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
95576 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
95577 +lm3533_als_get_threshold_3725 lm3533_als_get_threshold 2 3725 NULL
95578 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
95579 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
95580 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
95581 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
95582 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
95583 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
95584 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
95585 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
95586 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
95587 +get_fd_set_3866 get_fd_set 1 3866 NULL
95588 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
95589 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
95590 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
95591 +nvram_write_3894 nvram_write 3 3894 NULL
95592 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
95593 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
95594 +vcs_write_3910 vcs_write 3 3910 NULL
95595 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
95596 +do_add_counters_3992 do_add_counters 3 3992 NULL
95597 +userspace_status_4004 userspace_status 4 4004 NULL
95598 +mei_write_4005 mei_write 3 4005 NULL nohasharray
95599 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
95600 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
95601 +blk_end_request_4024 blk_end_request 3 4024 NULL
95602 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
95603 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
95604 +read_file_queues_4078 read_file_queues 3 4078 NULL
95605 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
95606 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
95607 +tm6000_read_4151 tm6000_read 3 4151 NULL
95608 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
95609 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
95610 +get_alua_req_4166 get_alua_req 3 4166 NULL
95611 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
95612 +read_file_bool_4180 read_file_bool 3 4180 NULL
95613 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
95614 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
95615 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
95616 +ext4_new_inode_4247 ext4_new_inode 5 4247 NULL
95617 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
95618 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
95619 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 2-3-5 4303 NULL
95620 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
95621 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
95622 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
95623 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
95624 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
95625 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
95626 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
95627 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
95628 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
95629 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
95630 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
95631 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
95632 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
95633 +set_link_security_4502 set_link_security 4 4502 NULL
95634 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
95635 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
95636 +tty_register_device_4544 tty_register_device 2 4544 NULL
95637 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
95638 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
95639 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
95640 +bch_alloc_4593 bch_alloc 1 4593 NULL
95641 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
95642 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
95643 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
95644 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
95645 +kone_receive_4690 kone_receive 4 4690 NULL
95646 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
95647 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
95648 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
95649 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
95650 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
95651 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
95652 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
95653 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
95654 +__iio_allocate_sw_ring_buffer_4843 __iio_allocate_sw_ring_buffer 3 4843 NULL
95655 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
95656 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
95657 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
95658 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
95659 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
95660 +sys_ipc_4889 sys_ipc 3 4889 NULL
95661 +lp872x_write_byte_4914 lp872x_write_byte 2 4914 NULL
95662 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
95663 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
95664 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
95665 +da9055_reg_write_4942 da9055_reg_write 2 4942 NULL
95666 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
95667 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
95668 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
95669 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
95670 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
95671 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
95672 +lm3533_als_set_target_5010 lm3533_als_set_target 2-3 5010 NULL
95673 +do_mincore_5018 do_mincore 0-1 5018 NULL
95674 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
95675 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
95676 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
95677 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
95678 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
95679 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
95680 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
95681 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
95682 +sound_write_5102 sound_write 3 5102 NULL
95683 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
95684 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
95685 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
95686 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
95687 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
95688 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
95689 +skb_network_header_5203 skb_network_header 0 5203 NULL
95690 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
95691 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
95692 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
95693 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
95694 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
95695 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
95696 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
95697 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
95698 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
95699 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
95700 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
95701 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
95702 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
95703 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
95704 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
95705 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
95706 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
95707 +tty_write_5494 tty_write 3 5494 NULL
95708 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
95709 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
95710 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
95711 +spidev_message_5518 spidev_message 3 5518 NULL
95712 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
95713 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
95714 +le_readq_5557 le_readq 0 5557 NULL
95715 +inw_5558 inw 0 5558 NULL
95716 +__first_dma_cap_5560 __first_dma_cap 0 5560 NULL
95717 +fir16_create_5574 fir16_create 3 5574 NULL
95718 +bioset_create_5580 bioset_create 1 5580 NULL
95719 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
95720 +do_msgrcv_5590 do_msgrcv 4 5590 NULL
95721 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
95722 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
95723 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
95724 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
95725 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
95726 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
95727 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
95728 +get_arg_5694 get_arg 3 5694 NULL
95729 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
95730 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
95731 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
95732 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
95733 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
95734 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
95735 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
95736 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
95737 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
95738 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
95739 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
95740 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
95741 +setup_req_5848 setup_req 3 5848 NULL
95742 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
95743 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
95744 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
95745 +port_show_regs_5904 port_show_regs 3 5904 NULL
95746 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
95747 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
95748 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
95749 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
95750 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
95751 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
95752 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
95753 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
95754 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
95755 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
95756 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
95757 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
95758 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
95759 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
95760 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
95761 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
95762 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
95763 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
95764 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
95765 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
95766 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
95767 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
95768 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
95769 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
95770 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
95771 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
95772 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
95773 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
95774 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 0 6282 NULL nohasharray
95775 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
95776 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
95777 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
95778 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
95779 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
95780 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
95781 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
95782 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
95783 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
95784 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
95785 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 NULL
95786 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
95787 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
95788 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
95789 +mei_read_6507 mei_read 3 6507 NULL
95790 +cpumask_next_and_6516 cpumask_next_and 1 6516 NULL
95791 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
95792 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
95793 +wdm_read_6549 wdm_read 3 6549 NULL
95794 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
95795 +usb_dump_config_descriptor_6572 usb_dump_config_descriptor 0 6572 NULL
95796 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
95797 +usemap_size_6601 usemap_size 0-1 6601 NULL
95798 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
95799 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
95800 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
95801 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
95802 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
95803 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
95804 +ieee80211_build_preq_ies_6691 ieee80211_build_preq_ies 0-4 6691 NULL
95805 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
95806 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
95807 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
95808 +mpeg_read_6708 mpeg_read 3 6708 NULL
95809 +video_proc_write_6724 video_proc_write 3 6724 NULL
95810 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
95811 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
95812 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
95813 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
95814 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
95815 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
95816 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
95817 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
95818 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
95819 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
95820 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
95821 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
95822 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
95823 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
95824 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
95825 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
95826 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
95827 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
95828 +ieee80211_rx_mgmt_probe_resp_6918 ieee80211_rx_mgmt_probe_resp 3 6918 NULL
95829 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
95830 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
95831 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
95832 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
95833 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
95834 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
95835 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
95836 +request_key_async_6990 request_key_async 4 6990 NULL
95837 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
95838 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
95839 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
95840 +wimax_msg_7030 wimax_msg 4 7030 NULL
95841 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
95842 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
95843 +event_enable_read_7074 event_enable_read 3 7074 NULL
95844 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
95845 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
95846 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
95847 +check_header_7108 check_header 0 7108 NULL
95848 +utf16_strsize_7203 utf16_strsize 0 7203 NULL nohasharray
95849 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 &utf16_strsize_7203
95850 +sys32_ipc_7238 sys32_ipc 3-5-6-4 7238 NULL
95851 +get_param_h_7247 get_param_h 0 7247 NULL
95852 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
95853 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
95854 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
95855 +mgmt_control_7349 mgmt_control 3 7349 NULL
95856 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
95857 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
95858 +hweight_long_7388 hweight_long 0-1 7388 NULL
95859 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
95860 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
95861 +readb_7401 readb 0 7401 NULL
95862 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
95863 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
95864 +ms_rw_multi_sector_7459 ms_rw_multi_sector 3-4 7459 NULL
95865 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL nohasharray
95866 +wm8996_gpio_direction_out_7469 wm8996_gpio_direction_out 2 7469 &__mutex_lock_common_7469
95867 +garp_request_join_7471 garp_request_join 4 7471 NULL
95868 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
95869 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
95870 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
95871 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
95872 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
95873 +setup_usemap_7524 setup_usemap 3 7524 NULL
95874 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
95875 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
95876 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
95877 +groups_alloc_7614 groups_alloc 1 7614 NULL
95878 +sg_virt_7616 sg_virt 0 7616 NULL
95879 +cpumask_first_7648 cpumask_first 0 7648 NULL
95880 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
95881 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
95882 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
95883 +dev_write_7708 dev_write 3 7708 NULL
95884 +tps65090_set_bits_7709 tps65090_set_bits 2 7709 NULL
95885 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL nohasharray
95886 +dbg_check_cats_7713 dbg_check_cats 0 7713 &brcmf_sdcard_send_buf_7713
95887 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
95888 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
95889 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
95890 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
95891 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
95892 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
95893 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
95894 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
95895 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
95896 +da9052_reg_update_7858 da9052_reg_update 2 7858 NULL
95897 +tps6586x_clr_bits_7889 tps6586x_clr_bits 2 7889 NULL
95898 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
95899 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
95900 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
95901 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
95902 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
95903 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
95904 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
95905 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
95906 +sys_mbind_7990 sys_mbind 5 7990 NULL
95907 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
95908 +vcs_read_8017 vcs_read 3 8017 NULL
95909 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
95910 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
95911 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
95912 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
95913 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
95914 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
95915 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
95916 +venus_lookup_8121 venus_lookup 4 8121 NULL
95917 +lm3533_als_set_threshold_8125 lm3533_als_set_threshold 2 8125 NULL
95918 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
95919 +ext_sd_execute_write_data_8175 ext_sd_execute_write_data 9 8175 NULL
95920 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
95921 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
95922 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
95923 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
95924 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
95925 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
95926 +play_iframe_8219 play_iframe 3 8219 NULL
95927 +create_log_8225 create_log 2 8225 NULL nohasharray
95928 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
95929 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
95930 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
95931 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
95932 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
95933 +init_cdev_8274 init_cdev 1 8274 NULL
95934 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
95935 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
95936 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
95937 +lm3533_led_get_pattern_8321 lm3533_led_get_pattern 0 8321 NULL nohasharray
95938 +construct_key_and_link_8321 construct_key_and_link 4 8321 &lm3533_led_get_pattern_8321
95939 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
95940 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
95941 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
95942 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
95943 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
95944 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
95945 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
95946 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
95947 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
95948 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
95949 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
95950 +_irq_to_enable_addr_8485 _irq_to_enable_addr 0-1 8485 NULL
95951 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
95952 +dev_config_8506 dev_config 3 8506 NULL
95953 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
95954 +utf16_strnlen_8513 utf16_strnlen 0 8513 NULL
95955 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
95956 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
95957 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
95958 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
95959 +profile_remove_8556 profile_remove 3 8556 NULL
95960 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
95961 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
95962 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
95963 +tower_write_8580 tower_write 3 8580 NULL
95964 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
95965 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
95966 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
95967 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
95968 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
95969 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
95970 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
95971 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
95972 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
95973 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
95974 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
95975 +arcfb_write_8702 arcfb_write 3 8702 NULL
95976 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
95977 +init_header_8703 init_header 0 8703 &i_size_read_8703
95978 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
95979 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL nohasharray
95980 +snapshot_status_8729 snapshot_status 5 8729 &jffs2_acl_count_8729
95981 +f_dupfd_8730 f_dupfd 1 8730 NULL
95982 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
95983 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
95984 +sys_prctl_8766 sys_prctl 4 8766 NULL
95985 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
95986 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
95987 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
95988 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
95989 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
95990 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
95991 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
95992 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
95993 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
95994 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
95995 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
95996 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
95997 +send_pages_8872 send_pages 3 8872 NULL
95998 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
95999 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
96000 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
96001 +layout_commit_8926 layout_commit 3 8926 NULL
96002 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
96003 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
96004 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
96005 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
96006 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
96007 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
96008 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
96009 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
96010 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
96011 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
96012 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
96013 +palmas_ldo_write_9012 palmas_ldo_write 2 9012 NULL
96014 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
96015 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
96016 +nla_put_9042 nla_put 3 9042 NULL
96017 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
96018 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
96019 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
96020 +string_9080 string 0 9080 NULL
96021 +create_queues_9088 create_queues 2-3 9088 NULL
96022 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
96023 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
96024 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
96025 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
96026 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
96027 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
96028 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
96029 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
96030 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
96031 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
96032 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
96033 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
96034 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
96035 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
96036 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
96037 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
96038 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
96039 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
96040 +flakey_status_9274 flakey_status 5 9274 NULL
96041 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
96042 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
96043 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
96044 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
96045 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
96046 +read_9397 read 3 9397 NULL
96047 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
96048 +cfg80211_report_obss_beacon_9422 cfg80211_report_obss_beacon 3 9422 NULL
96049 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
96050 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
96051 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
96052 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
96053 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
96054 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
96055 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
96056 +rbd_coll_end_req_9472 rbd_coll_end_req 3 9472 NULL
96057 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
96058 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
96059 +lp_write_9511 lp_write 3 9511 NULL
96060 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
96061 +lm3533_update_9529 lm3533_update 2 9529 NULL
96062 +read_file_dma_9530 read_file_dma 3 9530 NULL
96063 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
96064 +tps65910_gpio_output_9539 tps65910_gpio_output 2 9539 NULL
96065 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
96066 +readl_9557 readl 0 9557 NULL
96067 +fw_node_create_9559 fw_node_create 2 9559 NULL
96068 +kobj_map_9566 kobj_map 2-3 9566 NULL
96069 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
96070 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
96071 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
96072 +do_sync_9604 do_sync 1 9604 NULL
96073 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
96074 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
96075 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
96076 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
96077 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
96078 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
96079 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
96080 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
96081 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
96082 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
96083 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
96084 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 NULL nohasharray
96085 +is_hole_9694 is_hole 2 9694 &x25_asy_compat_ioctl_9694
96086 +fnb_9703 fnb 2-3 9703 NULL
96087 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 NULL
96088 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
96089 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
96090 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
96091 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
96092 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
96093 +do_sigpending_9766 do_sigpending 2 9766 NULL
96094 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
96095 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
96096 +_regmap_write_9803 _regmap_write 2 9803 NULL
96097 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
96098 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
96099 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
96100 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
96101 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
96102 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
96103 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
96104 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
96105 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
96106 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
96107 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
96108 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
96109 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
96110 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
96111 +receive_DataRequest_9904 receive_DataRequest 3 9904 NULL
96112 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
96113 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
96114 +read_file_misc_9948 read_file_misc 3 9948 NULL
96115 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
96116 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
96117 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
96118 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
96119 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
96120 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
96121 +twl6040_clear_bits_9985 twl6040_clear_bits 2 9985 NULL
96122 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
96123 +handle_request_10024 handle_request 9 10024 NULL
96124 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
96125 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
96126 +rbd_coll_end_req_index_10041 rbd_coll_end_req_index 5 10041 NULL
96127 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
96128 +wm831x_gpio_direction_in_10099 wm831x_gpio_direction_in 2 10099 NULL
96129 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
96130 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
96131 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
96132 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
96133 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
96134 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
96135 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
96136 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
96137 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
96138 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
96139 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
96140 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
96141 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
96142 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
96143 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
96144 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
96145 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
96146 +lm3533_led_delay_set_10291 lm3533_led_delay_set 2 10291 NULL
96147 +read_emulate_10310 read_emulate 2-4 10310 NULL
96148 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
96149 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
96150 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
96151 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
96152 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
96153 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
96154 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
96155 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
96156 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
96157 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
96158 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
96159 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
96160 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
96161 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
96162 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
96163 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
96164 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
96165 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
96166 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
96167 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
96168 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
96169 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
96170 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
96171 +otp_read_10594 otp_read 2-4-5 10594 NULL
96172 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
96173 +mc13783_set_fmt_10616 mc13783_set_fmt 3 10616 NULL
96174 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
96175 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
96176 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
96177 +parport_write_10669 parport_write 0 10669 NULL
96178 +inl_10708 inl 0 10708 NULL nohasharray
96179 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
96180 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
96181 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
96182 +spi_sync_10731 spi_sync 0 10731 NULL
96183 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
96184 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
96185 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
96186 +sys_syslog_10746 sys_syslog 3 10746 NULL
96187 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
96188 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
96189 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
96190 +sys_bind_10799 sys_bind 3 10799 NULL
96191 +compat_put_int_10828 compat_put_int 1 10828 NULL
96192 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
96193 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
96194 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
96195 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
96196 +batadv_check_unicast_packet_10866 batadv_check_unicast_packet 2 10866 NULL
96197 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
96198 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
96199 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
96200 +get_scq_10897 get_scq 2 10897 NULL
96201 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
96202 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
96203 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
96204 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
96205 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
96206 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
96207 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
96208 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
96209 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
96210 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
96211 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
96212 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
96213 +nouveau_gpio_create__11048 nouveau_gpio_create_ 4 11048 NULL
96214 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
96215 +carl9170_handle_mpdu_11056 carl9170_handle_mpdu 3 11056 NULL
96216 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
96217 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
96218 +count_argc_11083 count_argc 0 11083 NULL
96219 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
96220 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
96221 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
96222 +page_offset_11120 page_offset 0 11120 NULL
96223 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
96224 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
96225 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
96226 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
96227 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
96228 +__swab16p_11220 __swab16p 0 11220 NULL
96229 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
96230 +of_irq_count_11253 of_irq_count 0 11253 NULL
96231 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
96232 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
96233 +cru_detect_11272 cru_detect 1 11272 NULL
96234 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
96235 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
96236 +construct_key_11329 construct_key 3 11329 NULL nohasharray
96237 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
96238 +next_segment_11330 next_segment 0-2-1 11330 NULL
96239 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
96240 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
96241 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
96242 +sel_write_create_11353 sel_write_create 3 11353 NULL
96243 +handle_unit_11355 handle_unit 0-1 11355 NULL
96244 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
96245 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
96246 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
96247 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
96248 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
96249 +str_to_user_11411 str_to_user 2 11411 NULL
96250 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
96251 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
96252 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
96253 +trace_options_read_11419 trace_options_read 3 11419 NULL
96254 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
96255 +prepare_image_11424 prepare_image 0 11424 NULL
96256 +vring_size_11426 vring_size 0-1-2 11426 NULL
96257 +bttv_read_11432 bttv_read 3 11432 NULL
96258 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
96259 +swp_offset_11475 swp_offset 0 11475 NULL
96260 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
96261 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
96262 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
96263 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
96264 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
96265 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
96266 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
96267 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
96268 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
96269 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
96270 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
96271 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
96272 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
96273 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
96274 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
96275 +da9055_gpio_direction_output_11680 da9055_gpio_direction_output 2 11680 NULL
96276 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
96277 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
96278 +split_11691 split 2 11691 NULL
96279 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
96280 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
96281 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
96282 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
96283 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
96284 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
96285 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
96286 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
96287 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
96288 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
96289 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
96290 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
96291 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
96292 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
96293 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
96294 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
96295 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
96296 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
96297 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
96298 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
96299 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
96300 +kvm_set_msr_common_11953 kvm_set_msr_common 3 11953 NULL
96301 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
96302 +atmel_read16_11981 atmel_read16 0 11981 NULL
96303 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
96304 +mwifiex_cfg80211_mgmt_tx_12022 mwifiex_cfg80211_mgmt_tx 9 12022 NULL
96305 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
96306 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
96307 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
96308 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
96309 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
96310 +da9052_gpio_direction_output_12120 da9052_gpio_direction_output 2 12120 NULL
96311 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
96312 +set_powered_12129 set_powered 4 12129 NULL
96313 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
96314 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
96315 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
96316 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
96317 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
96318 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
96319 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
96320 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
96321 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
96322 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
96323 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
96324 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
96325 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
96326 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
96327 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
96328 +receive_copy_12216 receive_copy 3 12216 NULL
96329 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
96330 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 NULL
96331 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
96332 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
96333 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
96334 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
96335 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
96336 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
96337 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
96338 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
96339 +split_bvec_12312 split_bvec 6 12312 NULL
96340 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
96341 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
96342 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
96343 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
96344 +receive_packet_12367 receive_packet 2 12367 NULL
96345 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
96346 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
96347 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL
96348 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
96349 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
96350 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
96351 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
96352 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
96353 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
96354 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
96355 +arizona_gpio_direction_out_12564 arizona_gpio_direction_out 2 12564 NULL
96356 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
96357 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
96358 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
96359 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
96360 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
96361 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
96362 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
96363 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
96364 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
96365 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
96366 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
96367 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
96368 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
96369 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
96370 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
96371 +ivtv_write_12721 ivtv_write 3 12721 NULL
96372 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
96373 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
96374 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
96375 +listxattr_12769 listxattr 3 12769 NULL
96376 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
96377 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
96378 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
96379 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
96380 +readq_12825 readq 0 12825 NULL
96381 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
96382 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 NULL nohasharray
96383 +spidev_sync_12842 spidev_sync 0 12842 &ath6kl_wmi_add_wow_pattern_cmd_12842
96384 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
96385 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
96386 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
96387 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
96388 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
96389 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
96390 +tps65910_reg_update_bits_12934 tps65910_reg_update_bits 2 12934 NULL
96391 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
96392 +bm_status_write_12964 bm_status_write 3 12964 NULL
96393 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
96394 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
96395 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
96396 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
96397 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
96398 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
96399 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
96400 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
96401 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
96402 +tps6586x_set_bits_13089 tps6586x_set_bits 2 13089 NULL
96403 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
96404 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
96405 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
96406 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
96407 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
96408 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
96409 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
96410 +blk_update_request_13146 blk_update_request 3 13146 NULL
96411 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
96412 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
96413 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
96414 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
96415 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
96416 +comedi_read_13199 comedi_read 3 13199 NULL
96417 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
96418 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
96419 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
96420 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
96421 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
96422 +fw_download_code_13249 fw_download_code 3 13249 NULL
96423 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
96424 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
96425 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
96426 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
96427 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
96428 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
96429 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
96430 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
96431 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
96432 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
96433 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
96434 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
96435 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
96436 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
96437 +sky2_receive_13407 sky2_receive 2 13407 NULL
96438 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
96439 +keyring_read_13438 keyring_read 3 13438 NULL
96440 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
96441 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
96442 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 7-8-9 13443 NULL
96443 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
96444 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
96445 +core_status_13515 core_status 4 13515 NULL
96446 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
96447 +bm_init_13529 bm_init 2 13529 NULL
96448 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
96449 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
96450 +alloc_tio_13564 alloc_tio 3 13564 NULL
96451 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
96452 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
96453 +pm860x_set_bits_13582 pm860x_set_bits 2 13582 NULL
96454 +cache_write_13589 cache_write 3 13589 NULL
96455 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
96456 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
96457 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
96458 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
96459 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
96460 +wm8994_bulk_write_13615 wm8994_bulk_write 3-2 13615 NULL
96461 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
96462 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
96463 +packet_snd_13634 packet_snd 3 13634 NULL
96464 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
96465 +cache_downcall_13666 cache_downcall 3 13666 NULL
96466 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
96467 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
96468 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
96469 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
96470 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
96471 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
96472 +random_read_13815 random_read 3 13815 NULL
96473 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
96474 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
96475 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
96476 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
96477 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
96478 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
96479 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
96480 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
96481 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
96482 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
96483 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
96484 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
96485 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
96486 +com90xx_found_13974 com90xx_found 3 13974 NULL
96487 +qcam_read_13977 qcam_read 3 13977 NULL
96488 +dsp_read_13980 dsp_read 2 13980 NULL
96489 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
96490 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
96491 +ieee80211_bss_info_update_13991 ieee80211_bss_info_update 4 13991 NULL
96492 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
96493 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
96494 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
96495 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
96496 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
96497 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
96498 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
96499 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
96500 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
96501 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
96502 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
96503 +em_canid_change_14150 em_canid_change 3 14150 NULL
96504 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
96505 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
96506 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
96507 +alloc_async_14208 alloc_async 1 14208 NULL
96508 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
96509 +pool_status_14230 pool_status 5 14230 NULL
96510 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
96511 +inode_to_path_14235 inode_to_path 2 14235 NULL
96512 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
96513 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 4-2 14245 NULL
96514 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
96515 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
96516 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
96517 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
96518 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
96519 +rr_status_14293 rr_status 5 14293 NULL
96520 +lp8788_write_byte_14299 lp8788_write_byte 2 14299 NULL
96521 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
96522 +oo_objects_14319 oo_objects 0 14319 NULL
96523 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
96524 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
96525 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
96526 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
96527 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
96528 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
96529 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
96530 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
96531 +block_size_14443 block_size 0 14443 NULL
96532 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
96533 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
96534 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
96535 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
96536 +stripe_status_14506 stripe_status 5 14506 NULL
96537 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
96538 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
96539 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
96540 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
96541 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
96542 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
96543 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
96544 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
96545 +dbJoin_14644 dbJoin 0 14644 NULL
96546 +profile_replace_14652 profile_replace 3 14652 NULL
96547 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
96548 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
96549 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
96550 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
96551 +vfd_write_14717 vfd_write 3 14717 NULL
96552 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
96553 +raid1_resize_14740 raid1_resize 2 14740 NULL
96554 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
96555 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
96556 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
96557 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
96558 +lm3533_als_get_hysteresis_14776 lm3533_als_get_hysteresis 2 14776 NULL
96559 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
96560 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
96561 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
96562 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
96563 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
96564 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
96565 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
96566 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
96567 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
96568 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
96569 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
96570 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
96571 +unifi_read_14899 unifi_read 3 14899 NULL
96572 +krealloc_14908 krealloc 2 14908 NULL
96573 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
96574 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL
96575 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
96576 +queue_cnt_14951 queue_cnt 0 14951 NULL
96577 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
96578 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
96579 +setkey_14987 setkey 3 14987 NULL nohasharray
96580 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
96581 +vmap_15025 vmap 2 15025 NULL
96582 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
96583 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
96584 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
96585 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
96586 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
96587 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
96588 +__alloc_extent_buffer_15093 __alloc_extent_buffer 3 15093 NULL
96589 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
96590 +start_port_15124 start_port 0 15124 NULL
96591 +memchr_15126 memchr 0 15126 NULL
96592 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
96593 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
96594 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
96595 +reserve_resources_15194 reserve_resources 3 15194 NULL
96596 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
96597 +variax_alloc_sysex_buffer_15237 variax_alloc_sysex_buffer 3 15237 NULL
96598 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
96599 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
96600 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
96601 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
96602 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
96603 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
96604 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
96605 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
96606 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
96607 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
96608 +ioread16_15342 ioread16 0 15342 NULL
96609 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
96610 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
96611 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
96612 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
96613 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
96614 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
96615 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
96616 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
96617 +get_modalias_15406 get_modalias 2 15406 NULL
96618 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
96619 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 0-2 15438 NULL
96620 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
96621 +memweight_15450 memweight 2 15450 NULL
96622 +vmalloc_15464 vmalloc 1 15464 NULL
96623 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
96624 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
96625 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
96626 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
96627 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
96628 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
96629 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
96630 +persistent_status_15574 persistent_status 4 15574 NULL
96631 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
96632 +vme_user_write_15587 vme_user_write 3 15587 NULL
96633 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
96634 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
96635 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
96636 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
96637 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
96638 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
96639 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
96640 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
96641 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
96642 +fs_path_add_15648 fs_path_add 3 15648 NULL
96643 +xsd_read_15653 xsd_read 3 15653 NULL
96644 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
96645 +unix_bind_15668 unix_bind 3 15668 NULL
96646 +dm_read_15674 dm_read 3 15674 NULL
96647 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
96648 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
96649 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
96650 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
96651 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
96652 +do_test_15766 do_test 1 15766 NULL
96653 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
96654 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
96655 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
96656 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
96657 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
96658 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
96659 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
96660 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
96661 +table_size_15851 table_size 0-1-2 15851 NULL
96662 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
96663 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
96664 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
96665 +ERR_PTR_15881 ERR_PTR 0 15881 NULL
96666 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
96667 +native_read_msr_15905 native_read_msr 0 15905 NULL
96668 +wm5100_gpio_direction_in_15934 wm5100_gpio_direction_in 2 15934 NULL
96669 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
96670 +power_read_15939 power_read 3 15939 NULL
96671 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
96672 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
96673 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
96674 +set_spte_15977 set_spte 7-6 15977 NULL
96675 +frame_alloc_15981 frame_alloc 4 15981 NULL
96676 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
96677 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
96678 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
96679 +got_frame_16028 got_frame 2 16028 NULL
96680 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
96681 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
96682 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
96683 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
96684 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
96685 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
96686 +fsm_init_16134 fsm_init 2 16134 NULL
96687 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
96688 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
96689 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
96690 +mapping_level_16188 mapping_level 2 16188 NULL
96691 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
96692 +create_table_16213 create_table 2 16213 NULL
96693 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
96694 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
96695 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 NULL
96696 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
96697 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
96698 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
96699 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
96700 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
96701 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
96702 +account_16283 account 0-2-4 16283 NULL nohasharray
96703 +mirror_status_16283 mirror_status 5 16283 &account_16283
96704 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
96705 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
96706 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
96707 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
96708 +tps80031_update_16360 tps80031_update 3 16360 NULL
96709 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
96710 +rbd_add_16366 rbd_add 3 16366 NULL
96711 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
96712 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
96713 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
96714 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
96715 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
96716 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
96717 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
96718 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
96719 +raid10_resize_16537 raid10_resize 2 16537 NULL
96720 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
96721 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
96722 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
96723 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
96724 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
96725 +da9052_reg_write_16685 da9052_reg_write 2 16685 NULL
96726 +em28xx_v4l2_read_16701 em28xx_v4l2_read 3 16701 NULL
96727 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
96728 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
96729 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
96730 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
96731 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
96732 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
96733 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
96734 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
96735 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
96736 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
96737 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
96738 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
96739 +st_write_16874 st_write 3 16874 NULL
96740 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
96741 +wm8350_set_bits_16911 wm8350_set_bits 2 16911 NULL
96742 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
96743 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
96744 +random32_16937 random32 0 16937 NULL
96745 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
96746 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
96747 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
96748 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
96749 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
96750 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
96751 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
96752 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
96753 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
96754 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
96755 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
96756 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
96757 +mac_address_string_17091 mac_address_string 0 17091 NULL
96758 +entry_length_17093 entry_length 0 17093 NULL
96759 +sys_preadv_17100 sys_preadv 3 17100 NULL
96760 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
96761 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
96762 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
96763 +sep_read_17161 sep_read 3 17161 NULL
96764 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
96765 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
96766 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
96767 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
96768 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
96769 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
96770 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
96771 +ms_rw_17220 ms_rw 3-4 17220 NULL
96772 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
96773 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
96774 +alloc_ep_17269 alloc_ep 1 17269 NULL
96775 +pg_read_17276 pg_read 3 17276 NULL
96776 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
96777 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
96778 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
96779 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
96780 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
96781 +skb_pad_17302 skb_pad 2 17302 NULL
96782 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
96783 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
96784 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
96785 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
96786 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
96787 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
96788 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
96789 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
96790 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
96791 +compat_cmd_17465 compat_cmd 2 17465 NULL
96792 +probe_bios_17467 probe_bios 1 17467 NULL
96793 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
96794 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
96795 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
96796 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
96797 +arizona_apply_fll_17538 arizona_apply_fll 2 17538 NULL
96798 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
96799 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
96800 +copy_from_user_17559 copy_from_user 3 17559 NULL
96801 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
96802 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
96803 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
96804 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
96805 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
96806 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
96807 +osst_execute_17607 osst_execute 7-6 17607 NULL
96808 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
96809 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
96810 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
96811 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
96812 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
96813 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
96814 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
96815 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
96816 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
96817 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
96818 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
96819 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
96820 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
96821 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL
96822 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
96823 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
96824 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
96825 +count_leafs_17842 count_leafs 0 17842 NULL
96826 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
96827 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
96828 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
96829 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
96830 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
96831 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
96832 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
96833 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
96834 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
96835 +wm8400_set_bits_17898 wm8400_set_bits 2 17898 NULL
96836 +recover_head_17904 recover_head 3 17904 NULL
96837 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
96838 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
96839 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
96840 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
96841 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
96842 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
96843 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
96844 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
96845 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
96846 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
96847 +prandom32_18007 prandom32 0 18007 NULL
96848 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
96849 +fill_read_18019 fill_read 0 18019 NULL
96850 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
96851 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
96852 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
96853 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
96854 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
96855 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
96856 +packet_came_18072 packet_came 3 18072 NULL
96857 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
96858 +get_vm_area_18080 get_vm_area 1 18080 NULL
96859 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
96860 +tps65910_gpio_input_18110 tps65910_gpio_input 2 18110 NULL
96861 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
96862 +svc_getnl_18120 svc_getnl 0 18120 NULL
96863 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
96864 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
96865 +tps65910_gpio_set_18135 tps65910_gpio_set 2 18135 NULL
96866 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
96867 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
96868 +_has_tag_18169 _has_tag 2 18169 NULL
96869 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
96870 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
96871 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
96872 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
96873 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
96874 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
96875 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
96876 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
96877 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
96878 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
96879 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
96880 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
96881 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
96882 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
96883 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
96884 +um_idi_write_18293 um_idi_write 3 18293 NULL
96885 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
96886 +vga_r_18310 vga_r 0 18310 NULL
96887 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
96888 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
96889 +wm8994_gpio_direction_out_18337 wm8994_gpio_direction_out 2 18337 NULL
96890 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
96891 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
96892 +ep_io_18367 ep_io 0 18367 NULL
96893 +lp872x_update_bits_18368 lp872x_update_bits 2 18368 NULL
96894 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 NULL
96895 +__video_register_device_18399 __video_register_device 3 18399 NULL
96896 +reada_tree_block_flagged_18402 reada_tree_block_flagged 3 18402 NULL nohasharray
96897 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &reada_tree_block_flagged_18402
96898 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
96899 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
96900 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
96901 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
96902 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
96903 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
96904 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
96905 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
96906 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
96907 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
96908 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
96909 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
96910 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
96911 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
96912 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
96913 +debug_output_18575 debug_output 3 18575 NULL
96914 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
96915 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
96916 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
96917 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
96918 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
96919 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
96920 +from_buffer_18625 from_buffer 3 18625 NULL
96921 +f1x_map_sysaddr_to_csrow_18628 f1x_map_sysaddr_to_csrow 2 18628 NULL
96922 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
96923 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
96924 +unmap_page_18665 unmap_page 2-3 18665 NULL
96925 +edge_tty_recv_18667 edge_tty_recv 4 18667 NULL nohasharray
96926 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 &edge_tty_recv_18667
96927 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
96928 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
96929 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
96930 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
96931 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
96932 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
96933 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
96934 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
96935 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
96936 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
96937 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
96938 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
96939 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
96940 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
96941 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
96942 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
96943 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
96944 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
96945 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
96946 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
96947 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
96948 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
96949 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
96950 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
96951 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
96952 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
96953 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
96954 +alc_auto_create_extra_outs_18975 alc_auto_create_extra_outs 2 18975 NULL
96955 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
96956 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
96957 +huge_page_size_19008 huge_page_size 0 19008 NULL
96958 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
96959 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
96960 +revalidate_19043 revalidate 2 19043 NULL
96961 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
96962 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
96963 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
96964 +copy_and_check_19089 copy_and_check 3 19089 NULL
96965 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
96966 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
96967 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
96968 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
96969 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
96970 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
96971 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
96972 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
96973 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
96974 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
96975 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
96976 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
96977 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
96978 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
96979 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
96980 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
96981 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
96982 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
96983 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
96984 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
96985 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
96986 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
96987 +qc_capture_19298 qc_capture 3 19298 NULL
96988 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
96989 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
96990 +debug_read_19322 debug_read 3 19322 NULL
96991 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
96992 +read_zero_19366 read_zero 3 19366 NULL
96993 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
96994 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
96995 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
96996 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
96997 +__phys_addr_19434 __phys_addr 0 19434 NULL
96998 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
96999 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
97000 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
97001 +sky2_read16_19475 sky2_read16 0 19475 NULL
97002 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
97003 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
97004 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
97005 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
97006 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
97007 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
97008 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
97009 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
97010 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
97011 +nfsd_read_19568 nfsd_read 5 19568 NULL
97012 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
97013 +bm_status_read_19583 bm_status_read 3 19583 NULL
97014 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
97015 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
97016 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
97017 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
97018 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
97019 +read_reg_19723 read_reg 0 19723 NULL
97020 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
97021 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
97022 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
97023 +p9_client_read_19750 p9_client_read 5 19750 NULL
97024 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
97025 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
97026 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
97027 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
97028 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
97029 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
97030 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
97031 +vip_read_19832 vip_read 3 19832 NULL nohasharray
97032 +vfs_getxattr_19832 vfs_getxattr 0 19832 &vip_read_19832
97033 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
97034 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
97035 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
97036 +__nla_put_19857 __nla_put 3 19857 NULL
97037 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
97038 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
97039 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
97040 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
97041 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
97042 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
97043 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
97044 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
97045 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
97046 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
97047 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
97048 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
97049 +team_options_register_20091 team_options_register 3 20091 NULL
97050 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
97051 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
97052 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
97053 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
97054 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
97055 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
97056 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
97057 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
97058 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
97059 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
97060 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
97061 +resource_size_20256 resource_size 0 20256 NULL
97062 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
97063 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
97064 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
97065 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
97066 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
97067 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
97068 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
97069 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
97070 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
97071 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
97072 +pm860x_write_reg_cache_20448 pm860x_write_reg_cache 2 20448 NULL
97073 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
97074 +ip_vs_icmp_xmit_v6_20464 ip_vs_icmp_xmit_v6 4 20464 NULL
97075 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
97076 +read_buf_20469 read_buf 2 20469 NULL
97077 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
97078 +fast_user_write_20494 fast_user_write 5 20494 NULL
97079 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
97080 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
97081 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
97082 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
97083 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
97084 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
97085 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
97086 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
97087 +venus_create_20555 venus_create 4 20555 NULL
97088 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
97089 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
97090 +rc5t583_set_bits_20573 rc5t583_set_bits 2 20573 NULL
97091 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
97092 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
97093 +lirc_write_20604 lirc_write 3 20604 NULL
97094 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
97095 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
97096 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
97097 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
97098 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
97099 +ceph_osdc_new_request_20654 ceph_osdc_new_request 15-4 20654 NULL
97100 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
97101 +sec_reg_write_20667 sec_reg_write 2 20667 NULL
97102 +tps65910_reg_clear_bits_20672 tps65910_reg_clear_bits 2 20672 NULL
97103 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
97104 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
97105 +cpumask_size_20683 cpumask_size 0 20683 NULL
97106 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
97107 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
97108 +__maestro_read_20700 __maestro_read 0 20700 NULL
97109 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
97110 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
97111 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
97112 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
97113 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
97114 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
97115 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
97116 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
97117 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
97118 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
97119 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
97120 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
97121 +sys_sendto_20809 sys_sendto 6 20809 NULL
97122 +strndup_user_20819 strndup_user 2 20819 NULL
97123 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
97124 +uvc_alloc_entity_20836 uvc_alloc_entity 4-3 20836 NULL
97125 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
97126 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
97127 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
97128 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
97129 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
97130 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
97131 +htable_bits_20933 htable_bits 0 20933 NULL
97132 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
97133 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
97134 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
97135 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
97136 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
97137 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
97138 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
97139 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
97140 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
97141 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
97142 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
97143 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
97144 +multipath_status_21094 multipath_status 5 21094 NULL
97145 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
97146 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
97147 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
97148 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
97149 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
97150 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
97151 +ath6kl_mgmt_tx_21153 ath6kl_mgmt_tx 9 21153 NULL
97152 +setup_msi_irq_21169 setup_msi_irq 3 21169 NULL
97153 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
97154 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
97155 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
97156 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
97157 +input_ff_create_21240 input_ff_create 2 21240 NULL
97158 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
97159 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
97160 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
97161 +rc5t583_clear_bits_21300 rc5t583_clear_bits 2 21300 NULL
97162 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
97163 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
97164 +add_res_range_21310 add_res_range 4 21310 NULL
97165 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
97166 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
97167 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
97168 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
97169 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
97170 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
97171 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
97172 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
97173 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
97174 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
97175 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
97176 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
97177 +btrfs_iref_to_path_21445 btrfs_iref_to_path 7 21445 NULL
97178 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
97179 +concat_writev_21451 concat_writev 3 21451 NULL
97180 +extend_netdev_table_21453 extend_netdev_table 2 21453 NULL
97181 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
97182 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
97183 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
97184 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
97185 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
97186 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
97187 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
97188 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
97189 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
97190 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
97191 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
97192 +rbd_req_sync_op_21632 rbd_req_sync_op 7-8 21632 NULL
97193 +validate_nnode_21638 validate_nnode 0 21638 NULL
97194 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
97195 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
97196 +hpet_setup_msi_irq_21662 hpet_setup_msi_irq 1 21662 NULL
97197 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
97198 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
97199 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
97200 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
97201 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
97202 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
97203 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
97204 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
97205 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
97206 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
97207 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
97208 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
97209 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
97210 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
97211 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
97212 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
97213 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
97214 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
97215 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
97216 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
97217 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
97218 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
97219 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
97220 +rbd_req_read_21952 rbd_req_read 4-5 21952 NULL
97221 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
97222 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
97223 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
97224 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
97225 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
97226 +ti_recv_22027 ti_recv 4 22027 NULL
97227 +pcf50633_irq_unmask_22034 pcf50633_irq_unmask 2 22034 NULL
97228 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
97229 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
97230 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
97231 +mem_rw_22085 mem_rw 3 22085 NULL
97232 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
97233 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
97234 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
97235 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
97236 +compat_insn_22142 compat_insn 2 22142 NULL
97237 +pn533_dep_link_up_22154 pn533_dep_link_up 5 22154 NULL
97238 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
97239 +__kfifo_alloc_22173 __kfifo_alloc 2-3 22173 NULL
97240 +fls_22210 fls 0 22210 NULL
97241 +bio_chain_clone_22227 bio_chain_clone 4 22227 NULL
97242 +mem_write_22232 mem_write 3 22232 NULL
97243 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
97244 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
97245 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
97246 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
97247 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
97248 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
97249 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
97250 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
97251 +get_segment_base_22324 get_segment_base 0 22324 NULL
97252 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
97253 +atomic_read_22342 atomic_read 0 22342 NULL
97254 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
97255 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL
97256 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
97257 +wlcore_alloc_hw_22365 wlcore_alloc_hw 1 22365 NULL nohasharray
97258 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 &wlcore_alloc_hw_22365
97259 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
97260 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
97261 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
97262 +zoran_write_22404 zoran_write 3 22404 NULL
97263 +queue_reply_22416 queue_reply 3 22416 NULL
97264 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
97265 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
97266 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
97267 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
97268 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
97269 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
97270 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
97271 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
97272 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
97273 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
97274 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
97275 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
97276 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
97277 +snapshot_read_22601 snapshot_read 3 22601 NULL
97278 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
97279 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
97280 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
97281 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
97282 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
97283 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
97284 +fill_gap_22681 fill_gap 0 22681 NULL
97285 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
97286 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
97287 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
97288 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
97289 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
97290 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
97291 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
97292 +print_frame_22769 print_frame 0 22769 NULL
97293 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
97294 +retu_write_22800 retu_write 2 22800 NULL
97295 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
97296 +can_nocow_odirect_22854 can_nocow_odirect 3 22854 NULL nohasharray
97297 +read_file_rcstat_22854 read_file_rcstat 3 22854 &can_nocow_odirect_22854
97298 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
97299 +nfs4_realloc_slot_table_22859 nfs4_realloc_slot_table 2 22859 NULL
97300 +create_attr_set_22861 create_attr_set 1 22861 NULL
97301 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
97302 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
97303 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
97304 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
97305 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
97306 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
97307 +vme_get_size_22964 vme_get_size 0 22964 NULL
97308 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
97309 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
97310 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
97311 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
97312 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
97313 +st_status_23032 st_status 5 23032 NULL
97314 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
97315 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
97316 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
97317 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
97318 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
97319 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
97320 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
97321 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
97322 +fls_long_23096 fls_long 0 23096 NULL
97323 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
97324 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
97325 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
97326 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
97327 +__clear_user_23118 __clear_user 0 23118 NULL
97328 +dm_write_async_23120 dm_write_async 3 23120 NULL
97329 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
97330 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
97331 +wm831x_set_bits_23158 wm831x_set_bits 2 23158 NULL
97332 +read_file_ani_23161 read_file_ani 3 23161 NULL
97333 +ioremap_23172 ioremap 1-2 23172 NULL
97334 +usblp_write_23178 usblp_write 3 23178 NULL
97335 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
97336 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
97337 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
97338 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
97339 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
97340 +__next_dma_cap_23195 __next_dma_cap 1 23195 NULL
97341 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
97342 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
97343 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
97344 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
97345 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
97346 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
97347 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
97348 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
97349 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
97350 +doc_probe_23285 doc_probe 1 23285 NULL
97351 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
97352 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
97353 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
97354 +page_readlink_23346 page_readlink 3 23346 NULL
97355 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
97356 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
97357 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
97358 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
97359 +__cxio_init_resource_fifo_23447 __cxio_init_resource_fifo 3 23447 NULL nohasharray
97360 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 &__cxio_init_resource_fifo_23447
97361 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
97362 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
97363 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
97364 +event_filter_read_23494 event_filter_read 3 23494 NULL
97365 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
97366 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
97367 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
97368 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
97369 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
97370 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
97371 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
97372 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
97373 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
97374 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
97375 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
97376 +sInW_23663 sInW 0 23663 NULL
97377 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
97378 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
97379 +cx18_read_23699 cx18_read 3 23699 NULL
97380 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
97381 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
97382 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
97383 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
97384 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
97385 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
97386 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
97387 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
97388 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
97389 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
97390 +p54_init_common_23850 p54_init_common 1 23850 NULL
97391 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
97392 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
97393 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
97394 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
97395 +ieee80211_if_read_channel_type_23884 ieee80211_if_read_channel_type 3 23884 NULL
97396 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
97397 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
97398 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
97399 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
97400 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
97401 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
97402 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
97403 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
97404 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
97405 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
97406 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
97407 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
97408 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
97409 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
97410 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
97411 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
97412 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
97413 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
97414 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
97415 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
97416 +ieee80211_send_auth_24121 ieee80211_send_auth 5 24121 NULL
97417 +mpu401_read_24126 mpu401_read 3 24126 NULL
97418 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
97419 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
97420 +adu_read_24177 adu_read 3 24177 NULL
97421 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
97422 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
97423 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
97424 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
97425 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
97426 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
97427 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
97428 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
97429 +thin_status_24278 thin_status 5 24278 NULL
97430 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
97431 +msg_size_24288 msg_size 0 24288 NULL
97432 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
97433 +map_page_24298 map_page 3-4 24298 NULL
97434 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
97435 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
97436 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
97437 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
97438 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
97439 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
97440 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
97441 +igetword_24373 igetword 0 24373 NULL
97442 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
97443 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
97444 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
97445 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
97446 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
97447 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
97448 +smk_user_access_24440 smk_user_access 3 24440 NULL
97449 +page_address_24444 page_address 0 24444 NULL
97450 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
97451 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
97452 +pd_video_read_24510 pd_video_read 3 24510 NULL
97453 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
97454 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
97455 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
97456 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
97457 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
97458 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
97459 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
97460 +palmas_smps_write_24600 palmas_smps_write 2 24600 NULL nohasharray
97461 +count_preds_24600 count_preds 0 24600 &palmas_smps_write_24600
97462 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
97463 +context_alloc_24645 context_alloc 3 24645 NULL
97464 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
97465 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
97466 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
97467 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
97468 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
97469 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
97470 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
97471 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
97472 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
97473 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
97474 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
97475 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
97476 +cache_read_24790 cache_read 3 24790 NULL
97477 +unpack_str_24798 unpack_str 0 24798 NULL
97478 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
97479 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
97480 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
97481 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
97482 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
97483 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
97484 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
97485 +queues_read_24877 queues_read 3 24877 NULL
97486 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
97487 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
97488 +next_token_24929 next_token 0 24929 NULL
97489 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
97490 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
97491 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
97492 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
97493 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
97494 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
97495 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
97496 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
97497 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
97498 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
97499 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
97500 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
97501 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
97502 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL
97503 +cxio_hal_init_rhdl_resource_25104 cxio_hal_init_rhdl_resource 1 25104 NULL
97504 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
97505 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
97506 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
97507 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
97508 +mmu_set_spte_25177 mmu_set_spte 8-9 25177 NULL
97509 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
97510 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
97511 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
97512 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
97513 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
97514 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
97515 +stripe_status_25259 stripe_status 5 25259 NULL
97516 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
97517 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
97518 +vfs_writev_25278 vfs_writev 3 25278 NULL
97519 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
97520 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
97521 +help_25316 help 5 25316 NULL nohasharray
97522 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
97523 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
97524 +i915_gem_execbuffer_relocate_slow_25355 i915_gem_execbuffer_relocate_slow 7 25355 NULL
97525 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
97526 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
97527 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
97528 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
97529 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
97530 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
97531 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
97532 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
97533 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
97534 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
97535 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
97536 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
97537 +sb_permission_25523 sb_permission 0 25523 NULL
97538 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
97539 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
97540 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
97541 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
97542 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
97543 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
97544 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
97545 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
97546 +__get_user_pages_25628 __get_user_pages 0 25628 NULL nohasharray
97547 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
97548 +__direct_map_25647 __direct_map 5-6 25647 NULL
97549 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
97550 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
97551 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
97552 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
97553 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
97554 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
97555 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
97556 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
97557 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
97558 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
97559 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
97560 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
97561 +sg_read_25799 sg_read 3 25799 NULL
97562 +sys32_rt_sigpending_25814 sys32_rt_sigpending 2 25814 NULL
97563 +system_enable_read_25815 system_enable_read 3 25815 NULL
97564 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
97565 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
97566 +parport_read_25855 parport_read 0 25855 NULL
97567 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
97568 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
97569 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
97570 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
97571 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
97572 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
97573 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
97574 +utf16_strlen_25913 utf16_strlen 0 25913 NULL
97575 +rcname_read_25919 rcname_read 3 25919 NULL
97576 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
97577 +key_flags_read_25931 key_flags_read 3 25931 NULL
97578 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
97579 +tps80031_clr_bits_25942 tps80031_clr_bits 3 25942 NULL
97580 +flush_25957 flush 2 25957 NULL
97581 +video_register_device_25971 video_register_device 3 25971 NULL
97582 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
97583 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
97584 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
97585 +mirror_status_26010 mirror_status 5 26010 NULL
97586 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
97587 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
97588 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
97589 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
97590 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
97591 +tun_do_read_26047 tun_do_read 5 26047 NULL
97592 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
97593 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
97594 +cpumask_next_26096 cpumask_next 1 26096 NULL
97595 +skb_cow_26138 skb_cow 2 26138 NULL
97596 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
97597 +__fswab64_26155 __fswab64 0 26155 NULL
97598 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
97599 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
97600 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
97601 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
97602 +disk_devt_26180 disk_devt 0 26180 NULL
97603 +get_registers_26187 get_registers 3 26187 NULL
97604 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
97605 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
97606 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
97607 +mce_write_26201 mce_write 3 26201 NULL
97608 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
97609 +cxio_num_stags_26233 cxio_num_stags 0 26233 NULL
97610 +bio_split_26235 bio_split 2 26235 NULL
97611 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
97612 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
97613 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
97614 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
97615 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
97616 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
97617 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
97618 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
97619 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
97620 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
97621 +virtio_has_feature_26467 virtio_has_feature 0 26467 NULL
97622 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
97623 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
97624 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
97625 +read_vmcore_26501 read_vmcore 3 26501 NULL
97626 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
97627 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
97628 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
97629 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
97630 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
97631 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
97632 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
97633 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
97634 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
97635 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
97636 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
97637 +mmap_region_26649 mmap_region 0-2 26649 NULL
97638 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
97639 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
97640 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
97641 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
97642 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
97643 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
97644 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
97645 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
97646 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
97647 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
97648 +ntfs_are_rl_mergeable_26777 ntfs_are_rl_mergeable 0 26777 NULL
97649 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
97650 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
97651 +smk_write_load_26829 smk_write_load 3 26829 NULL
97652 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
97653 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
97654 +scnprint_id_26842 scnprint_id 3 26842 NULL
97655 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
97656 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
97657 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
97658 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
97659 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
97660 +wm8994_reg_write_26919 wm8994_reg_write 2 26919 NULL
97661 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
97662 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
97663 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
97664 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
97665 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
97666 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
97667 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
97668 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
97669 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
97670 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
97671 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
97672 +rbd_do_op_27025 rbd_do_op 7-8 27025 NULL
97673 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
97674 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
97675 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
97676 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
97677 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
97678 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
97679 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
97680 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
97681 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
97682 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
97683 +pms_capture_27142 pms_capture 4 27142 NULL
97684 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
97685 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
97686 +mc13xxx_irq_handle_27166 mc13xxx_irq_handle 3 27166 NULL
97687 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
97688 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
97689 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
97690 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
97691 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
97692 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
97693 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
97694 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
97695 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
97696 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
97697 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
97698 +rbd_req_sync_exec_27320 rbd_req_sync_exec 8 27320 NULL
97699 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
97700 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
97701 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
97702 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
97703 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
97704 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
97705 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
97706 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
97707 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
97708 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
97709 +tps65910_reg_set_bits_27468 tps65910_reg_set_bits 2 27468 NULL
97710 +rtsx_write_cfg_seq_27485 rtsx_write_cfg_seq 5-3 27485 NULL
97711 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
97712 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
97713 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
97714 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
97715 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
97716 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
97717 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
97718 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
97719 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
97720 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
97721 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
97722 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
97723 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
97724 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
97725 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
97726 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
97727 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
97728 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
97729 +qword_get_27670 qword_get 0 27670 NULL
97730 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
97731 +__tty_buffer_request_room_27700 __tty_buffer_request_room 2 27700 NULL
97732 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
97733 +evm_write_key_27715 evm_write_key 3 27715 NULL
97734 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
97735 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
97736 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
97737 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
97738 +kcalloc_27770 kcalloc 1-2 27770 NULL
97739 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
97740 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
97741 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
97742 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
97743 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
97744 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
97745 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
97746 +read_profile_27859 read_profile 3 27859 NULL
97747 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
97748 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
97749 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
97750 +gluebi_write_27905 gluebi_write 3 27905 NULL
97751 +mc13783_set_sysclk_27914 mc13783_set_sysclk 5 27914 NULL
97752 +bm_find_next_27929 bm_find_next 2 27929 NULL
97753 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
97754 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
97755 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
97756 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
97757 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
97758 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
97759 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
97760 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
97761 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
97762 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
97763 +pool_status_28055 pool_status 5 28055 NULL
97764 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
97765 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
97766 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
97767 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
97768 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
97769 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
97770 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
97771 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
97772 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
97773 +video_read_28148 video_read 3 28148 NULL
97774 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
97775 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
97776 +vread_28173 vread 0 28173 NULL
97777 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
97778 +d_path_28198 d_path 0 28198 NULL
97779 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
97780 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
97781 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
97782 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
97783 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
97784 +usemap_size_28281 usemap_size 0 28281 NULL
97785 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
97786 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
97787 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
97788 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
97789 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
97790 +snapshot_write_28351 snapshot_write 3 28351 NULL
97791 +__next_wq_cpu_28352 __next_wq_cpu 1 28352 NULL
97792 +sys_writev_28384 sys_writev 3 28384 NULL
97793 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
97794 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
97795 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
97796 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
97797 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
97798 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
97799 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
97800 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
97801 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
97802 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
97803 +max_response_pages_28492 max_response_pages 0 28492 NULL
97804 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
97805 +__next_node_28521 __next_node 1 28521 NULL
97806 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
97807 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
97808 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
97809 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
97810 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
97811 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
97812 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
97813 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
97814 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
97815 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
97816 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
97817 +wm8350_clear_bits_28596 wm8350_clear_bits 2 28596 NULL
97818 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
97819 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
97820 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
97821 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
97822 +_set_range_28627 _set_range 3 28627 NULL
97823 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
97824 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
97825 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
97826 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
97827 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
97828 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
97829 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
97830 +spi_execute_28736 spi_execute 5 28736 NULL
97831 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
97832 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
97833 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
97834 +cxio_init_resource_fifo_28764 cxio_init_resource_fifo 3 28764 NULL
97835 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
97836 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
97837 +sel_write_member_28800 sel_write_member 3 28800 NULL
97838 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
97839 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0-8-3 28809 NULL
97840 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
97841 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
97842 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
97843 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
97844 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
97845 +tps6586x_update_28898 tps6586x_update 2 28898 NULL
97846 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
97847 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
97848 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
97849 +push_rx_28939 push_rx 3 28939 NULL
97850 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
97851 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
97852 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
97853 +bin_uuid_28999 bin_uuid 3 28999 NULL
97854 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
97855 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
97856 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
97857 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
97858 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
97859 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
97860 +ieee80211_probereq_get_29069 ieee80211_probereq_get 4-6 29069 NULL
97861 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
97862 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
97863 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
97864 +snprintf_29125 snprintf 0 29125 NULL
97865 +iov_shorten_29130 iov_shorten 0 29130 NULL
97866 +pm860x_reg_write_29141 pm860x_reg_write 2 29141 NULL
97867 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
97868 +reshape_ring_29147 reshape_ring 2 29147 NULL
97869 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
97870 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
97871 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
97872 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
97873 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
97874 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
97875 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
97876 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
97877 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
97878 +recover_peb_29238 recover_peb 6-7 29238 NULL
97879 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
97880 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
97881 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
97882 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
97883 +fd_do_writev_29329 fd_do_writev 3 29329 NULL
97884 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
97885 +tun_put_user_29337 tun_put_user 5 29337 NULL
97886 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
97887 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
97888 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
97889 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
97890 +mempool_create_29437 mempool_create 1 29437 NULL
97891 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
97892 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
97893 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
97894 +do_register_entry_29478 do_register_entry 4 29478 NULL
97895 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
97896 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
97897 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
97898 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
97899 +ftrace_write_29551 ftrace_write 3 29551 NULL
97900 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
97901 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
97902 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
97903 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
97904 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
97905 +wm8903_gpio_set_29597 wm8903_gpio_set 2 29597 NULL
97906 +slots_per_page_29601 slots_per_page 0 29601 NULL
97907 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
97908 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
97909 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
97910 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
97911 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
97912 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
97913 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
97914 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
97915 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
97916 +probes_write_29711 probes_write 3 29711 NULL
97917 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
97918 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
97919 +da9055_gpio_direction_input_29742 da9055_gpio_direction_input 2 29742 NULL
97920 +cxio_hal_init_resource_29771 cxio_hal_init_resource 2-6-7 29771 NULL nohasharray
97921 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 &cxio_hal_init_resource_29771
97922 +dbAlloc_29794 dbAlloc 0 29794 NULL
97923 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
97924 +arizona_gpio_set_29823 arizona_gpio_set 2 29823 NULL
97925 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
97926 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
97927 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
97928 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
97929 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
97930 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
97931 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
97932 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
97933 +tps6586x_write_29894 tps6586x_write 2 29894 NULL
97934 +check586_29914 check586 2 29914 NULL
97935 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
97936 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
97937 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
97938 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
97939 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
97940 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
97941 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
97942 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
97943 +drp_wmove_30043 drp_wmove 4 30043 NULL
97944 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
97945 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
97946 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
97947 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
97948 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
97949 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
97950 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
97951 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
97952 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
97953 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
97954 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
97955 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
97956 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
97957 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
97958 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
97959 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
97960 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
97961 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
97962 +compat_readv_30273 compat_readv 3 30273 NULL
97963 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
97964 +__be64_to_cpup_30283 __be64_to_cpup 0 30283 NULL
97965 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
97966 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
97967 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
97968 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
97969 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
97970 +resource_from_user_30341 resource_from_user 3 30341 NULL
97971 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
97972 +sys_get_mempolicy_30379 sys_get_mempolicy 3 30379 NULL
97973 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
97974 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
97975 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
97976 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
97977 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
97978 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
97979 +enable_write_30456 enable_write 3 30456 NULL
97980 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
97981 +urandom_read_30462 urandom_read 3 30462 NULL
97982 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
97983 +write_head_30481 write_head 4 30481 NULL
97984 +adu_write_30487 adu_write 3 30487 NULL
97985 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
97986 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
97987 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
97988 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
97989 +set_le_30581 set_le 4 30581 NULL
97990 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
97991 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
97992 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL
97993 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
97994 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
97995 +nfsd_nrpools_30651 nfsd_nrpools 0 30651 NULL
97996 +agp_remap_30665 agp_remap 2 30665 NULL
97997 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
97998 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
97999 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
98000 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
98001 +snapshot_status_30744 snapshot_status 5 30744 NULL
98002 +max77693_update_reg_30747 max77693_update_reg 2 30747 NULL
98003 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
98004 +wm8350_read_auxadc_30780 wm8350_read_auxadc 2 30780 NULL
98005 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
98006 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
98007 +create_subvol_30836 create_subvol 4 30836 NULL
98008 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
98009 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL nohasharray
98010 +twl6040_set_bits_30844 twl6040_set_bits 2 30844 &cfg80211_rx_mgmt_30844
98011 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
98012 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
98013 +f1x_match_to_this_node_30888 f1x_match_to_this_node 3 30888 NULL
98014 +regmap_update_bits_check_30894 regmap_update_bits_check 2 30894 NULL
98015 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
98016 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
98017 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
98018 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
98019 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
98020 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
98021 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
98022 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
98023 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
98024 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
98025 +sys_mincore_31079 sys_mincore 1 31079 NULL
98026 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
98027 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
98028 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
98029 +depth_read_31112 depth_read 3 31112 NULL
98030 +ssb_read16_31139 ssb_read16 0 31139 NULL
98031 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
98032 +size_inside_page_31141 size_inside_page 0 31141 NULL
98033 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
98034 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
98035 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
98036 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
98037 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
98038 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
98039 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
98040 +__read_reg_31216 __read_reg 0 31216 NULL
98041 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
98042 +cyy_readb_31240 cyy_readb 0 31240 NULL
98043 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
98044 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
98045 +ceph_copy_page_vector_to_user_31270 ceph_copy_page_vector_to_user 3-4 31270 NULL
98046 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
98047 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
98048 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
98049 +futex_uaddr_31316 futex_uaddr 2 31316 NULL
98050 +command_file_write_31318 command_file_write 3 31318 NULL
98051 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
98052 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
98053 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3 31374 NULL
98054 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
98055 +inb_31388 inb 0 31388 NULL
98056 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
98057 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
98058 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
98059 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
98060 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
98061 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
98062 +_regmap_update_bits_31456 _regmap_update_bits 2 31456 NULL
98063 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
98064 +do_fcntl_31468 do_fcntl 3 31468 NULL
98065 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
98066 +alg_setkey_31485 alg_setkey 3 31485 NULL
98067 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
98068 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
98069 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
98070 +hidraw_write_31536 hidraw_write 3 31536 NULL
98071 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
98072 +usbvision_read_31555 usbvision_read 3 31555 NULL
98073 +normalize_31566 normalize 0-1-2 31566 NULL
98074 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
98075 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
98076 +osst_write_31581 osst_write 3 31581 NULL
98077 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
98078 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
98079 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
98080 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
98081 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
98082 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
98083 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
98084 +__lgread_31668 __lgread 4 31668 NULL
98085 +symbol_string_31670 symbol_string 0 31670 NULL
98086 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
98087 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
98088 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
98089 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
98090 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL
98091 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
98092 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
98093 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
98094 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
98095 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
98096 +lm3533_led_get_pattern_reg_31752 lm3533_led_get_pattern_reg 0-2 31752 NULL
98097 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
98098 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
98099 +get_count_order_31800 get_count_order 0 31800 NULL
98100 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
98101 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
98102 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
98103 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
98104 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
98105 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
98106 +xattr_permission_31907 xattr_permission 0 31907 NULL
98107 +new_dir_31919 new_dir 3 31919 NULL
98108 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
98109 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
98110 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
98111 +vb2_write_31948 vb2_write 3 31948 NULL
98112 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
98113 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
98114 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
98115 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
98116 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
98117 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
98118 +calc_hmac_32010 calc_hmac 3 32010 NULL
98119 +aead_len_32021 aead_len 0 32021 NULL
98120 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
98121 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
98122 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
98123 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
98124 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
98125 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
98126 +bio_alloc_32095 bio_alloc 2 32095 NULL
98127 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
98128 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
98129 +disk_status_32120 disk_status 4 32120 NULL
98130 +rc5t583_write_32124 rc5t583_write 2 32124 NULL
98131 +venus_link_32165 venus_link 5 32165 NULL
98132 +drbd_new_dev_size_32171 drbd_new_dev_size 0 32171 NULL
98133 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
98134 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
98135 +load_header_32183 load_header 0 32183 NULL
98136 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
98137 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
98138 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
98139 +lm3533_write_32236 lm3533_write 2 32236 NULL
98140 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
98141 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
98142 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
98143 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
98144 +hex_string_32310 hex_string 0 32310 NULL
98145 +flakey_status_32315 flakey_status 5 32315 NULL
98146 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
98147 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
98148 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
98149 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
98150 +f1x_translate_sysaddr_to_cs_32359 f1x_translate_sysaddr_to_cs 2 32359 NULL
98151 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
98152 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
98153 +variax_set_raw2_32374 variax_set_raw2 4 32374 NULL
98154 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
98155 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
98156 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
98157 +log_text_32428 log_text 0 32428 NULL
98158 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
98159 +hid_input_report_32458 hid_input_report 4 32458 NULL
98160 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
98161 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
98162 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
98163 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
98164 +disconnect_32521 disconnect 4 32521 NULL
98165 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
98166 +ilo_read_32531 ilo_read 3 32531 NULL
98167 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL nohasharray
98168 +crypt_status_32533 crypt_status 5 32533 &ieee80211_if_read_estab_plinks_32533
98169 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
98170 +__first_node_32558 __first_node 0 32558 NULL
98171 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
98172 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
98173 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
98174 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
98175 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
98176 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
98177 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
98178 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
98179 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
98180 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
98181 +kvmalloc_32646 kvmalloc 1 32646 NULL
98182 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
98183 +generic_readlink_32654 generic_readlink 3 32654 NULL
98184 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
98185 +tps80031_set_bits_32686 tps80031_set_bits 3 32686 NULL
98186 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
98187 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
98188 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
98189 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
98190 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
98191 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
98192 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
98193 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
98194 +vga_rseq_32848 vga_rseq 0 32848 NULL
98195 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
98196 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
98197 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
98198 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
98199 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
98200 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
98201 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
98202 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
98203 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
98204 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
98205 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
98206 +compat_filldir_32999 compat_filldir 3 32999 NULL
98207 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
98208 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
98209 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
98210 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
98211 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
98212 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
98213 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
98214 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
98215 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
98216 +write_node_33121 write_node 4 33121 NULL
98217 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
98218 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
98219 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
98220 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
98221 +pp_read_33210 pp_read 3 33210 NULL
98222 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
98223 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
98224 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
98225 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
98226 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
98227 +pcf50633_irq_mask_33280 pcf50633_irq_mask 2 33280 NULL
98228 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
98229 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
98230 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
98231 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
98232 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
98233 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
98234 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
98235 +ceph_osdc_writepages_33375 ceph_osdc_writepages 5 33375 NULL
98236 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
98237 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
98238 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
98239 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
98240 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
98241 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
98242 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
98243 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
98244 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
98245 +create_entry_33479 create_entry 2 33479 NULL
98246 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
98247 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
98248 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
98249 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
98250 +res_counter_read_33499 res_counter_read 4 33499 NULL
98251 +fb_read_33506 fb_read 3 33506 NULL
98252 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
98253 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
98254 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
98255 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
98256 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
98257 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
98258 +dup_array_33551 dup_array 3 33551 NULL
98259 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
98260 +count_subheaders_33591 count_subheaders 0 33591 NULL
98261 +scsi_execute_33596 scsi_execute 5 33596 NULL
98262 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
98263 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
98264 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
98265 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 NULL
98266 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
98267 +inw_p_33668 inw_p 0 33668 NULL
98268 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
98269 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
98270 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
98271 +rbd_alloc_coll_33678 rbd_alloc_coll 1 33678 NULL
98272 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
98273 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
98274 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
98275 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
98276 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
98277 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
98278 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
98279 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
98280 +Read_hfc_33755 Read_hfc 0 33755 NULL
98281 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
98282 +hashtab_create_33769 hashtab_create 3 33769 NULL
98283 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
98284 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
98285 +find_next_offset_33804 find_next_offset 3 33804 NULL
98286 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
98287 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
98288 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
98289 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
98290 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
98291 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
98292 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
98293 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
98294 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
98295 +config_proc_write_33878 config_proc_write 3 33878 NULL
98296 +get_user_pages_33908 get_user_pages 0 33908 NULL
98297 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
98298 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
98299 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
98300 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
98301 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
98302 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
98303 +ppp_write_34034 ppp_write 3 34034 NULL
98304 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
98305 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
98306 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
98307 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
98308 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
98309 +show_risefalltime_34084 show_risefalltime 4 34084 NULL
98310 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
98311 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
98312 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
98313 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
98314 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
98315 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
98316 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
98317 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
98318 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
98319 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
98320 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
98321 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
98322 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
98323 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
98324 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
98325 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
98326 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
98327 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
98328 +ea_read_34378 ea_read 0 34378 NULL
98329 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
98330 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
98331 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
98332 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
98333 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
98334 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
98335 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
98336 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
98337 +line6_dumpreq_init_34473 line6_dumpreq_init 3 34473 NULL
98338 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
98339 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
98340 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
98341 +alloc_buf_34532 alloc_buf 1 34532 NULL
98342 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
98343 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
98344 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
98345 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
98346 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
98347 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
98348 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
98349 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
98350 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
98351 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
98352 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
98353 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
98354 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
98355 +port_print_34704 port_print 3 34704 NULL
98356 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
98357 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
98358 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
98359 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
98360 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
98361 +ssd1307fb_write_array_34779 ssd1307fb_write_array 4 34779 NULL
98362 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
98363 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
98364 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
98365 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
98366 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
98367 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
98368 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
98369 +lm3533_ctrlbank_get_reg_34886 lm3533_ctrlbank_get_reg 0-2 34886 NULL
98370 +msg_print_text_34889 msg_print_text 0 34889 NULL
98371 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
98372 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
98373 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
98374 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
98375 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
98376 +Realloc_34961 Realloc 2 34961 NULL
98377 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
98378 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
98379 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
98380 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
98381 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
98382 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
98383 +store_ifalias_35088 store_ifalias 4 35088 NULL
98384 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
98385 +capi_write_35104 capi_write 3 35104 NULL nohasharray
98386 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
98387 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
98388 +pointer_35138 pointer 0 35138 NULL
98389 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
98390 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
98391 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
98392 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
98393 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
98394 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
98395 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
98396 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
98397 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
98398 +set_fd_set_35249 set_fd_set 1 35249 NULL
98399 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
98400 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
98401 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
98402 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
98403 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
98404 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
98405 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
98406 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
98407 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
98408 +new_bind_ctl_35324 new_bind_ctl 2 35324 NULL
98409 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
98410 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
98411 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
98412 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
98413 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
98414 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
98415 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
98416 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
98417 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
98418 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
98419 +rdev_get_id_35454 rdev_get_id 0 35454 NULL
98420 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
98421 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
98422 +async_setkey_35521 async_setkey 3 35521 NULL
98423 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
98424 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
98425 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
98426 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
98427 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
98428 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
98429 +ReadZReg_35604 ReadZReg 0 35604 NULL
98430 +kernel_readv_35617 kernel_readv 3 35617 NULL
98431 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
98432 +scrub_stripe_35637 scrub_stripe 4-3 35637 NULL
98433 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
98434 +store_debug_level_35652 store_debug_level 3 35652 NULL
98435 +regmap_update_bits_35668 regmap_update_bits 2 35668 NULL
98436 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
98437 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
98438 +dm_table_create_35687 dm_table_create 3 35687 NULL
98439 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
98440 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
98441 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
98442 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
98443 +read_file_stations_35795 read_file_stations 3 35795 NULL
98444 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
98445 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
98446 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
98447 +fls64_35862 fls64 0 35862 NULL
98448 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
98449 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
98450 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
98451 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
98452 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
98453 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
98454 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
98455 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
98456 +wm8350_reg_write_35967 wm8350_reg_write 2 35967 NULL
98457 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
98458 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
98459 +acl_alloc_35979 acl_alloc 1 35979 NULL
98460 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
98461 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
98462 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
98463 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
98464 +sys_init_module_36047 sys_init_module 2 36047 NULL
98465 +account_shadowed_36048 account_shadowed 2 36048 NULL
98466 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
98467 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
98468 +write_emulate_36065 write_emulate 2-4 36065 NULL
98469 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
98470 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
98471 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
98472 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
98473 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
98474 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
98475 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
98476 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
98477 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
98478 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
98479 +iwl_trans_txq_alloc_36147 iwl_trans_txq_alloc 3 36147 NULL
98480 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
98481 +twl_set_36154 twl_set 2 36154 NULL
98482 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
98483 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
98484 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
98485 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
98486 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
98487 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
98488 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
98489 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
98490 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
98491 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
98492 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
98493 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
98494 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
98495 +readahead_tree_block_36285 readahead_tree_block 3 36285 NULL
98496 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
98497 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
98498 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
98499 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
98500 +lc_create_36332 lc_create 4 36332 NULL
98501 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
98502 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
98503 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
98504 +to_sector_36361 to_sector 0-1 36361 NULL
98505 +tunables_read_36385 tunables_read 3 36385 NULL
98506 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
98507 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
98508 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
98509 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
98510 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
98511 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
98512 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
98513 +get_param_l_36518 get_param_l 0 36518 NULL
98514 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
98515 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
98516 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
98517 +ssd1307fb_write_data_array_36538 ssd1307fb_write_data_array 3 36538 NULL
98518 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
98519 +get_entry_len_36549 get_entry_len 0 36549 NULL
98520 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
98521 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
98522 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
98523 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
98524 +__erst_read_36579 __erst_read 0 36579 NULL
98525 +put_cmsg_36589 put_cmsg 4 36589 NULL
98526 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
98527 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
98528 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
98529 +format_decode_36638 format_decode 0 36638 NULL
98530 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
98531 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
98532 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
98533 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
98534 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
98535 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
98536 +snd_soc_update_bits_36714 snd_soc_update_bits 2 36714 NULL
98537 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
98538 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
98539 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
98540 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
98541 +snd_soc_update_bits_locked_36766 snd_soc_update_bits_locked 2 36766 NULL
98542 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
98543 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
98544 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
98545 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
98546 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
98547 +pcf50633_reg_write_36841 pcf50633_reg_write 2 36841 NULL nohasharray
98548 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 &pcf50633_reg_write_36841
98549 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
98550 +cm_write_36858 cm_write 3 36858 NULL
98551 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
98552 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
98553 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
98554 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
98555 +lm3533_als_get_target_36905 lm3533_als_get_target 2-3 36905 NULL
98556 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
98557 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
98558 +div_u64_36951 div_u64 0 36951 NULL
98559 +write_leb_36957 write_leb 5 36957 NULL
98560 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
98561 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
98562 +mc13xxx_reg_rmw_36997 mc13xxx_reg_rmw 2 36997 NULL
98563 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
98564 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
98565 +setxattr_37006 setxattr 4 37006 NULL
98566 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL
98567 +parse_command_37079 parse_command 2 37079 NULL
98568 +wm8994_gpio_set_37082 wm8994_gpio_set 2 37082 NULL
98569 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
98570 +tun_get_user_37094 tun_get_user 5 37094 NULL
98571 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
98572 +msg_word_37164 msg_word 0 37164 NULL
98573 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
98574 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
98575 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
98576 +__do_replace_37227 __do_replace 5 37227 NULL
98577 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
98578 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
98579 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
98580 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
98581 +c101_run_37279 c101_run 2 37279 NULL
98582 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
98583 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
98584 +send_msg_37323 send_msg 4 37323 NULL
98585 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
98586 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
98587 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
98588 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
98589 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
98590 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
98591 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
98592 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
98593 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
98594 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
98595 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
98596 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
98597 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
98598 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
98599 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
98600 +get_est_timing_37484 get_est_timing 0 37484 NULL
98601 +xfs_trans_read_buf_map_37487 xfs_trans_read_buf_map 5 37487 NULL
98602 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
98603 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
98604 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
98605 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
98606 +hdr_size_37536 hdr_size 0 37536 NULL
98607 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
98608 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
98609 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
98610 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
98611 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
98612 +alloc_fd_37637 alloc_fd 1 37637 NULL
98613 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
98614 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
98615 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
98616 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
98617 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
98618 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
98619 +nametbl_header_37698 nametbl_header 2 37698 NULL
98620 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
98621 +soc_widget_update_bits_locked_37715 soc_widget_update_bits_locked 2 37715 NULL
98622 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
98623 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
98624 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
98625 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
98626 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
98627 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
98628 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
98629 +deny_write_access_37813 deny_write_access 0 37813 NULL
98630 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
98631 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
98632 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
98633 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
98634 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
98635 +lm3533_als_get_target_reg_37881 lm3533_als_get_target_reg 0-1-2 37881 NULL
98636 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
98637 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
98638 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
98639 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
98640 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
98641 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
98642 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
98643 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
98644 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
98645 +vfs_readv_38011 vfs_readv 3 38011 NULL
98646 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
98647 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
98648 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
98649 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
98650 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
98651 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
98652 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
98653 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
98654 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
98655 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
98656 +ep0_read_38095 ep0_read 3 38095 NULL
98657 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
98658 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
98659 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
98660 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
98661 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
98662 +cdev_add_38176 cdev_add 2-3 38176 NULL
98663 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
98664 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
98665 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
98666 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
98667 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
98668 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
98669 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
98670 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
98671 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
98672 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
98673 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
98674 +verity_status_38273 verity_status 5 38273 NULL
98675 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
98676 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
98677 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
98678 +ieee80211_send_probe_req_38307 ieee80211_send_probe_req 6-4 38307 NULL
98679 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
98680 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
98681 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
98682 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
98683 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
98684 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
98685 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
98686 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
98687 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
98688 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
98689 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
98690 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
98691 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
98692 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
98693 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
98694 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
98695 +dev_names_read_38509 dev_names_read 3 38509 NULL
98696 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
98697 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
98698 +set_queue_count_38519 set_queue_count 0 38519 NULL
98699 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
98700 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
98701 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
98702 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
98703 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
98704 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
98705 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
98706 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
98707 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
98708 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
98709 +delay_status_38606 delay_status 5 38606 NULL
98710 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
98711 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
98712 +cma_create_area_38642 cma_create_area 2 38642 NULL
98713 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
98714 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
98715 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
98716 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
98717 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
98718 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
98719 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
98720 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
98721 +udf_readpages_38761 udf_readpages 4 38761 NULL
98722 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
98723 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
98724 +err_decode_38804 err_decode 2 38804 NULL
98725 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
98726 +sys_select_38827 sys_select 1 38827 NULL
98727 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
98728 +direct_entry_38836 direct_entry 3 38836 NULL
98729 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
98730 +interfaces_38859 interfaces 2 38859 NULL
98731 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
98732 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
98733 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
98734 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
98735 +__fswab16_38898 __fswab16 0 38898 NULL
98736 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
98737 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
98738 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
98739 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
98740 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
98741 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
98742 +udf_new_block_38999 udf_new_block 4 38999 NULL
98743 +get_nodes_39012 get_nodes 3 39012 NULL
98744 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
98745 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
98746 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
98747 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
98748 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
98749 +tun_get_user_39099 tun_get_user 4 39099 NULL
98750 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
98751 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
98752 +ea_foreach_39133 ea_foreach 0 39133 NULL
98753 +generic_permission_39150 generic_permission 0 39150 NULL
98754 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
98755 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
98756 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
98757 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
98758 +init_list_set_39188 init_list_set 2-3 39188 NULL
98759 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
98760 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
98761 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
98762 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
98763 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
98764 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
98765 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
98766 +drm_order_39244 drm_order 0 39244 NULL
98767 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
98768 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
98769 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
98770 +__skb_cow_39254 __skb_cow 2 39254 NULL
98771 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
98772 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
98773 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
98774 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
98775 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
98776 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
98777 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
98778 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
98779 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
98780 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
98781 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
98782 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
98783 +__send_to_port_39386 __send_to_port 3 39386 NULL
98784 +user_power_read_39414 user_power_read 3 39414 NULL
98785 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
98786 +sys_semop_39457 sys_semop 3 39457 NULL
98787 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
98788 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
98789 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
98790 +int_proc_write_39542 int_proc_write 3 39542 NULL
98791 +pp_write_39554 pp_write 3 39554 NULL
98792 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
98793 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
98794 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
98795 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
98796 +adau1373_set_pll_39593 adau1373_set_pll 2 39593 NULL
98797 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
98798 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
98799 +ext_depth_39607 ext_depth 0 39607 NULL
98800 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
98801 +sdio_readb_39618 sdio_readb 0 39618 NULL
98802 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
98803 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
98804 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
98805 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
98806 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
98807 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
98808 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
98809 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
98810 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
98811 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
98812 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
98813 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
98814 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
98815 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
98816 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
98817 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
98818 +pkt_add_39897 pkt_add 3 39897 NULL
98819 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
98820 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
98821 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
98822 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
98823 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
98824 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
98825 +__spi_async_39932 __spi_async 0 39932 NULL
98826 +__get_order_39935 __get_order 0 39935 NULL
98827 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
98828 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
98829 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
98830 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
98831 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
98832 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
98833 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
98834 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
98835 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
98836 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
98837 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
98838 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
98839 +add_tty_40055 add_tty 1 40055 NULL nohasharray
98840 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
98841 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
98842 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
98843 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
98844 +rbd_do_op_40128 rbd_do_op 4-5 40128 NULL
98845 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
98846 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
98847 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
98848 +pt_write_40159 pt_write 3 40159 NULL
98849 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
98850 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
98851 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
98852 +allocate_probes_40204 allocate_probes 1 40204 NULL
98853 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
98854 +compat_put_long_40214 compat_put_long 1 40214 NULL
98855 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
98856 +xfs_buf_read_map_40226 xfs_buf_read_map 3 40226 NULL
98857 +osst_read_40237 osst_read 3 40237 NULL
98858 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
98859 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
98860 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
98861 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
98862 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
98863 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
98864 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
98865 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
98866 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
98867 +mmio_read_40348 mmio_read 4 40348 NULL
98868 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
98869 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
98870 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
98871 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
98872 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
98873 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
98874 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
98875 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
98876 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
98877 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
98878 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
98879 +tty_write_room_40495 tty_write_room 0 40495 NULL
98880 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
98881 +sg_phys_40507 sg_phys 0 40507 NULL
98882 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
98883 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
98884 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
98885 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
98886 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
98887 +arch_setup_hpet_msi_40584 arch_setup_hpet_msi 1 40584 NULL
98888 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
98889 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
98890 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
98891 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
98892 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
98893 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
98894 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
98895 +fops_read_40672 fops_read 3 40672 NULL
98896 +tps80031_write_40678 tps80031_write 3 40678 NULL
98897 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
98898 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
98899 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
98900 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
98901 +tps65910_irq_map_40748 tps65910_irq_map 2 40748 NULL
98902 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
98903 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
98904 +card_send_command_40757 card_send_command 3 40757 NULL
98905 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
98906 +pg_write_40766 pg_write 3 40766 NULL
98907 +show_list_40775 show_list 3 40775 NULL
98908 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
98909 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
98910 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
98911 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
98912 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
98913 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
98914 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
98915 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
98916 +read_file_queue_40895 read_file_queue 3 40895 NULL
98917 +waiters_read_40902 waiters_read 3 40902 NULL
98918 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
98919 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
98920 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
98921 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
98922 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
98923 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
98924 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
98925 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
98926 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
98927 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
98928 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
98929 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
98930 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
98931 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
98932 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
98933 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
98934 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
98935 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
98936 +dma_attach_41094 dma_attach 5-6 41094 NULL
98937 +provide_user_output_41105 provide_user_output 3 41105 NULL
98938 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
98939 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
98940 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
98941 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
98942 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
98943 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
98944 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
98945 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
98946 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
98947 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
98948 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
98949 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
98950 +erst_read_41260 erst_read 0 41260 NULL
98951 +__fprog_create_41263 __fprog_create 2 41263 NULL
98952 +alloc_context_41283 alloc_context 1 41283 NULL
98953 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
98954 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
98955 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
98956 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
98957 +kmp_init_41373 kmp_init 2 41373 NULL
98958 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
98959 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
98960 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
98961 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
98962 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
98963 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
98964 +ext4_trim_extent_41436 ext4_trim_extent 4 41436 NULL
98965 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
98966 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
98967 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
98968 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
98969 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
98970 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
98971 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
98972 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
98973 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
98974 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
98975 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
98976 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
98977 +gserial_setup_41558 gserial_setup 2 41558 NULL
98978 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
98979 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
98980 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
98981 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
98982 +vga_io_r_41609 vga_io_r 0 41609 NULL
98983 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
98984 +a2mp_send_41615 a2mp_send 4 41615 NULL
98985 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
98986 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
98987 +get_std_timing_41654 get_std_timing 0 41654 NULL
98988 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
98989 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
98990 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
98991 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
98992 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
98993 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
98994 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
98995 +fillonedir_41746 fillonedir 3 41746 NULL
98996 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
98997 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
98998 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
98999 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
99000 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
99001 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
99002 +irq_data_to_status_reg_41854 irq_data_to_status_reg 0 41854 NULL
99003 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
99004 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
99005 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
99006 +ceph_get_direct_page_vector_41917 ceph_get_direct_page_vector 2 41917 NULL
99007 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
99008 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
99009 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
99010 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
99011 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
99012 +portnames_read_41958 portnames_read 3 41958 NULL
99013 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
99014 +dst_mtu_41969 dst_mtu 0 41969 NULL
99015 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
99016 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
99017 +lguest_map_42008 lguest_map 1-2 42008 NULL
99018 +pool_allocate_42012 pool_allocate 3 42012 NULL
99019 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
99020 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
99021 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
99022 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
99023 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
99024 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
99025 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
99026 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
99027 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
99028 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
99029 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
99030 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL
99031 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
99032 +v9fs_alloc_rdir_buf_42150 v9fs_alloc_rdir_buf 2 42150 NULL
99033 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
99034 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
99035 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
99036 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
99037 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
99038 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
99039 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
99040 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
99041 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
99042 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
99043 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
99044 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
99045 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
99046 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
99047 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
99048 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
99049 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
99050 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
99051 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
99052 +krng_get_random_42420 krng_get_random 3 42420 NULL
99053 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
99054 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
99055 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
99056 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
99057 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
99058 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
99059 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
99060 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
99061 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
99062 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
99063 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
99064 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
99065 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
99066 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
99067 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
99068 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
99069 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
99070 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
99071 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
99072 +map_state_42602 map_state 1 42602 NULL nohasharray
99073 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
99074 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
99075 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
99076 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
99077 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
99078 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
99079 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
99080 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
99081 +vb2_read_42703 vb2_read 3 42703 NULL
99082 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
99083 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
99084 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
99085 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
99086 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
99087 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
99088 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
99089 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
99090 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
99091 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
99092 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
99093 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
99094 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
99095 +set_arg_42824 set_arg 3 42824 NULL
99096 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
99097 +xfs_buf_read_uncached_42844 xfs_buf_read_uncached 3 42844 NULL
99098 +prandom_u32_42853 prandom_u32 0 42853 NULL
99099 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
99100 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
99101 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
99102 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
99103 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
99104 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
99105 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
99106 +hd_end_request_42904 hd_end_request 2 42904 NULL
99107 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
99108 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
99109 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
99110 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
99111 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
99112 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
99113 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
99114 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
99115 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
99116 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
99117 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
99118 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
99119 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
99120 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
99121 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
99122 +uuid_string_43154 uuid_string 0 43154 NULL
99123 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
99124 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
99125 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
99126 +process_measurement_43190 process_measurement 0 43190 NULL
99127 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
99128 +uio_write_43202 uio_write 3 43202 NULL
99129 +iso_callback_43208 iso_callback 3 43208 NULL
99130 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
99131 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
99132 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
99133 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
99134 +fixup_leb_43256 fixup_leb 3 43256 NULL
99135 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
99136 +evtchn_write_43278 evtchn_write 3 43278 NULL
99137 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
99138 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
99139 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
99140 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
99141 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
99142 +xenfb_write_43412 xenfb_write 3 43412 NULL
99143 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 NULL nohasharray
99144 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 &gdm_wimax_netif_rx_43423
99145 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
99146 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
99147 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
99148 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
99149 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
99150 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
99151 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
99152 +do_readlink_43518 do_readlink 2 43518 NULL
99153 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
99154 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
99155 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
99156 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
99157 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
99158 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
99159 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
99160 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
99161 +proc_read_43614 proc_read 3 43614 NULL
99162 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
99163 +tps65217_set_bits_43659 tps65217_set_bits 2 43659 NULL nohasharray
99164 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 &tps65217_set_bits_43659
99165 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
99166 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
99167 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
99168 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
99169 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
99170 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
99171 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
99172 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
99173 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
99174 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
99175 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
99176 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
99177 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
99178 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
99179 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
99180 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
99181 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
99182 +read_flush_43851 read_flush 3 43851 NULL
99183 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
99184 +pm860x_bulk_write_43875 pm860x_bulk_write 3-2 43875 NULL
99185 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
99186 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
99187 +SendString_43928 SendString 3 43928 NULL
99188 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
99189 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
99190 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
99191 +nla_reserve_43984 nla_reserve 3 43984 NULL
99192 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
99193 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
99194 +emit_flags_44006 emit_flags 4-3 44006 NULL
99195 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
99196 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
99197 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
99198 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
99199 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
99200 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
99201 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
99202 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
99203 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
99204 +__set_free_44211 __set_free 2 44211 NULL
99205 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
99206 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
99207 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
99208 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
99209 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
99210 +enlarge_skb_44248 enlarge_skb 2 44248 NULL nohasharray
99211 +xfs_buf_readahead_map_44248 xfs_buf_readahead_map 3 44248 &enlarge_skb_44248
99212 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
99213 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
99214 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
99215 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
99216 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
99217 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
99218 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
99219 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
99220 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
99221 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
99222 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
99223 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
99224 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
99225 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
99226 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
99227 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
99228 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
99229 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
99230 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
99231 +spidev_write_44510 spidev_write 3 44510 NULL
99232 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
99233 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
99234 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
99235 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
99236 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
99237 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
99238 +wm5100_gpio_set_44602 wm5100_gpio_set 2 44602 NULL
99239 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
99240 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
99241 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
99242 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
99243 +mpi_resize_44674 mpi_resize 2 44674 NULL
99244 +ts_read_44687 ts_read 3 44687 NULL
99245 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
99246 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
99247 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
99248 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
99249 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
99250 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
99251 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
99252 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
99253 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
99254 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
99255 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
99256 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
99257 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
99258 +sisusb_write_44834 sisusb_write 3 44834 NULL
99259 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
99260 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
99261 +skb_availroom_44883 skb_availroom 0 44883 NULL
99262 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
99263 +do_tty_write_44896 do_tty_write 5 44896 NULL
99264 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
99265 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
99266 +max77693_write_reg_45004 max77693_write_reg 2 45004 NULL
99267 +ftdi_process_packet_45005 ftdi_process_packet 5 45005 NULL
99268 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
99269 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
99270 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
99271 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
99272 +sel_write_user_45060 sel_write_user 3 45060 NULL
99273 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
99274 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
99275 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
99276 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
99277 +usbdev_read_45114 usbdev_read 3 45114 NULL
99278 +send_to_tty_45141 send_to_tty 3 45141 NULL
99279 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
99280 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
99281 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
99282 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
99283 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
99284 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
99285 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
99286 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
99287 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
99288 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
99289 +add_child_45201 add_child 4 45201 NULL
99290 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
99291 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
99292 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
99293 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
99294 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
99295 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
99296 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
99297 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
99298 +keymap_store_45406 keymap_store 4 45406 NULL
99299 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL
99300 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
99301 +do_mmap_pgoff_45441 do_mmap_pgoff 0 45441 NULL
99302 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
99303 +__node_remap_45458 __node_remap 4 45458 NULL
99304 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
99305 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
99306 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
99307 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
99308 +arizona_init_fll_45503 arizona_init_fll 4-5 45503 NULL
99309 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
99310 +clone_bio_45516 clone_bio 6 45516 NULL
99311 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
99312 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
99313 +copy_macs_45534 copy_macs 4 45534 NULL
99314 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
99315 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
99316 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
99317 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
99318 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
99319 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
99320 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
99321 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
99322 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
99323 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
99324 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
99325 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
99326 +da9052_gpio_set_45643 da9052_gpio_set 2 45643 NULL
99327 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
99328 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
99329 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
99330 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
99331 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
99332 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
99333 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
99334 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
99335 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
99336 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
99337 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
99338 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
99339 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
99340 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
99341 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
99342 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
99343 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
99344 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
99345 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
99346 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
99347 +amthi_read_45831 amthi_read 4 45831 NULL
99348 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
99349 +isdn_write_45863 isdn_write 3 45863 NULL
99350 +rbd_get_num_segments_45864 rbd_get_num_segments 0-2-3 45864 NULL
99351 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
99352 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
99353 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
99354 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
99355 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
99356 +alloc_mr_45935 alloc_mr 1 45935 NULL
99357 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
99358 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
99359 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
99360 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
99361 +get_free_entries_46030 get_free_entries 1 46030 NULL
99362 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
99363 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
99364 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
99365 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
99366 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
99367 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
99368 +slhc_toss_46066 slhc_toss 0 46066 NULL
99369 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
99370 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
99371 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
99372 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
99373 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
99374 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
99375 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
99376 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
99377 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
99378 +qlcnic_alloc_msix_entries_46160 qlcnic_alloc_msix_entries 2 46160 NULL
99379 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
99380 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
99381 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
99382 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
99383 +dsp_write_46218 dsp_write 2 46218 NULL
99384 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
99385 +__le64_to_cpup_46257 __le64_to_cpup 0 46257 NULL
99386 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
99387 +ReadReg_46277 ReadReg 0 46277 NULL
99388 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
99389 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
99390 +twl6040_write_46351 twl6040_write 2 46351 NULL
99391 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
99392 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
99393 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
99394 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
99395 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
99396 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
99397 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
99398 +filldir64_46469 filldir64 3 46469 NULL
99399 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
99400 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
99401 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
99402 +kmsg_read_46514 kmsg_read 3 46514 NULL
99403 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
99404 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
99405 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
99406 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
99407 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
99408 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
99409 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
99410 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
99411 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
99412 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
99413 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
99414 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
99415 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
99416 +aircable_process_packet_46639 aircable_process_packet 5 46639 NULL
99417 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
99418 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
99419 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
99420 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
99421 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
99422 +prepare_copy_46725 prepare_copy 2 46725 NULL
99423 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
99424 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
99425 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
99426 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
99427 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
99428 +scrub_chunk_46789 scrub_chunk 4 46789 NULL
99429 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
99430 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
99431 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
99432 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
99433 +ieee80211_rx_radiotap_len_46846 ieee80211_rx_radiotap_len 0 46846 NULL
99434 +spi_async_46857 spi_async 0 46857 NULL
99435 +ieee80211_mgmt_tx_46860 ieee80211_mgmt_tx 9 46860 NULL
99436 +vsnprintf_46863 vsnprintf 0 46863 NULL
99437 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
99438 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
99439 +rvmalloc_46873 rvmalloc 1 46873 NULL
99440 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
99441 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
99442 +em28xx_alloc_isoc_46892 em28xx_alloc_isoc 4 46892 NULL
99443 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
99444 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
99445 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
99446 +fb_write_46924 fb_write 3 46924 NULL
99447 +raid_status_46930 raid_status 5 46930 NULL
99448 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
99449 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
99450 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
99451 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
99452 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
99453 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
99454 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
99455 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
99456 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
99457 +__map_single_47020 __map_single 3-4-7 47020 NULL
99458 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
99459 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
99460 +wm8994_set_bits_47052 wm8994_set_bits 2 47052 NULL
99461 +fs_path_len_47060 fs_path_len 0 47060 NULL
99462 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
99463 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
99464 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
99465 +mousedev_read_47123 mousedev_read 3 47123 NULL
99466 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
99467 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
99468 +cxio_init_resource_fifo_random_47151 cxio_init_resource_fifo_random 3 47151 NULL
99469 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
99470 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
99471 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
99472 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
99473 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
99474 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
99475 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
99476 +wm8903_gpio_direction_in_47213 wm8903_gpio_direction_in 2 47213 NULL
99477 +l2headersize_47238 l2headersize 0 47238 NULL
99478 +options_write_47243 options_write 3 47243 NULL
99479 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
99480 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
99481 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
99482 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
99483 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
99484 +vsnprintf_47291 vsnprintf 0 47291 NULL
99485 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
99486 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
99487 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
99488 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
99489 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
99490 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL
99491 +nametbl_list_47391 nametbl_list 2 47391 NULL
99492 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
99493 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
99494 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
99495 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
99496 +vzalloc_47421 vzalloc 1 47421 NULL
99497 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
99498 +newpart_47485 newpart 6 47485 NULL
99499 +core_sys_select_47494 core_sys_select 1 47494 NULL
99500 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
99501 +unlink_simple_47506 unlink_simple 3 47506 NULL
99502 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
99503 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
99504 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
99505 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
99506 +oz_events_read_47535 oz_events_read 3 47535 NULL
99507 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
99508 +cycx_setup_47562 cycx_setup 4 47562 NULL
99509 +read_ldt_47570 read_ldt 2 47570 NULL
99510 +pci_iomap_47575 pci_iomap 3 47575 NULL
99511 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
99512 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
99513 +wm831x_gpio_direction_out_47607 wm831x_gpio_direction_out 2 47607 NULL
99514 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
99515 +uea_request_47613 uea_request 4 47613 NULL
99516 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
99517 +tps65217_clear_bits_47619 tps65217_clear_bits 2 47619 NULL
99518 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
99519 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
99520 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
99521 +irq_linear_revmap_47682 irq_linear_revmap 0 47682 NULL
99522 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
99523 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
99524 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
99525 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
99526 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
99527 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
99528 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
99529 +irq_domain_legacy_revmap_47765 irq_domain_legacy_revmap 0-2 47765 NULL
99530 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
99531 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
99532 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
99533 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
99534 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
99535 +__pcf50633_irq_mask_set_47847 __pcf50633_irq_mask_set 2 47847 NULL
99536 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
99537 +vhci_read_47878 vhci_read 3 47878 NULL
99538 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
99539 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
99540 +timeout_read_47915 timeout_read 3 47915 NULL
99541 +comedi_write_47926 comedi_write 3 47926 NULL
99542 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
99543 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
99544 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
99545 +pnpacpi_parse_allocated_irqresource_47986 pnpacpi_parse_allocated_irqresource 2 47986 NULL
99546 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
99547 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
99548 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
99549 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
99550 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
99551 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
99552 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
99553 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
99554 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
99555 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
99556 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
99557 +rtsx_read_cfg_seq_48139 rtsx_read_cfg_seq 5-3 48139 NULL
99558 +set_discoverable_48141 set_discoverable 4 48141 NULL
99559 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
99560 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
99561 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
99562 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
99563 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
99564 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
99565 +init_ipath_48187 init_ipath 1 48187 NULL nohasharray
99566 +ieee80211_send_auth_48187 ieee80211_send_auth 6 48187 &init_ipath_48187
99567 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
99568 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
99569 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
99570 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
99571 +read_file_recv_48232 read_file_recv 3 48232 NULL
99572 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
99573 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
99574 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
99575 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
99576 +send_set_info_48288 send_set_info 7 48288 NULL
99577 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
99578 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
99579 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
99580 +hash_setkey_48310 hash_setkey 3 48310 NULL
99581 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
99582 +skb_add_data_48363 skb_add_data 3 48363 NULL
99583 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
99584 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
99585 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
99586 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
99587 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
99588 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
99589 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
99590 +send_control_msg_48498 send_control_msg 6 48498 NULL
99591 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
99592 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
99593 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
99594 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
99595 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
99596 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
99597 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
99598 +named_distribute_48544 named_distribute 4 48544 NULL
99599 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
99600 +ext_sd_execute_read_data_48589 ext_sd_execute_read_data 9 48589 NULL
99601 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
99602 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
99603 +mtd_read_48655 mtd_read 0 48655 NULL
99604 +lc_create_48662 lc_create 3 48662 NULL
99605 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
99606 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
99607 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
99608 +altera_drscan_48698 altera_drscan 2 48698 NULL
99609 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
99610 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
99611 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
99612 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
99613 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
99614 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
99615 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
99616 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
99617 +azx_get_position_48841 azx_get_position 0 48841 NULL
99618 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
99619 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
99620 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
99621 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
99622 +get_num_ops_48886 get_num_ops 0 48886 NULL
99623 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
99624 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
99625 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
99626 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
99627 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL nohasharray
99628 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 &gdth_isa_probe_one_48925
99629 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
99630 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
99631 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
99632 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
99633 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
99634 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
99635 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
99636 +xd_rw_49020 xd_rw 3-4 49020 NULL
99637 +transient_status_49027 transient_status 4 49027 NULL
99638 +ubi_read_49061 ubi_read 0 49061 NULL
99639 +tps65910_reg_write_49066 tps65910_reg_write 2 49066 NULL
99640 +calc_layout_49074 calc_layout 4 49074 NULL
99641 +vmx_set_msr_49090 vmx_set_msr 3 49090 NULL
99642 +scsi_register_49094 scsi_register 2 49094 NULL
99643 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
99644 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
99645 +pt_read_49136 pt_read 3 49136 NULL
99646 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
99647 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
99648 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
99649 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
99650 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
99651 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
99652 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
99653 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
99654 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
99655 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
99656 +pcf50633_gpio_invert_set_49256 pcf50633_gpio_invert_set 2 49256 NULL
99657 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
99658 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
99659 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
99660 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
99661 +uio_read_49300 uio_read 3 49300 NULL
99662 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
99663 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
99664 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
99665 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
99666 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
99667 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
99668 +px_raw_event_49371 px_raw_event 4 49371 NULL
99669 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
99670 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
99671 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
99672 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
99673 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
99674 +md_domain_init_49432 md_domain_init 2 49432 NULL
99675 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
99676 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
99677 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
99678 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
99679 +ieee80211_ie_split_49474 ieee80211_ie_split 0-5 49474 NULL
99680 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
99681 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
99682 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
99683 +wm831x_dcdc_set_mode_int_49546 wm831x_dcdc_set_mode_int 2 49546 NULL
99684 +smk_write_access_49561 smk_write_access 3 49561 NULL
99685 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
99686 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
99687 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
99688 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
99689 +heap_init_49617 heap_init 2 49617 NULL
99690 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
99691 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
99692 +svm_set_msr_49643 svm_set_msr 3 49643 NULL
99693 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
99694 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
99695 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
99696 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
99697 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
99698 +check_frame_49741 check_frame 0 49741 NULL
99699 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
99700 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
99701 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
99702 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
99703 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
99704 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
99705 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
99706 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
99707 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
99708 +add_uuid_49831 add_uuid 4 49831 NULL
99709 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
99710 +__btrfs_map_block_49839 __btrfs_map_block 3 49839 NULL
99711 +twl4030_write_49846 twl4030_write 2 49846 NULL
99712 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
99713 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
99714 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
99715 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
99716 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
99717 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
99718 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
99719 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
99720 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
99721 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
99722 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
99723 +__module_alloc_50004 __module_alloc 1 50004 NULL
99724 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
99725 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
99726 +isdn_read_50021 isdn_read 3 50021 NULL
99727 +rbd_req_write_50041 rbd_req_write 4-5 50041 NULL
99728 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
99729 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
99730 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
99731 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
99732 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
99733 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
99734 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
99735 +read_file_slot_50111 read_file_slot 3 50111 NULL
99736 +copy_items_50140 copy_items 6 50140 NULL
99737 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
99738 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
99739 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
99740 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
99741 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
99742 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
99743 +odev_update_50169 odev_update 2 50169 NULL
99744 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
99745 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
99746 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
99747 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
99748 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
99749 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
99750 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
99751 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
99752 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
99753 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
99754 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
99755 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
99756 +do_launder_page_50329 do_launder_page 0 50329 NULL
99757 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
99758 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
99759 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
99760 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
99761 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
99762 +tpm_read_50344 tpm_read 3 50344 NULL
99763 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
99764 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
99765 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
99766 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
99767 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
99768 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
99769 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
99770 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
99771 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
99772 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
99773 +tps65217_update_bits_50472 tps65217_update_bits 2 50472 NULL
99774 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
99775 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
99776 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
99777 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
99778 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
99779 +pcf50633_reg_set_bit_mask_50544 pcf50633_reg_set_bit_mask 2 50544 NULL
99780 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
99781 +fat_readpages_50582 fat_readpages 4 50582 NULL
99782 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
99783 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
99784 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
99785 +__ffs_50625 __ffs 0 50625 NULL
99786 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
99787 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
99788 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
99789 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
99790 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
99791 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
99792 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
99793 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
99794 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
99795 +skb_padto_50759 skb_padto 2 50759 NULL
99796 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
99797 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
99798 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
99799 +tpm_write_50798 tpm_write 3 50798 NULL
99800 +tun_do_read_50800 tun_do_read 4 50800 NULL
99801 +write_flush_50803 write_flush 3 50803 NULL
99802 +dvb_play_50814 dvb_play 3 50814 NULL
99803 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
99804 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
99805 +pstore_mkfile_50830 pstore_mkfile 5 50830 NULL
99806 +dma_attach_50831 dma_attach 6-7 50831 NULL
99807 +SetArea_50835 SetArea 4 50835 NULL nohasharray
99808 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
99809 +self_check_write_50856 self_check_write 5 50856 NULL
99810 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
99811 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
99812 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
99813 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
99814 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
99815 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
99816 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
99817 +sock_bindtodevice_50942 sock_bindtodevice 3 50942 NULL
99818 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
99819 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
99820 +timeout_write_50991 timeout_write 3 50991 NULL
99821 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL nohasharray
99822 +wm8903_gpio_direction_out_50995 wm8903_gpio_direction_out 2 50995 &wm831x_irq_map_50995
99823 +proc_write_51003 proc_write 3 51003 NULL
99824 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
99825 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
99826 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
99827 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
99828 +dump_midi_51040 dump_midi 3 51040 NULL
99829 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
99830 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
99831 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
99832 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
99833 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
99834 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
99835 +lm3533_als_get_current_51120 lm3533_als_get_current 2 51120 NULL
99836 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
99837 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
99838 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
99839 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
99840 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
99841 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
99842 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
99843 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
99844 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
99845 +tipc_send_51238 tipc_send 4 51238 NULL
99846 +drm_property_create_51239 drm_property_create 4 51239 NULL
99847 +st_read_51251 st_read 3 51251 NULL
99848 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
99849 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
99850 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
99851 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
99852 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
99853 +fd_do_readv_51297 fd_do_readv 3 51297 NULL
99854 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
99855 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
99856 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
99857 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
99858 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
99859 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
99860 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
99861 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
99862 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
99863 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
99864 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
99865 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
99866 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
99867 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
99868 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
99869 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
99870 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
99871 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
99872 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
99873 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
99874 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
99875 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
99876 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
99877 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
99878 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
99879 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
99880 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
99881 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
99882 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
99883 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
99884 +sel_write_access_51704 sel_write_access 3 51704 NULL
99885 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
99886 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
99887 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
99888 +msg_set_51725 msg_set 3 51725 NULL
99889 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
99890 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
99891 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
99892 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
99893 +if_write_51756 if_write 3 51756 NULL
99894 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
99895 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
99896 +__fswab32_51781 __fswab32 0 51781 NULL
99897 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
99898 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
99899 +wm2000_write_51834 wm2000_write 2 51834 NULL
99900 +ioread32_51847 ioread32 0 51847 NULL nohasharray
99901 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
99902 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
99903 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
99904 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
99905 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
99906 +user_read_51881 user_read 3 51881 NULL
99907 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
99908 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
99909 +iio_read_first_n_sw_rb_51911 iio_read_first_n_sw_rb 2 51911 NULL
99910 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
99911 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
99912 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
99913 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
99914 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
99915 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
99916 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
99917 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
99918 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
99919 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
99920 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
99921 +rdmalt_52022 rdmalt 0 52022 NULL
99922 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
99923 +override_release_52032 override_release 2 52032 NULL
99924 +end_port_52042 end_port 0 52042 NULL
99925 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
99926 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
99927 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
99928 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
99929 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
99930 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
99931 +retry_count_read_52129 retry_count_read 3 52129 NULL
99932 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
99933 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
99934 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
99935 +htable_size_52148 htable_size 0-1 52148 NULL
99936 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
99937 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
99938 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
99939 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
99940 +print_prefix_52176 print_prefix 0 52176 NULL
99941 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
99942 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
99943 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
99944 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
99945 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
99946 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
99947 +mpol_to_str_52293 mpol_to_str 2 52293 NULL
99948 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
99949 +read_file_reset_52310 read_file_reset 3 52310 NULL
99950 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
99951 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
99952 +hwflags_read_52318 hwflags_read 3 52318 NULL
99953 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
99954 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
99955 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
99956 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
99957 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
99958 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
99959 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
99960 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
99961 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
99962 +pcf50633_reg_clear_bits_52407 pcf50633_reg_clear_bits 2 52407 NULL
99963 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
99964 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
99965 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
99966 +delay_status_52431 delay_status 5 52431 NULL
99967 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
99968 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
99969 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
99970 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
99971 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
99972 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
99973 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
99974 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
99975 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
99976 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
99977 +emit_code_52583 emit_code 0-3 52583 NULL
99978 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
99979 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
99980 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
99981 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
99982 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
99983 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
99984 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
99985 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
99986 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
99987 +alloc_extent_buffer_52824 alloc_extent_buffer 3 52824 NULL
99988 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
99989 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
99990 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
99991 +twlreg_write_52880 twlreg_write 3 52880 NULL
99992 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
99993 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
99994 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
99995 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
99996 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
99997 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
99998 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
99999 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
100000 +send_packet_52960 send_packet 4 52960 NULL
100001 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
100002 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 NULL
100003 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
100004 +num_node_state_52989 num_node_state 0 52989 NULL
100005 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
100006 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
100007 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
100008 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
100009 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
100010 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
100011 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
100012 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
100013 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
100014 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
100015 +verity_status_53120 verity_status 5 53120 NULL
100016 +line6_dumpreq_initbuf_53123 line6_dumpreq_initbuf 3 53123 NULL
100017 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
100018 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
100019 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
100020 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
100021 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
100022 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
100023 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
100024 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
100025 +lirc_buffer_init_53282 lirc_buffer_init 3-2 53282 NULL
100026 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
100027 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
100028 +vm_mmap_53339 vm_mmap 0 53339 NULL
100029 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
100030 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
100031 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
100032 +wm8996_gpio_set_53421 wm8996_gpio_set 2 53421 NULL
100033 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
100034 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
100035 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
100036 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
100037 +n2_run_53459 n2_run 3 53459 NULL
100038 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
100039 +wm831x_write_53469 wm831x_write 2 53469 NULL
100040 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
100041 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
100042 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
100043 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
100044 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
100045 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
100046 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
100047 +check_acl_53512 check_acl 0 53512 NULL
100048 +set_registers_53582 set_registers 3 53582 NULL
100049 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
100050 +__readw_53594 __readw 0 53594 NULL
100051 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
100052 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
100053 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
100054 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
100055 +_preload_range_53676 _preload_range 2-3 53676 NULL
100056 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
100057 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
100058 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 NULL nohasharray
100059 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
100060 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
100061 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
100062 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
100063 +wdm_write_53735 wdm_write 3 53735 NULL
100064 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
100065 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
100066 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
100067 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
100068 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
100069 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
100070 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
100071 +regmap_raw_write_53803 regmap_raw_write 4-2 53803 NULL
100072 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
100073 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
100074 +cpumask_next_zero_53835 cpumask_next_zero 1 53835 NULL
100075 +pms_read_53873 pms_read 3 53873 NULL
100076 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
100077 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
100078 +proc_file_read_53905 proc_file_read 3 53905 NULL
100079 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
100080 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
100081 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
100082 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
100083 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
100084 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
100085 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
100086 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
100087 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
100088 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
100089 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
100090 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
100091 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
100092 +_malloc_54077 _malloc 1 54077 NULL
100093 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
100094 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
100095 +create_xattr_54106 create_xattr 5 54106 NULL
100096 +strn_len_54122 strn_len 0 54122 NULL
100097 +isku_receive_54130 isku_receive 4 54130 NULL
100098 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
100099 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
100100 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
100101 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
100102 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
100103 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
100104 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
100105 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
100106 +reada_add_block_54247 reada_add_block 2 54247 NULL
100107 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
100108 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
100109 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
100110 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
100111 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
100112 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
100113 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
100114 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
100115 +sprintf_54306 sprintf 0 54306 NULL
100116 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
100117 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
100118 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
100119 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
100120 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
100121 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
100122 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
100123 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
100124 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
100125 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
100126 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
100127 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
100128 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
100129 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
100130 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
100131 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
100132 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
100133 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
100134 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
100135 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
100136 +viacam_read_54526 viacam_read 3 54526 NULL
100137 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
100138 +setsockopt_54539 setsockopt 5 54539 NULL
100139 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
100140 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
100141 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
100142 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
100143 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
100144 +irq_of_parse_and_map_54646 irq_of_parse_and_map 0 54646 NULL
100145 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
100146 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
100147 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
100148 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
100149 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
100150 +evm_read_key_54674 evm_read_key 3 54674 NULL
100151 +resource_string_54699 resource_string 0 54699 NULL
100152 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
100153 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
100154 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
100155 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
100156 +kzalloc_54740 kzalloc 1 54740 NULL
100157 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
100158 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
100159 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
100160 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
100161 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
100162 +domain_init_54797 domain_init 2 54797 NULL
100163 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
100164 +nfsd_write_54809 nfsd_write 6 54809 NULL
100165 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
100166 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
100167 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
100168 +write_rio_54837 write_rio 3 54837 NULL
100169 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
100170 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
100171 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
100172 +printer_read_54851 printer_read 3 54851 NULL
100173 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
100174 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
100175 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
100176 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
100177 +lm3533_led_get_lv_reg_54900 lm3533_led_get_lv_reg 0-2 54900 NULL
100178 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
100179 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
100180 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
100181 +add_port_54941 add_port 2 54941 NULL
100182 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
100183 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
100184 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
100185 +c4_add_card_54968 c4_add_card 3 54968 NULL
100186 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
100187 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
100188 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
100189 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
100190 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
100191 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
100192 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
100193 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
100194 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
100195 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL
100196 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
100197 +corrupt_data_55120 corrupt_data 0 55120 NULL
100198 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
100199 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
100200 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
100201 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
100202 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
100203 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
100204 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
100205 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
100206 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL nohasharray
100207 +pcf50633_gpio_set_55209 pcf50633_gpio_set 2 55209 &ht40allow_map_read_55209
100208 +ssd1307fb_write_cmd_array_55211 ssd1307fb_write_cmd_array 3 55211 NULL nohasharray
100209 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 &ssd1307fb_write_cmd_array_55211
100210 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
100211 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
100212 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
100213 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
100214 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
100215 +ptrace_request_55288 ptrace_request 3 55288 NULL
100216 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
100217 +rbd_create_rw_ops_55297 rbd_create_rw_ops 1 55297 NULL
100218 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
100219 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 NULL
100220 +vme_user_read_55338 vme_user_read 3 55338 NULL
100221 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
100222 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
100223 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
100224 +__send_to_port_55383 __send_to_port 3 55383 NULL
100225 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
100226 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
100227 +alloc_skb_55439 alloc_skb 1 55439 NULL
100228 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
100229 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
100230 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
100231 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
100232 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
100233 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
100234 +wm5100_gpio_direction_out_55497 wm5100_gpio_direction_out 2 55497 NULL
100235 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
100236 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
100237 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
100238 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
100239 +ea_get_55522 ea_get 0 55522 NULL
100240 +buffer_size_55534 buffer_size 0 55534 NULL
100241 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
100242 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
100243 +add_partition_55588 add_partition 2 55588 NULL
100244 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
100245 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
100246 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
100247 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
100248 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
100249 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
100250 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
100251 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
100252 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
100253 +read_oldmem_55658 read_oldmem 3 55658 NULL
100254 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
100255 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
100256 +get_info_55681 get_info 3 55681 NULL
100257 +arizona_gpio_direction_in_55690 arizona_gpio_direction_in 2 55690 NULL
100258 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
100259 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
100260 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
100261 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
100262 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 3-2 55738 NULL
100263 +set_local_name_55757 set_local_name 4 55757 NULL
100264 +btrfs_init_new_buffer_55761 btrfs_init_new_buffer 4 55761 NULL
100265 +strlen_55778 strlen 0 55778 NULL nohasharray
100266 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
100267 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
100268 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
100269 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
100270 +btrfs_find_create_tree_block_55812 btrfs_find_create_tree_block 3 55812 NULL
100271 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
100272 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
100273 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
100274 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
100275 +hsc_write_55875 hsc_write 3 55875 NULL
100276 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
100277 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
100278 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
100279 +handle_response_55951 handle_response 5 55951 NULL
100280 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
100281 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
100282 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
100283 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
100284 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
100285 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
100286 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
100287 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
100288 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
100289 +map_addr_56144 map_addr 7 56144 NULL
100290 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
100291 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
100292 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
100293 +skb_headroom_56200 skb_headroom 0 56200 NULL
100294 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
100295 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
100296 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
100297 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
100298 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
100299 +scrub_setup_recheck_block_56245 scrub_setup_recheck_block 4-3 56245 NULL
100300 +fd_copyin_56247 fd_copyin 3 56247 NULL
100301 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
100302 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
100303 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
100304 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
100305 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
100306 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
100307 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
100308 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
100309 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
100310 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
100311 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
100312 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
100313 +tps80031_ext_power_req_config_56353 tps80031_ext_power_req_config 3-4-5 56353 NULL
100314 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
100315 +dev_read_56369 dev_read 3 56369 NULL
100316 +alloc_dummy_extent_buffer_56374 alloc_dummy_extent_buffer 2 56374 NULL
100317 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
100318 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
100319 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
100320 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
100321 +store_msg_56417 store_msg 3 56417 NULL
100322 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
100323 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
100324 +fl_create_56435 fl_create 5 56435 NULL
100325 +gnttab_map_56439 gnttab_map 2 56439 NULL
100326 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
100327 +set_connectable_56458 set_connectable 4 56458 NULL
100328 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
100329 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
100330 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
100331 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
100332 +ip_options_get_56538 ip_options_get 4 56538 NULL
100333 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
100334 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
100335 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
100336 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
100337 +event_filter_write_56609 event_filter_write 3 56609 NULL
100338 +gather_array_56641 gather_array 3 56641 NULL
100339 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
100340 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
100341 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
100342 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
100343 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
100344 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
100345 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
100346 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
100347 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
100348 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
100349 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
100350 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
100351 +do_syslog_56807 do_syslog 3 56807 NULL
100352 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
100353 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
100354 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
100355 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
100356 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
100357 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
100358 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
100359 +strcspn_56913 strcspn 0 56913 NULL
100360 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
100361 +check_header_56930 check_header 2 56930 NULL
100362 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
100363 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
100364 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
100365 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
100366 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
100367 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
100368 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
100369 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
100370 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
100371 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
100372 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
100373 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
100374 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
100375 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
100376 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
100377 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
100378 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
100379 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
100380 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
100381 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
100382 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
100383 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
100384 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
100385 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
100386 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
100387 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
100388 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
100389 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
100390 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
100391 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
100392 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
100393 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
100394 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
100395 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
100396 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
100397 +fw_file_size_57307 fw_file_size 0 57307 NULL
100398 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
100399 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
100400 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
100401 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
100402 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
100403 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
100404 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
100405 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
100406 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
100407 +read_file_blob_57406 read_file_blob 3 57406 NULL
100408 +enclosure_register_57412 enclosure_register 3 57412 NULL
100409 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
100410 +wm831x_gpio_set_debounce_57428 wm831x_gpio_set_debounce 2 57428 NULL
100411 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
100412 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
100413 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
100414 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
100415 +ReadReg_57453 ReadReg 0 57453 NULL
100416 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
100417 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
100418 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
100419 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
100420 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
100421 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
100422 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
100423 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
100424 +skb_headlen_57501 skb_headlen 0 57501 NULL
100425 +copy_in_user_57502 copy_in_user 3 57502 NULL
100426 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
100427 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
100428 +init_tag_map_57515 init_tag_map 3 57515 NULL
100429 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
100430 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
100431 +inode_permission_57531 inode_permission 0 57531 NULL
100432 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
100433 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
100434 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
100435 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
100436 +lp8788_update_bits_57600 lp8788_update_bits 2 57600 NULL
100437 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
100438 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
100439 +tps65217_reg_write_57623 tps65217_reg_write 2 57623 NULL nohasharray
100440 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 &tps65217_reg_write_57623
100441 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
100442 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
100443 +mem_read_57631 mem_read 3 57631 NULL
100444 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
100445 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
100446 +r3964_write_57662 r3964_write 4 57662 NULL
100447 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
100448 +__lgwrite_57669 __lgwrite 4 57669 NULL
100449 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
100450 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
100451 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
100452 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
100453 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
100454 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
100455 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
100456 +ld2_57794 ld2 0 57794 NULL
100457 +ivtv_read_57796 ivtv_read 3 57796 NULL
100458 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
100459 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
100460 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
100461 +copy_to_user_57835 copy_to_user 3 57835 NULL
100462 +flash_read_57843 flash_read 3 57843 NULL
100463 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
100464 +ad5380_info_to_reg_57905 ad5380_info_to_reg 0 57905 NULL
100465 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
100466 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
100467 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
100468 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
100469 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
100470 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
100471 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
100472 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
100473 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
100474 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
100475 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
100476 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
100477 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
100478 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
100479 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
100480 +mc13783_write_58033 mc13783_write 2 58033 NULL
100481 +mce_async_out_58056 mce_async_out 3 58056 NULL
100482 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
100483 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
100484 +cm4040_write_58079 cm4040_write 3 58079 NULL
100485 +udi_log_event_58105 udi_log_event 3 58105 NULL
100486 +savemem_58129 savemem 3 58129 NULL
100487 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
100488 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
100489 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
100490 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
100491 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
100492 +btrfs_mksubvol_58240 btrfs_mksubvol 3 58240 NULL
100493 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
100494 +read_file_debug_58256 read_file_debug 3 58256 NULL
100495 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
100496 +profile_load_58267 profile_load 3 58267 NULL
100497 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
100498 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
100499 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
100500 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
100501 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
100502 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
100503 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
100504 +ieee80211_send_probe_req_58337 ieee80211_send_probe_req 4-6 58337 NULL
100505 +next_pidmap_58347 next_pidmap 2 58347 NULL
100506 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
100507 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
100508 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
100509 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
100510 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
100511 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
100512 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
100513 +capabilities_read_58457 capabilities_read 3 58457 NULL
100514 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
100515 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
100516 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
100517 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
100518 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
100519 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
100520 +wm831x_reg_write_58489 wm831x_reg_write 2 58489 NULL
100521 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
100522 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
100523 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
100524 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
100525 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
100526 +xip_file_read_58592 xip_file_read 3 58592 NULL
100527 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
100528 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
100529 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
100530 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
100531 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
100532 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
100533 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
100534 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
100535 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
100536 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
100537 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
100538 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
100539 +acpi_map_58725 acpi_map 1-2 58725 NULL
100540 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
100541 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
100542 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
100543 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
100544 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
100545 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
100546 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
100547 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
100548 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
100549 +ep_read_58813 ep_read 3 58813 NULL
100550 +command_write_58841 command_write 3 58841 NULL
100551 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
100552 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
100553 +hw_write_58881 hw_write 2 58881 NULL
100554 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
100555 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
100556 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
100557 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
100558 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
100559 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
100560 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
100561 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
100562 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
100563 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
100564 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
100565 +ep_write_59008 ep_write 3 59008 NULL
100566 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
100567 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
100568 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
100569 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
100570 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
100571 +da9052_gpio_direction_input_59062 da9052_gpio_direction_input 2 59062 NULL
100572 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
100573 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
100574 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
100575 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
100576 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
100577 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
100578 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
100579 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
100580 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
100581 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
100582 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
100583 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
100584 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
100585 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
100586 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
100587 +dt3155_read_59226 dt3155_read 3 59226 NULL
100588 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
100589 +rbd_do_request_59239 rbd_do_request 6-7 59239 NULL
100590 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
100591 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
100592 +nla_len_59258 nla_len 0 59258 NULL
100593 +da9055_reg_update_59280 da9055_reg_update 2 59280 NULL
100594 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
100595 +fd_copyout_59323 fd_copyout 3 59323 NULL
100596 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
100597 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
100598 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL
100599 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
100600 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
100601 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
100602 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
100603 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
100604 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
100605 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
100606 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
100607 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
100608 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
100609 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
100610 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
100611 +rds_pin_pages_59507 rds_pin_pages 0 59507 NULL
100612 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
100613 +tunables_write_59563 tunables_write 3 59563 NULL
100614 +memdup_user_59590 memdup_user 2 59590 NULL
100615 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
100616 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
100617 +mtrr_write_59622 mtrr_write 3 59622 NULL
100618 +ip_vs_icmp_xmit_59624 ip_vs_icmp_xmit 4 59624 NULL
100619 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
100620 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
100621 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
100622 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
100623 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
100624 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
100625 +wm8400_write_59675 wm8400_write 2 59675 NULL
100626 +sriov_enable_59689 sriov_enable 2 59689 NULL
100627 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
100628 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
100629 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
100630 +wm8996_gpio_direction_in_59739 wm8996_gpio_direction_in 2 59739 NULL
100631 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
100632 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
100633 +strnlen_59746 strnlen 0 59746 NULL
100634 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
100635 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
100636 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
100637 +sec_reg_update_59771 sec_reg_update 2 59771 NULL
100638 +venus_remove_59781 venus_remove 4 59781 NULL
100639 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
100640 +ipw_write_59807 ipw_write 3 59807 NULL
100641 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
100642 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
100643 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
100644 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
100645 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
100646 +tun_put_user_59849 tun_put_user 4 59849 NULL
100647 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
100648 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
100649 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
100650 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
100651 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
100652 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 NULL nohasharray
100653 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 &compat_ipmi_ioctl_59956
100654 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
100655 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
100656 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
100657 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
100658 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
100659 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
100660 +register_device_60015 register_device 2-3 60015 NULL
100661 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
100662 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
100663 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
100664 +ceph_calc_raw_layout_60035 ceph_calc_raw_layout 4 60035 NULL
100665 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
100666 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
100667 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
100668 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
100669 +load_module_60056 load_module 2 60056 NULL nohasharray
100670 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 &load_module_60056
100671 +compat_writev_60063 compat_writev 3 60063 NULL
100672 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 8-6 60064 NULL
100673 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
100674 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
100675 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
100676 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
100677 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
100678 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
100679 +init_state_60165 init_state 2 60165 NULL
100680 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
100681 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
100682 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
100683 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
100684 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
100685 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
100686 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
100687 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
100688 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
100689 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
100690 +lp8788_select_buck_vout_addr_60241 lp8788_select_buck_vout_addr 0 60241 NULL
100691 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
100692 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
100693 +printer_write_60276 printer_write 3 60276 NULL
100694 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
100695 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
100696 +getDataLength_60301 getDataLength 0 60301 NULL
100697 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
100698 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
100699 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
100700 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
100701 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
100702 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
100703 +driver_names_read_60399 driver_names_read 3 60399 NULL
100704 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
100705 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
100706 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
100707 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
100708 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
100709 +rx_data_60442 rx_data 4 60442 NULL
100710 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
100711 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
100712 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
100713 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
100714 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
100715 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
100716 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
100717 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
100718 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
100719 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
100720 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
100721 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
100722 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
100723 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
100724 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
100725 +init_data_container_60709 init_data_container 1 60709 NULL
100726 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
100727 +raid_status_60755 raid_status 5 60755 NULL
100728 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
100729 +opticon_write_60775 opticon_write 4 60775 NULL
100730 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
100731 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
100732 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
100733 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
100734 +alloc_irq_from_60868 alloc_irq_from 1 60868 NULL
100735 +generic_writepages_60871 generic_writepages 0 60871 NULL
100736 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
100737 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
100738 +wm8962_gpio_set_60894 wm8962_gpio_set 2 60894 NULL
100739 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
100740 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
100741 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
100742 +pti_char_write_60960 pti_char_write 3 60960 NULL
100743 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
100744 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
100745 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
100746 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
100747 +symtab_init_61050 symtab_init 2 61050 NULL
100748 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
100749 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
100750 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
100751 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
100752 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
100753 +get_derived_key_61100 get_derived_key 4 61100 NULL
100754 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
100755 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
100756 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
100757 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
100758 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
100759 +__vmalloc_61168 __vmalloc 1 61168 NULL
100760 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
100761 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
100762 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
100763 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
100764 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
100765 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
100766 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
100767 +sys_add_key_61288 sys_add_key 4 61288 NULL
100768 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
100769 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
100770 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
100771 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
100772 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
100773 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
100774 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
100775 +change_xattr_61390 change_xattr 5 61390 NULL
100776 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
100777 +irq_create_of_mapping_61428 irq_create_of_mapping 0 61428 NULL
100778 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
100779 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
100780 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
100781 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
100782 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
100783 +mc13xxx_reg_write_61490 mc13xxx_reg_write 2 61490 NULL
100784 +erst_errno_61526 erst_errno 0 61526 NULL
100785 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
100786 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
100787 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
100788 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
100789 +seq_open_private_61589 seq_open_private 3 61589 NULL
100790 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
100791 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
100792 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
100793 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
100794 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
100795 +ieee80211_rx_bss_info_61630 ieee80211_rx_bss_info 3 61630 NULL
100796 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
100797 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
100798 +resize_stripes_61650 resize_stripes 2 61650 NULL
100799 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
100800 +insert_one_name_61668 insert_one_name 7 61668 NULL
100801 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
100802 +lock_loop_61681 lock_loop 1 61681 NULL
100803 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
100804 +filter_read_61692 filter_read 3 61692 NULL
100805 +iov_length_61716 iov_length 0 61716 NULL
100806 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
100807 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
100808 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
100809 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
100810 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
100811 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
100812 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
100813 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
100814 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
100815 +get_fw_name_61874 get_fw_name 3 61874 NULL
100816 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
100817 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
100818 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
100819 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
100820 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
100821 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
100822 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
100823 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
100824 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
100825 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
100826 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
100827 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
100828 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
100829 +cow_file_range_61979 cow_file_range 3 61979 NULL
100830 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
100831 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
100832 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
100833 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
100834 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
100835 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
100836 +do_pselect_62061 do_pselect 1 62061 NULL
100837 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
100838 +__next_gcwq_cpu_62078 __next_gcwq_cpu 1 62078 NULL
100839 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
100840 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
100841 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
100842 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
100843 +ql_status_62135 ql_status 5 62135 NULL
100844 +video_usercopy_62151 video_usercopy 2 62151 NULL
100845 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
100846 +_irq_to_addr_62183 _irq_to_addr 0-1 62183 NULL
100847 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
100848 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
100849 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
100850 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
100851 +allocate_partition_62245 allocate_partition 4 62245 NULL
100852 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
100853 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
100854 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
100855 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
100856 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
100857 +subseq_list_62332 subseq_list 3-0 62332 NULL
100858 +flash_write_62354 flash_write 3 62354 NULL
100859 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
100860 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
100861 +altera_irscan_62396 altera_irscan 2 62396 NULL
100862 +set_ssp_62411 set_ssp 4 62411 NULL
100863 +tscadc_writel_62426 tscadc_writel 2 62426 NULL
100864 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
100865 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
100866 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
100867 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
100868 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
100869 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
100870 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
100871 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
100872 +debugfs_read_62535 debugfs_read 3 62535 NULL
100873 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
100874 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
100875 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
100876 +get_subdir_62581 get_subdir 3 62581 NULL
100877 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
100878 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
100879 +get_desc_base_62617 get_desc_base 0 62617 NULL
100880 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
100881 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
100882 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
100883 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
100884 +wm8994_gpio_direction_in_62649 wm8994_gpio_direction_in 2 62649 NULL
100885 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
100886 +write_62671 write 3 62671 NULL
100887 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
100888 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
100889 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
100890 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
100891 +rdm_62719 rdm 0 62719 NULL
100892 +key_replays_read_62746 key_replays_read 3 62746 NULL
100893 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
100894 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
100895 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
100896 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
100897 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
100898 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
100899 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
100900 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
100901 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
100902 +aoechr_write_62883 aoechr_write 3 62883 NULL nohasharray
100903 +em28xx_init_isoc_62883 em28xx_init_isoc 4 62883 &aoechr_write_62883
100904 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
100905 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
100906 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
100907 +getdqbuf_62908 getdqbuf 1 62908 NULL
100908 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
100909 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
100910 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
100911 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
100912 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
100913 +unlink1_63059 unlink1 3 63059 NULL
100914 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
100915 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
100916 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
100917 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
100918 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
100919 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
100920 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
100921 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
100922 +vme_master_read_63221 vme_master_read 0 63221 NULL
100923 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
100924 +ptp_read_63251 ptp_read 4 63251 NULL
100925 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
100926 +raid5_resize_63306 raid5_resize 2 63306 NULL
100927 +proc_info_read_63344 proc_info_read 3 63344 NULL
100928 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
100929 +idmouse_read_63374 idmouse_read 3 63374 NULL
100930 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
100931 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
100932 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
100933 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
100934 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
100935 +kone_send_63435 kone_send 4 63435 NULL
100936 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
100937 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
100938 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
100939 +read_kcore_63488 read_kcore 3 63488 NULL
100940 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
100941 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
100942 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
100943 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
100944 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
100945 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 &dbg_leb_write_63555
100946 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
100947 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
100948 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
100949 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
100950 +module_alloc_63630 module_alloc 1 63630 NULL
100951 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
100952 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
100953 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
100954 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
100955 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
100956 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
100957 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
100958 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
100959 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
100960 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
100961 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
100962 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
100963 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
100964 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
100965 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
100966 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
100967 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
100968 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
100969 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
100970 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
100971 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
100972 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
100973 +sel_write_load_63830 sel_write_load 3 63830 NULL
100974 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
100975 +ieee80211_if_fmt_channel_type_63855 ieee80211_if_fmt_channel_type 3 63855 NULL
100976 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
100977 +divas_write_63901 divas_write 3 63901 NULL
100978 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
100979 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
100980 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
100981 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
100982 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
100983 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
100984 +__team_options_register_63941 __team_options_register 3 63941 NULL
100985 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
100986 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
100987 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
100988 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
100989 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
100990 +kmemdup_64015 kmemdup 2 64015 NULL
100991 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 NULL
100992 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
100993 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
100994 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
100995 +get_u8_64076 get_u8 0 64076 NULL
100996 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
100997 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
100998 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
100999 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
101000 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
101001 +init_bch_64130 init_bch 1-2 64130 NULL
101002 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
101003 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
101004 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
101005 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
101006 +read_pulse_64227 read_pulse 0-3 64227 NULL
101007 +header_len_64232 header_len 0 64232 NULL
101008 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
101009 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
101010 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
101011 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
101012 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
101013 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
101014 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
101015 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
101016 +ffz_64324 ffz 0 64324 NULL
101017 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
101018 +ts_write_64336 ts_write 3 64336 NULL
101019 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
101020 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
101021 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
101022 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
101023 +ilo_write_64378 ilo_write 3 64378 NULL
101024 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
101025 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
101026 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
101027 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
101028 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
101029 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
101030 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
101031 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
101032 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
101033 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL
101034 +ieee80211_ie_build_ht_cap_64443 ieee80211_ie_build_ht_cap 0 64443 NULL
101035 +cap_capable_64462 cap_capable 0 64462 NULL
101036 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
101037 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
101038 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
101039 +remove_uuid_64505 remove_uuid 4 64505 NULL
101040 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
101041 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
101042 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
101043 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
101044 +__spi_sync_64561 __spi_sync 0 64561 NULL
101045 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
101046 +fanotify_write_64623 fanotify_write 3 64623 NULL
101047 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
101048 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
101049 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
101050 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
101051 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
101052 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
101053 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
101054 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
101055 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
101056 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
101057 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
101058 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
101059 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
101060 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
101061 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
101062 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
101063 +twl6040_reg_write_64790 twl6040_reg_write 2 64790 NULL
101064 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
101065 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
101066 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
101067 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
101068 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
101069 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
101070 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
101071 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
101072 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
101073 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
101074 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
101075 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
101076 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
101077 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
101078 +pskb_pull_65005 pskb_pull 2 65005 NULL
101079 +unifi_write_65012 unifi_write 3 65012 NULL
101080 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
101081 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
101082 +insert_dent_65034 insert_dent 7 65034 NULL
101083 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
101084 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
101085 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
101086 +make_idx_node_65068 make_idx_node 0 65068 NULL
101087 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
101088 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
101089 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
101090 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
101091 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
101092 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
101093 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
101094 +print_endpoint_stat_65232 print_endpoint_stat 0-4-3 65232 NULL
101095 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
101096 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
101097 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
101098 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
101099 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
101100 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
101101 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
101102 +get_var_len_65304 get_var_len 0 65304 NULL
101103 +unpack_array_65318 unpack_array 0 65318 NULL
101104 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
101105 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
101106 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
101107 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
101108 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
101109 +strchr_65372 strchr 0 65372 NULL
101110 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
101111 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
101112 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
101113 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
101114 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
101115 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
101116 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
101117 +pn533_init_target_frame_65438 pn533_init_target_frame 3 65438 NULL
101118 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
101119 +regmap_write_65478 regmap_write 2 65478 NULL
101120 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
101121 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
101122 +alloc_dr_65495 alloc_dr 2 65495 NULL
101123 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
101124 new file mode 100644
101125 index 0000000..9db0d0e
101126 --- /dev/null
101127 +++ b/tools/gcc/size_overflow_plugin.c
101128 @@ -0,0 +1,2114 @@
101129 +/*
101130 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
101131 + * Licensed under the GPL v2, or (at your option) v3
101132 + *
101133 + * Homepage:
101134 + * http://www.grsecurity.net/~ephox/overflow_plugin/
101135 + *
101136 + * Documentation:
101137 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
101138 + *
101139 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
101140 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
101141 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
101142 + *
101143 + * Usage:
101144 + * $ 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
101145 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
101146 + */
101147 +
101148 +#include "gcc-plugin.h"
101149 +#include "config.h"
101150 +#include "system.h"
101151 +#include "coretypes.h"
101152 +#include "tree.h"
101153 +#include "tree-pass.h"
101154 +#include "intl.h"
101155 +#include "plugin-version.h"
101156 +#include "tm.h"
101157 +#include "toplev.h"
101158 +#include "function.h"
101159 +#include "tree-flow.h"
101160 +#include "plugin.h"
101161 +#include "gimple.h"
101162 +#include "diagnostic.h"
101163 +#include "cfgloop.h"
101164 +
101165 +#if BUILDING_GCC_VERSION >= 4008
101166 +#define TODO_dump_func 0
101167 +#endif
101168 +
101169 +struct size_overflow_hash {
101170 + const struct size_overflow_hash * const next;
101171 + const char * const name;
101172 + const unsigned int param;
101173 +};
101174 +
101175 +#include "size_overflow_hash.h"
101176 +
101177 +enum mark {
101178 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
101179 +};
101180 +
101181 +enum err_code_conditions {
101182 + CAST_ONLY, FROM_CONST
101183 +};
101184 +
101185 +static unsigned int call_count = 0;
101186 +
101187 +#define __unused __attribute__((__unused__))
101188 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
101189 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
101190 +#define BEFORE_STMT true
101191 +#define AFTER_STMT false
101192 +#define CREATE_NEW_VAR NULL_TREE
101193 +#define CODES_LIMIT 32
101194 +#define MAX_PARAM 31
101195 +#define MY_STMT GF_PLF_1
101196 +#define NO_CAST_CHECK GF_PLF_2
101197 +#define FROM_ARG true
101198 +#define FROM_RET false
101199 +
101200 +#if BUILDING_GCC_VERSION == 4005
101201 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
101202 +#endif
101203 +
101204 +int plugin_is_GPL_compatible;
101205 +void debug_gimple_stmt(gimple gs);
101206 +
101207 +static tree expand(struct pointer_set_t *visited, tree lhs);
101208 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
101209 +static tree report_size_overflow_decl;
101210 +static const_tree const_char_ptr_type_node;
101211 +static unsigned int handle_function(void);
101212 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
101213 +static tree get_size_overflow_type(gimple stmt, const_tree node);
101214 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
101215 +static void print_missing_msg(tree func, unsigned int argnum);
101216 +
101217 +static struct plugin_info size_overflow_plugin_info = {
101218 + .version = "20130410beta",
101219 + .help = "no-size-overflow\tturn off size overflow checking\n",
101220 +};
101221 +
101222 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101223 +{
101224 + unsigned int arg_count;
101225 + enum tree_code code = TREE_CODE(*node);
101226 +
101227 + switch (code) {
101228 + case FUNCTION_DECL:
101229 + arg_count = type_num_arguments(TREE_TYPE(*node));
101230 + break;
101231 + case FUNCTION_TYPE:
101232 + case METHOD_TYPE:
101233 + arg_count = type_num_arguments(*node);
101234 + break;
101235 + default:
101236 + *no_add_attrs = true;
101237 + error("%s: %qE attribute only applies to functions", __func__, name);
101238 + return NULL_TREE;
101239 + }
101240 +
101241 + for (; args; args = TREE_CHAIN(args)) {
101242 + tree position = TREE_VALUE(args);
101243 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101244 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101245 + *no_add_attrs = true;
101246 + }
101247 + }
101248 + return NULL_TREE;
101249 +}
101250 +
101251 +static const char* get_asm_name(tree node)
101252 +{
101253 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
101254 +}
101255 +
101256 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101257 +{
101258 + unsigned int arg_count, arg_num;
101259 + enum tree_code code = TREE_CODE(*node);
101260 +
101261 + switch (code) {
101262 + case FUNCTION_DECL:
101263 + arg_count = type_num_arguments(TREE_TYPE(*node));
101264 + break;
101265 + case FUNCTION_TYPE:
101266 + case METHOD_TYPE:
101267 + arg_count = type_num_arguments(*node);
101268 + break;
101269 + case FIELD_DECL:
101270 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
101271 + if (arg_num != 0) {
101272 + *no_add_attrs = true;
101273 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
101274 + }
101275 + return NULL_TREE;
101276 + default:
101277 + *no_add_attrs = true;
101278 + error("%qE attribute only applies to functions", name);
101279 + return NULL_TREE;
101280 + }
101281 +
101282 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
101283 + return NULL_TREE;
101284 +
101285 + for (; args; args = TREE_CHAIN(args)) {
101286 + tree position = TREE_VALUE(args);
101287 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101288 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101289 + *no_add_attrs = true;
101290 + }
101291 + }
101292 + return NULL_TREE;
101293 +}
101294 +
101295 +static struct attribute_spec size_overflow_attr = {
101296 + .name = "size_overflow",
101297 + .min_length = 1,
101298 + .max_length = -1,
101299 + .decl_required = true,
101300 + .type_required = false,
101301 + .function_type_required = false,
101302 + .handler = handle_size_overflow_attribute,
101303 +#if BUILDING_GCC_VERSION >= 4007
101304 + .affects_type_identity = false
101305 +#endif
101306 +};
101307 +
101308 +static struct attribute_spec intentional_overflow_attr = {
101309 + .name = "intentional_overflow",
101310 + .min_length = 1,
101311 + .max_length = -1,
101312 + .decl_required = true,
101313 + .type_required = false,
101314 + .function_type_required = false,
101315 + .handler = handle_intentional_overflow_attribute,
101316 +#if BUILDING_GCC_VERSION >= 4007
101317 + .affects_type_identity = false
101318 +#endif
101319 +};
101320 +
101321 +static void register_attributes(void __unused *event_data, void __unused *data)
101322 +{
101323 + register_attribute(&size_overflow_attr);
101324 + register_attribute(&intentional_overflow_attr);
101325 +}
101326 +
101327 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
101328 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
101329 +{
101330 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
101331 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
101332 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
101333 +
101334 + unsigned int m = 0x57559429;
101335 + unsigned int n = 0x5052acdb;
101336 + const unsigned int *key4 = (const unsigned int *)key;
101337 + unsigned int h = len;
101338 + unsigned int k = len + seed + n;
101339 + unsigned long long p;
101340 +
101341 + while (len >= 8) {
101342 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
101343 + len -= 8;
101344 + }
101345 + if (len >= 4) {
101346 + cwmixb(key4[0]) key4 += 1;
101347 + len -= 4;
101348 + }
101349 + if (len)
101350 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
101351 + cwmixb(h ^ (k + n));
101352 + return k ^ h;
101353 +
101354 +#undef cwfold
101355 +#undef cwmixa
101356 +#undef cwmixb
101357 +}
101358 +
101359 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
101360 +{
101361 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
101362 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
101363 + return fn ^ codes;
101364 +}
101365 +
101366 +static inline tree get_original_function_decl(tree fndecl)
101367 +{
101368 + if (DECL_ABSTRACT_ORIGIN(fndecl))
101369 + return DECL_ABSTRACT_ORIGIN(fndecl);
101370 + return fndecl;
101371 +}
101372 +
101373 +static inline gimple get_def_stmt(const_tree node)
101374 +{
101375 + gcc_assert(node != NULL_TREE);
101376 + if (TREE_CODE(node) != SSA_NAME)
101377 + return NULL;
101378 + return SSA_NAME_DEF_STMT(node);
101379 +}
101380 +
101381 +static unsigned char get_tree_code(const_tree type)
101382 +{
101383 + switch (TREE_CODE(type)) {
101384 + case ARRAY_TYPE:
101385 + return 0;
101386 + case BOOLEAN_TYPE:
101387 + return 1;
101388 + case ENUMERAL_TYPE:
101389 + return 2;
101390 + case FUNCTION_TYPE:
101391 + return 3;
101392 + case INTEGER_TYPE:
101393 + return 4;
101394 + case POINTER_TYPE:
101395 + return 5;
101396 + case RECORD_TYPE:
101397 + return 6;
101398 + case UNION_TYPE:
101399 + return 7;
101400 + case VOID_TYPE:
101401 + return 8;
101402 + case REAL_TYPE:
101403 + return 9;
101404 + case VECTOR_TYPE:
101405 + return 10;
101406 + case REFERENCE_TYPE:
101407 + return 11;
101408 + case OFFSET_TYPE:
101409 + return 12;
101410 + case COMPLEX_TYPE:
101411 + return 13;
101412 + default:
101413 + debug_tree((tree)type);
101414 + gcc_unreachable();
101415 + }
101416 +}
101417 +
101418 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
101419 +{
101420 + gcc_assert(type != NULL_TREE);
101421 +
101422 + while (type && len < CODES_LIMIT) {
101423 + tree_codes[len] = get_tree_code(type);
101424 + len++;
101425 + type = TREE_TYPE(type);
101426 + }
101427 + return len;
101428 +}
101429 +
101430 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
101431 +{
101432 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
101433 + enum tree_code code = TREE_CODE(type);
101434 + size_t len = 0;
101435 +
101436 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
101437 +
101438 + arg = TYPE_ARG_TYPES(type);
101439 + // skip builtins __builtin_constant_p
101440 + if (!arg && DECL_BUILT_IN(fndecl))
101441 + return 0;
101442 +
101443 + if (TREE_CODE_CLASS(code) == tcc_type)
101444 + result = type;
101445 + else
101446 + result = DECL_RESULT(fndecl);
101447 +
101448 + gcc_assert(result != NULL_TREE);
101449 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
101450 +
101451 + if (arg == NULL_TREE) {
101452 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
101453 + arg_field = DECL_ARGUMENT_FLD(fndecl);
101454 + if (arg_field == NULL_TREE)
101455 + return 0;
101456 + arg = TREE_TYPE(arg_field);
101457 + len = add_type_codes(arg, tree_codes, len);
101458 + gcc_assert(len != 0);
101459 + return len;
101460 + }
101461 +
101462 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
101463 + while (arg && len < CODES_LIMIT) {
101464 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
101465 + arg = TREE_CHAIN(arg);
101466 + }
101467 +
101468 + gcc_assert(len != 0);
101469 + return len;
101470 +}
101471 +
101472 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
101473 +{
101474 + unsigned int hash;
101475 + const struct size_overflow_hash *entry;
101476 + unsigned char tree_codes[CODES_LIMIT];
101477 + size_t len;
101478 + const char *func_name;
101479 +
101480 + fndecl = get_original_function_decl(fndecl);
101481 + len = get_function_decl(fndecl, tree_codes);
101482 + if (len == 0)
101483 + return NULL;
101484 +
101485 + func_name = get_asm_name(fndecl);
101486 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
101487 +
101488 + entry = size_overflow_hash[hash];
101489 + while (entry) {
101490 + if (!strcmp(entry->name, func_name))
101491 + return entry;
101492 + entry = entry->next;
101493 + }
101494 +
101495 + return NULL;
101496 +}
101497 +
101498 +static bool is_bool(const_tree node)
101499 +{
101500 + const_tree type;
101501 +
101502 + if (node == NULL_TREE)
101503 + return false;
101504 +
101505 + type = TREE_TYPE(node);
101506 + if (!INTEGRAL_TYPE_P(type))
101507 + return false;
101508 + if (TREE_CODE(type) == BOOLEAN_TYPE)
101509 + return true;
101510 + if (TYPE_PRECISION(type) == 1)
101511 + return true;
101512 + return false;
101513 +}
101514 +
101515 +static bool skip_types(const_tree var)
101516 +{
101517 + tree type;
101518 +
101519 + if (is_gimple_constant(var))
101520 + return true;
101521 +
101522 + switch (TREE_CODE(var)) {
101523 + case ADDR_EXPR:
101524 +#if BUILDING_GCC_VERSION >= 4006
101525 + case MEM_REF:
101526 +#endif
101527 + case ARRAY_REF:
101528 + case BIT_FIELD_REF:
101529 + case INDIRECT_REF:
101530 + case TARGET_MEM_REF:
101531 + return true;
101532 + case PARM_DECL:
101533 + case VAR_DECL:
101534 + case COMPONENT_REF:
101535 + return false;
101536 + default:
101537 + break;
101538 + }
101539 +
101540 + gcc_assert(TREE_CODE(var) == SSA_NAME);
101541 +
101542 + type = TREE_TYPE(var);
101543 + switch (TREE_CODE(type)) {
101544 + case INTEGER_TYPE:
101545 + case ENUMERAL_TYPE:
101546 + return false;
101547 + case BOOLEAN_TYPE:
101548 + return is_bool(var);
101549 + default:
101550 + break;
101551 + }
101552 +
101553 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
101554 +
101555 + type = TREE_TYPE(type);
101556 + gcc_assert(type != NULL_TREE);
101557 + switch (TREE_CODE(type)) {
101558 + case RECORD_TYPE:
101559 + case POINTER_TYPE:
101560 + case ARRAY_TYPE:
101561 + return true;
101562 + case VOID_TYPE:
101563 + case INTEGER_TYPE:
101564 + case UNION_TYPE:
101565 + return false;
101566 + default:
101567 + break;
101568 + }
101569 +
101570 + debug_tree((tree)var);
101571 + gcc_unreachable();
101572 +}
101573 +
101574 +static unsigned int find_arg_number(const_tree arg, tree func)
101575 +{
101576 + tree var;
101577 + unsigned int argnum = 1;
101578 +
101579 + if (TREE_CODE(arg) == SSA_NAME)
101580 + arg = SSA_NAME_VAR(arg);
101581 +
101582 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
101583 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
101584 + continue;
101585 + if (!skip_types(var))
101586 + return argnum;
101587 + }
101588 +
101589 + return 0;
101590 +}
101591 +
101592 +static tree create_new_var(tree type)
101593 +{
101594 + tree new_var = create_tmp_var(type, "cicus");
101595 +
101596 +#if BUILDING_GCC_VERSION <= 4007
101597 + add_referenced_var(new_var);
101598 + mark_sym_for_renaming(new_var);
101599 +#endif
101600 + return new_var;
101601 +}
101602 +
101603 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
101604 +{
101605 + gimple assign;
101606 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101607 + tree type = TREE_TYPE(rhs1);
101608 + tree lhs = create_new_var(type);
101609 +
101610 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
101611 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
101612 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101613 +
101614 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101615 + update_stmt(assign);
101616 + gimple_set_plf(assign, MY_STMT, true);
101617 + return assign;
101618 +}
101619 +
101620 +static tree cast_a_tree(tree type, tree var)
101621 +{
101622 + gcc_assert(type != NULL_TREE);
101623 + gcc_assert(var != NULL_TREE);
101624 + gcc_assert(fold_convertible_p(type, var));
101625 +
101626 + return fold_convert(type, var);
101627 +}
101628 +
101629 +static tree get_lhs(const_gimple stmt)
101630 +{
101631 + switch (gimple_code(stmt)) {
101632 + case GIMPLE_ASSIGN:
101633 + return gimple_get_lhs(stmt);
101634 + case GIMPLE_PHI:
101635 + return gimple_phi_result(stmt);
101636 + case GIMPLE_CALL:
101637 + return gimple_call_lhs(stmt);
101638 + default:
101639 + return NULL_TREE;
101640 + }
101641 +}
101642 +
101643 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
101644 +{
101645 + const_gimple def_stmt = get_def_stmt(rhs);
101646 +
101647 + if (force)
101648 + return false;
101649 +
101650 + if (is_gimple_constant(rhs))
101651 + return false;
101652 +
101653 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101654 + return false;
101655 +
101656 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
101657 + return false;
101658 +
101659 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
101660 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101661 + return false;
101662 +
101663 + return true;
101664 +}
101665 +
101666 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
101667 +{
101668 + gimple assign, def_stmt;
101669 +
101670 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
101671 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
101672 + gcc_unreachable();
101673 +
101674 + def_stmt = get_def_stmt(rhs);
101675 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
101676 + return def_stmt;
101677 +
101678 + if (lhs == CREATE_NEW_VAR)
101679 + lhs = create_new_var(dst_type);
101680 +
101681 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
101682 +
101683 + if (!gsi_end_p(*gsi)) {
101684 + location_t loc = gimple_location(gsi_stmt(*gsi));
101685 + gimple_set_location(assign, loc);
101686 + }
101687 +
101688 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101689 +
101690 + if (before)
101691 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
101692 + else
101693 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
101694 + update_stmt(assign);
101695 + gimple_set_plf(assign, MY_STMT, true);
101696 +
101697 + return assign;
101698 +}
101699 +
101700 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
101701 +{
101702 + gimple_stmt_iterator gsi;
101703 + tree lhs;
101704 + const_gimple new_stmt;
101705 +
101706 + if (rhs == NULL_TREE)
101707 + return NULL_TREE;
101708 +
101709 + gsi = gsi_for_stmt(stmt);
101710 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
101711 +
101712 + lhs = get_lhs(new_stmt);
101713 + gcc_assert(lhs != NULL_TREE);
101714 + return lhs;
101715 +}
101716 +
101717 +static tree cast_to_TI_type(gimple stmt, tree node)
101718 +{
101719 + gimple_stmt_iterator gsi;
101720 + gimple cast_stmt;
101721 + tree type = TREE_TYPE(node);
101722 +
101723 + if (types_compatible_p(type, intTI_type_node))
101724 + return node;
101725 +
101726 + gsi = gsi_for_stmt(stmt);
101727 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101728 + return gimple_get_lhs(cast_stmt);
101729 +}
101730 +
101731 +static void check_function_hash(const_gimple stmt)
101732 +{
101733 + tree func;
101734 + const struct size_overflow_hash *hash;
101735 +
101736 + if (gimple_code(stmt) != GIMPLE_CALL)
101737 + return;
101738 +
101739 + func = gimple_call_fndecl(stmt);
101740 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
101741 + if (func == NULL_TREE)
101742 + return;
101743 +
101744 + hash = get_function_hash(func);
101745 + if (!hash)
101746 + print_missing_msg(func, 0);
101747 +}
101748 +
101749 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
101750 +{
101751 + tree lhs, new_lhs;
101752 + gimple_stmt_iterator gsi;
101753 +
101754 + if (rhs1 == NULL_TREE) {
101755 + debug_gimple_stmt(oldstmt);
101756 + error("%s: rhs1 is NULL_TREE", __func__);
101757 + gcc_unreachable();
101758 + }
101759 +
101760 + switch (gimple_code(oldstmt)) {
101761 + case GIMPLE_ASM:
101762 + lhs = rhs1;
101763 + break;
101764 + case GIMPLE_CALL:
101765 + lhs = gimple_call_lhs(oldstmt);
101766 + break;
101767 + case GIMPLE_ASSIGN:
101768 + lhs = gimple_get_lhs(oldstmt);
101769 + break;
101770 + default:
101771 + debug_gimple_stmt(oldstmt);
101772 + gcc_unreachable();
101773 + }
101774 +
101775 + gsi = gsi_for_stmt(oldstmt);
101776 + pointer_set_insert(visited, oldstmt);
101777 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
101778 + basic_block next_bb, cur_bb;
101779 + const_edge e;
101780 +
101781 + gcc_assert(before == false);
101782 + gcc_assert(stmt_can_throw_internal(oldstmt));
101783 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
101784 + gcc_assert(!gsi_end_p(gsi));
101785 +
101786 + cur_bb = gimple_bb(oldstmt);
101787 + next_bb = cur_bb->next_bb;
101788 + e = find_edge(cur_bb, next_bb);
101789 + gcc_assert(e != NULL);
101790 + gcc_assert(e->flags & EDGE_FALLTHRU);
101791 +
101792 + gsi = gsi_after_labels(next_bb);
101793 + gcc_assert(!gsi_end_p(gsi));
101794 +
101795 + before = true;
101796 + oldstmt = gsi_stmt(gsi);
101797 + }
101798 +
101799 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
101800 + return new_lhs;
101801 +}
101802 +
101803 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
101804 +{
101805 + gimple stmt;
101806 + gimple_stmt_iterator gsi;
101807 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
101808 +
101809 + if (gimple_plf(oldstmt, MY_STMT))
101810 + return lhs;
101811 +
101812 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
101813 + rhs1 = gimple_assign_rhs1(oldstmt);
101814 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
101815 + }
101816 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
101817 + rhs2 = gimple_assign_rhs2(oldstmt);
101818 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
101819 + }
101820 +
101821 + stmt = gimple_copy(oldstmt);
101822 + gimple_set_location(stmt, gimple_location(oldstmt));
101823 + gimple_set_plf(stmt, MY_STMT, true);
101824 +
101825 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
101826 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
101827 +
101828 + size_overflow_type = get_size_overflow_type(oldstmt, node);
101829 +
101830 + new_var = create_new_var(size_overflow_type);
101831 + new_var = make_ssa_name(new_var, stmt);
101832 + gimple_set_lhs(stmt, new_var);
101833 +
101834 + if (rhs1 != NULL_TREE)
101835 + gimple_assign_set_rhs1(stmt, rhs1);
101836 +
101837 + if (rhs2 != NULL_TREE)
101838 + gimple_assign_set_rhs2(stmt, rhs2);
101839 +#if BUILDING_GCC_VERSION >= 4007
101840 + if (rhs3 != NULL_TREE)
101841 + gimple_assign_set_rhs3(stmt, rhs3);
101842 +#endif
101843 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
101844 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
101845 +
101846 + gsi = gsi_for_stmt(oldstmt);
101847 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
101848 + update_stmt(stmt);
101849 + pointer_set_insert(visited, oldstmt);
101850 + return gimple_get_lhs(stmt);
101851 +}
101852 +
101853 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
101854 +{
101855 + basic_block first_bb;
101856 + gimple assign;
101857 + gimple_stmt_iterator gsi;
101858 +
101859 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101860 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
101861 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
101862 +
101863 + gsi = gsi_start_bb(first_bb);
101864 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101865 + return gimple_get_lhs(assign);
101866 +}
101867 +
101868 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
101869 +{
101870 + gimple_stmt_iterator gsi;
101871 + const_gimple assign;
101872 + gimple def_stmt = get_def_stmt(new_arg);
101873 +
101874 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
101875 + gsi = gsi_after_labels(gimple_bb(def_stmt));
101876 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
101877 + } else {
101878 + gsi = gsi_for_stmt(def_stmt);
101879 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
101880 + }
101881 +
101882 + return gimple_get_lhs(assign);
101883 +}
101884 +
101885 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
101886 +{
101887 + basic_block bb;
101888 + gimple_stmt_iterator gsi;
101889 + const_gimple assign, def_stmt;
101890 +
101891 + def_stmt = get_def_stmt(arg);
101892 + bb = gimple_bb(def_stmt);
101893 + gcc_assert(bb->index != 0);
101894 + gsi = gsi_after_labels(bb);
101895 +
101896 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101897 + return gimple_get_lhs(assign);
101898 +}
101899 +
101900 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
101901 +{
101902 + tree size_overflow_type;
101903 + const_gimple def_stmt = get_def_stmt(arg);
101904 +
101905 + if (phi_ssa_name != NULL_TREE)
101906 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
101907 +
101908 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
101909 +
101910 + if (new_arg != NULL_TREE) {
101911 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
101912 + return use_phi_ssa_name(phi_ssa_name, new_arg);
101913 + }
101914 +
101915 + switch(gimple_code(def_stmt)) {
101916 + case GIMPLE_PHI:
101917 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
101918 + case GIMPLE_NOP:
101919 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
101920 + default:
101921 + debug_gimple_stmt((gimple)def_stmt);
101922 + gcc_unreachable();
101923 + }
101924 +}
101925 +
101926 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
101927 +{
101928 + basic_block bb;
101929 + gimple phi;
101930 + gimple_seq seq;
101931 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
101932 +
101933 + bb = gsi_bb(gsi);
101934 +
101935 + phi = create_phi_node(result, bb);
101936 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
101937 + seq = phi_nodes(bb);
101938 + gsi = gsi_last(seq);
101939 + gsi_remove(&gsi, false);
101940 +
101941 + gsi = gsi_for_stmt(oldstmt);
101942 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
101943 + gimple_set_bb(phi, bb);
101944 + gimple_set_plf(phi, MY_STMT, true);
101945 + return phi;
101946 +}
101947 +
101948 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
101949 +{
101950 + gimple new_phi = NULL;
101951 + gimple oldstmt = get_def_stmt(orig_result);
101952 + tree phi_ssa_name = NULL_TREE;
101953 + unsigned int i;
101954 +
101955 + pointer_set_insert(visited, oldstmt);
101956 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
101957 + tree arg, new_arg;
101958 +
101959 + arg = gimple_phi_arg_def(oldstmt, i);
101960 +
101961 + new_arg = expand(visited, arg);
101962 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
101963 + if (i == 0) {
101964 + phi_ssa_name = new_arg;
101965 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
101966 + }
101967 +
101968 + gcc_assert(new_phi != NULL);
101969 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
101970 + }
101971 +
101972 + gcc_assert(new_phi != NULL);
101973 + update_stmt(new_phi);
101974 + return gimple_phi_result(new_phi);
101975 +}
101976 +
101977 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
101978 +{
101979 + const_gimple assign;
101980 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101981 + tree origtype = TREE_TYPE(orig_rhs);
101982 +
101983 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
101984 +
101985 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101986 + return gimple_get_lhs(assign);
101987 +}
101988 +
101989 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
101990 +{
101991 + const_tree rhs1, lhs, rhs1_type, lhs_type;
101992 + enum machine_mode lhs_mode, rhs_mode;
101993 + gimple def_stmt = get_def_stmt(no_const_rhs);
101994 +
101995 + if (!gimple_assign_cast_p(def_stmt))
101996 + return false;
101997 +
101998 + rhs1 = gimple_assign_rhs1(def_stmt);
101999 + lhs = gimple_get_lhs(def_stmt);
102000 + rhs1_type = TREE_TYPE(rhs1);
102001 + lhs_type = TREE_TYPE(lhs);
102002 + rhs_mode = TYPE_MODE(rhs1_type);
102003 + lhs_mode = TYPE_MODE(lhs_type);
102004 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
102005 + return false;
102006 +
102007 + return true;
102008 +}
102009 +
102010 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
102011 +{
102012 + tree rhs1 = gimple_assign_rhs1(stmt);
102013 + tree lhs = gimple_get_lhs(stmt);
102014 + const_tree rhs1_type = TREE_TYPE(rhs1);
102015 + const_tree lhs_type = TREE_TYPE(lhs);
102016 +
102017 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
102018 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102019 +
102020 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
102021 +}
102022 +
102023 +static bool no_uses(tree node)
102024 +{
102025 + imm_use_iterator imm_iter;
102026 + use_operand_p use_p;
102027 +
102028 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
102029 + const_gimple use_stmt = USE_STMT(use_p);
102030 + if (use_stmt == NULL)
102031 + return true;
102032 + if (is_gimple_debug(use_stmt))
102033 + continue;
102034 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
102035 + continue;
102036 + return false;
102037 + }
102038 + return true;
102039 +}
102040 +
102041 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
102042 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
102043 +{
102044 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
102045 + gimple def_stmt = get_def_stmt(lhs);
102046 +
102047 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102048 + return false;
102049 +
102050 + rhs1 = gimple_assign_rhs1(def_stmt);
102051 + rhs_type = TREE_TYPE(rhs1);
102052 + lhs_type = TREE_TYPE(lhs);
102053 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
102054 + return false;
102055 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
102056 + return false;
102057 +
102058 + def_stmt = get_def_stmt(rhs1);
102059 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
102060 + return false;
102061 +
102062 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
102063 + return false;
102064 +
102065 + rhs1 = gimple_assign_rhs1(def_stmt);
102066 + rhs2 = gimple_assign_rhs2(def_stmt);
102067 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
102068 + return false;
102069 +
102070 + if (is_gimple_constant(rhs2))
102071 + not_const_rhs = rhs1;
102072 + else
102073 + not_const_rhs = rhs2;
102074 +
102075 + return no_uses(not_const_rhs);
102076 +}
102077 +
102078 +static bool skip_lhs_cast_check(const_gimple stmt)
102079 +{
102080 + const_tree rhs = gimple_assign_rhs1(stmt);
102081 + const_gimple def_stmt = get_def_stmt(rhs);
102082 +
102083 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
102084 + if (gimple_code(def_stmt) == GIMPLE_ASM)
102085 + return true;
102086 +
102087 + if (is_const_plus_unsigned_signed_truncation(rhs))
102088 + return true;
102089 +
102090 + return false;
102091 +}
102092 +
102093 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
102094 +{
102095 + bool cast_lhs, cast_rhs;
102096 + tree lhs = gimple_get_lhs(stmt);
102097 + tree rhs = gimple_assign_rhs1(stmt);
102098 + const_tree lhs_type = TREE_TYPE(lhs);
102099 + const_tree rhs_type = TREE_TYPE(rhs);
102100 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
102101 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
102102 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
102103 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
102104 +
102105 + static bool check_lhs[3][4] = {
102106 + // ss su us uu
102107 + { false, true, true, false }, // lhs > rhs
102108 + { false, false, false, false }, // lhs = rhs
102109 + { true, true, true, true }, // lhs < rhs
102110 + };
102111 +
102112 + static bool check_rhs[3][4] = {
102113 + // ss su us uu
102114 + { true, false, true, true }, // lhs > rhs
102115 + { true, false, true, true }, // lhs = rhs
102116 + { true, false, true, true }, // lhs < rhs
102117 + };
102118 +
102119 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
102120 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
102121 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102122 +
102123 + if (lhs_size > rhs_size) {
102124 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102125 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102126 + } else if (lhs_size == rhs_size) {
102127 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102128 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102129 + } else {
102130 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102131 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102132 + }
102133 +
102134 + if (!cast_lhs && !cast_rhs)
102135 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102136 +
102137 + if (cast_lhs && !skip_lhs_cast_check(stmt))
102138 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
102139 +
102140 + if (cast_rhs)
102141 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
102142 +
102143 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102144 +}
102145 +
102146 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
102147 +{
102148 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
102149 +
102150 + if (gimple_plf(stmt, MY_STMT))
102151 + return lhs;
102152 +
102153 + rhs1 = gimple_assign_rhs1(stmt);
102154 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
102155 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102156 +
102157 + new_rhs1 = expand(visited, rhs1);
102158 +
102159 + if (new_rhs1 == NULL_TREE)
102160 + return create_cast_assign(visited, stmt);
102161 +
102162 + if (gimple_plf(stmt, NO_CAST_CHECK))
102163 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102164 +
102165 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
102166 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
102167 +
102168 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
102169 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
102170 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102171 + }
102172 +
102173 + if (!gimple_assign_cast_p(stmt))
102174 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102175 +
102176 + return create_cast_overflow_check(visited, new_rhs1, stmt);
102177 +}
102178 +
102179 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
102180 +{
102181 + tree rhs1, lhs = gimple_get_lhs(stmt);
102182 + gimple def_stmt = get_def_stmt(lhs);
102183 +
102184 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
102185 + rhs1 = gimple_assign_rhs1(def_stmt);
102186 +
102187 + if (is_gimple_constant(rhs1))
102188 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102189 +
102190 + switch (TREE_CODE(rhs1)) {
102191 + case SSA_NAME:
102192 + return handle_unary_rhs(visited, def_stmt);
102193 + case ARRAY_REF:
102194 + case BIT_FIELD_REF:
102195 + case ADDR_EXPR:
102196 + case COMPONENT_REF:
102197 + case INDIRECT_REF:
102198 +#if BUILDING_GCC_VERSION >= 4006
102199 + case MEM_REF:
102200 +#endif
102201 + case TARGET_MEM_REF:
102202 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102203 + case PARM_DECL:
102204 + case VAR_DECL:
102205 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102206 +
102207 + default:
102208 + debug_gimple_stmt(def_stmt);
102209 + debug_tree(rhs1);
102210 + gcc_unreachable();
102211 + }
102212 +}
102213 +
102214 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
102215 +{
102216 + gimple cond_stmt;
102217 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
102218 +
102219 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
102220 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
102221 + update_stmt(cond_stmt);
102222 +}
102223 +
102224 +static tree create_string_param(tree string)
102225 +{
102226 + tree i_type, a_type;
102227 + const int length = TREE_STRING_LENGTH(string);
102228 +
102229 + gcc_assert(length > 0);
102230 +
102231 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
102232 + a_type = build_array_type(char_type_node, i_type);
102233 +
102234 + TREE_TYPE(string) = a_type;
102235 + TREE_CONSTANT(string) = 1;
102236 + TREE_READONLY(string) = 1;
102237 +
102238 + return build1(ADDR_EXPR, ptr_type_node, string);
102239 +}
102240 +
102241 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
102242 +{
102243 + gimple func_stmt;
102244 + const_gimple def_stmt;
102245 + const_tree loc_line;
102246 + tree loc_file, ssa_name, current_func;
102247 + expanded_location xloc;
102248 + char *ssa_name_buf;
102249 + int len;
102250 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
102251 +
102252 + def_stmt = get_def_stmt(arg);
102253 + xloc = expand_location(gimple_location(def_stmt));
102254 +
102255 + if (!gimple_has_location(def_stmt)) {
102256 + xloc = expand_location(gimple_location(stmt));
102257 + if (!gimple_has_location(stmt))
102258 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102259 + }
102260 +
102261 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
102262 +
102263 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
102264 + loc_file = create_string_param(loc_file);
102265 +
102266 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
102267 + current_func = create_string_param(current_func);
102268 +
102269 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
102270 + call_count++;
102271 + 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);
102272 + gcc_assert(len > 0);
102273 + ssa_name = build_string(len + 1, ssa_name_buf);
102274 + free(ssa_name_buf);
102275 + ssa_name = create_string_param(ssa_name);
102276 +
102277 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
102278 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
102279 +
102280 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
102281 +}
102282 +
102283 +static void __unused print_the_code_insertions(const_gimple stmt)
102284 +{
102285 + location_t loc = gimple_location(stmt);
102286 +
102287 + inform(loc, "Integer size_overflow check applied here.");
102288 +}
102289 +
102290 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
102291 +{
102292 + basic_block cond_bb, join_bb, bb_true;
102293 + edge e;
102294 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102295 +
102296 + cond_bb = gimple_bb(stmt);
102297 + if (before)
102298 + gsi_prev(&gsi);
102299 + if (gsi_end_p(gsi))
102300 + e = split_block_after_labels(cond_bb);
102301 + else
102302 + e = split_block(cond_bb, gsi_stmt(gsi));
102303 + cond_bb = e->src;
102304 + join_bb = e->dest;
102305 + e->flags = EDGE_FALSE_VALUE;
102306 + e->probability = REG_BR_PROB_BASE;
102307 +
102308 + bb_true = create_empty_bb(cond_bb);
102309 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
102310 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
102311 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
102312 +
102313 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102314 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
102315 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
102316 +
102317 + if (current_loops != NULL) {
102318 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
102319 + add_bb_to_loop(bb_true, cond_bb->loop_father);
102320 + }
102321 +
102322 + insert_cond(cond_bb, arg, cond_code, type_value);
102323 + insert_cond_result(bb_true, stmt, arg, min);
102324 +
102325 +// print_the_code_insertions(stmt);
102326 +}
102327 +
102328 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
102329 +{
102330 + const_tree rhs_type = TREE_TYPE(rhs);
102331 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
102332 +
102333 + gcc_assert(rhs_type != NULL_TREE);
102334 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
102335 + return;
102336 +
102337 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
102338 +
102339 + if (is_const_plus_unsigned_signed_truncation(rhs))
102340 + return;
102341 +
102342 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
102343 + // typemax (-1) < typemin (0)
102344 + if (TREE_OVERFLOW(type_max))
102345 + return;
102346 +
102347 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
102348 +
102349 + cast_rhs_type = TREE_TYPE(cast_rhs);
102350 + type_max_type = TREE_TYPE(type_max);
102351 + type_min_type = TREE_TYPE(type_min);
102352 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
102353 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
102354 +
102355 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
102356 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
102357 +}
102358 +
102359 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
102360 +{
102361 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
102362 + return false;
102363 + if (!is_gimple_constant(rhs))
102364 + return false;
102365 + return true;
102366 +}
102367 +
102368 +static tree get_def_stmt_rhs(const_tree var)
102369 +{
102370 + tree rhs1, def_stmt_rhs1;
102371 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
102372 +
102373 + def_stmt = get_def_stmt(var);
102374 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
102375 +
102376 + rhs1 = gimple_assign_rhs1(def_stmt);
102377 + rhs1_def_stmt = get_def_stmt(rhs1);
102378 + if (!gimple_assign_cast_p(rhs1_def_stmt))
102379 + return rhs1;
102380 +
102381 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102382 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
102383 +
102384 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
102385 + case GIMPLE_CALL:
102386 + case GIMPLE_NOP:
102387 + case GIMPLE_ASM:
102388 + case GIMPLE_PHI:
102389 + return def_stmt_rhs1;
102390 + case GIMPLE_ASSIGN:
102391 + return rhs1;
102392 + default:
102393 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
102394 + gcc_unreachable();
102395 + }
102396 +}
102397 +
102398 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
102399 +{
102400 + tree new_rhs, orig_rhs;
102401 + void (*gimple_assign_set_rhs)(gimple, tree);
102402 + tree rhs1 = gimple_assign_rhs1(stmt);
102403 + tree rhs2 = gimple_assign_rhs2(stmt);
102404 + tree lhs = gimple_get_lhs(stmt);
102405 +
102406 + if (!check_overflow)
102407 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102408 +
102409 + if (change_rhs == NULL_TREE)
102410 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102411 +
102412 + if (new_rhs2 == NULL_TREE) {
102413 + orig_rhs = rhs1;
102414 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
102415 + } else {
102416 + orig_rhs = rhs2;
102417 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
102418 + }
102419 +
102420 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
102421 +
102422 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
102423 + gimple_assign_set_rhs(stmt, new_rhs);
102424 + update_stmt(stmt);
102425 +
102426 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102427 +}
102428 +
102429 +static bool is_subtraction_special(const_gimple stmt)
102430 +{
102431 + gimple rhs1_def_stmt, rhs2_def_stmt;
102432 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
102433 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
102434 + const_tree rhs1 = gimple_assign_rhs1(stmt);
102435 + const_tree rhs2 = gimple_assign_rhs2(stmt);
102436 +
102437 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
102438 + return false;
102439 +
102440 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
102441 +
102442 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
102443 + return false;
102444 +
102445 + rhs1_def_stmt = get_def_stmt(rhs1);
102446 + rhs2_def_stmt = get_def_stmt(rhs2);
102447 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
102448 + return false;
102449 +
102450 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102451 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
102452 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
102453 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
102454 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
102455 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
102456 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
102457 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
102458 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
102459 + return false;
102460 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
102461 + return false;
102462 +
102463 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
102464 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
102465 + return true;
102466 +}
102467 +
102468 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
102469 +{
102470 + tree new_rhs1, new_rhs2;
102471 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
102472 + gimple assign, stmt = get_def_stmt(lhs);
102473 + tree rhs1 = gimple_assign_rhs1(stmt);
102474 + tree rhs2 = gimple_assign_rhs2(stmt);
102475 +
102476 + if (!is_subtraction_special(stmt))
102477 + return NULL_TREE;
102478 +
102479 + new_rhs1 = expand(visited, rhs1);
102480 + new_rhs2 = expand(visited, rhs2);
102481 +
102482 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
102483 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
102484 +
102485 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
102486 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
102487 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
102488 + }
102489 +
102490 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
102491 + new_lhs = gimple_get_lhs(assign);
102492 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
102493 +
102494 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102495 +}
102496 +
102497 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
102498 +{
102499 + const_gimple def_stmt;
102500 +
102501 + if (TREE_CODE(rhs) != SSA_NAME)
102502 + return false;
102503 +
102504 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
102505 + return false;
102506 +
102507 + def_stmt = get_def_stmt(rhs);
102508 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
102509 + return false;
102510 +
102511 + return true;
102512 +}
102513 +
102514 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
102515 +{
102516 + tree rhs1, rhs2, new_lhs;
102517 + gimple def_stmt = get_def_stmt(lhs);
102518 + tree new_rhs1 = NULL_TREE;
102519 + tree new_rhs2 = NULL_TREE;
102520 +
102521 + rhs1 = gimple_assign_rhs1(def_stmt);
102522 + rhs2 = gimple_assign_rhs2(def_stmt);
102523 +
102524 + /* no DImode/TImode division in the 32/64 bit kernel */
102525 + switch (gimple_assign_rhs_code(def_stmt)) {
102526 + case RDIV_EXPR:
102527 + case TRUNC_DIV_EXPR:
102528 + case CEIL_DIV_EXPR:
102529 + case FLOOR_DIV_EXPR:
102530 + case ROUND_DIV_EXPR:
102531 + case TRUNC_MOD_EXPR:
102532 + case CEIL_MOD_EXPR:
102533 + case FLOOR_MOD_EXPR:
102534 + case ROUND_MOD_EXPR:
102535 + case EXACT_DIV_EXPR:
102536 + case POINTER_PLUS_EXPR:
102537 + case BIT_AND_EXPR:
102538 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102539 + default:
102540 + break;
102541 + }
102542 +
102543 + new_lhs = handle_integer_truncation(visited, lhs);
102544 + if (new_lhs != NULL_TREE)
102545 + return new_lhs;
102546 +
102547 + if (TREE_CODE(rhs1) == SSA_NAME)
102548 + new_rhs1 = expand(visited, rhs1);
102549 + if (TREE_CODE(rhs2) == SSA_NAME)
102550 + new_rhs2 = expand(visited, rhs2);
102551 +
102552 + if (is_a_neg_overflow(def_stmt, rhs2))
102553 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
102554 + if (is_a_neg_overflow(def_stmt, rhs1))
102555 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
102556 +
102557 +
102558 + if (is_a_constant_overflow(def_stmt, rhs2))
102559 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
102560 + if (is_a_constant_overflow(def_stmt, rhs1))
102561 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
102562 +
102563 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102564 +}
102565 +
102566 +#if BUILDING_GCC_VERSION >= 4007
102567 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
102568 +{
102569 + if (is_gimple_constant(rhs))
102570 + return cast_a_tree(size_overflow_type, rhs);
102571 + if (TREE_CODE(rhs) != SSA_NAME)
102572 + return NULL_TREE;
102573 + return expand(visited, rhs);
102574 +}
102575 +
102576 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
102577 +{
102578 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
102579 + gimple def_stmt = get_def_stmt(lhs);
102580 +
102581 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
102582 +
102583 + rhs1 = gimple_assign_rhs1(def_stmt);
102584 + rhs2 = gimple_assign_rhs2(def_stmt);
102585 + rhs3 = gimple_assign_rhs3(def_stmt);
102586 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
102587 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
102588 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
102589 +
102590 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
102591 +}
102592 +#endif
102593 +
102594 +static tree get_size_overflow_type(gimple stmt, const_tree node)
102595 +{
102596 + const_tree type;
102597 + tree new_type;
102598 +
102599 + gcc_assert(node != NULL_TREE);
102600 +
102601 + type = TREE_TYPE(node);
102602 +
102603 + if (gimple_plf(stmt, MY_STMT))
102604 + return TREE_TYPE(node);
102605 +
102606 + switch (TYPE_MODE(type)) {
102607 + case QImode:
102608 + new_type = intHI_type_node;
102609 + break;
102610 + case HImode:
102611 + new_type = intSI_type_node;
102612 + break;
102613 + case SImode:
102614 + new_type = intDI_type_node;
102615 + break;
102616 + case DImode:
102617 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102618 + new_type = intDI_type_node;
102619 + else
102620 + new_type = intTI_type_node;
102621 + break;
102622 + default:
102623 + debug_tree((tree)node);
102624 + error("%s: unsupported gcc configuration.", __func__);
102625 + gcc_unreachable();
102626 + }
102627 +
102628 + if (TYPE_QUALS(type) != 0)
102629 + return build_qualified_type(new_type, TYPE_QUALS(type));
102630 + return new_type;
102631 +}
102632 +
102633 +static tree expand_visited(gimple def_stmt)
102634 +{
102635 + const_gimple next_stmt;
102636 + gimple_stmt_iterator gsi;
102637 + enum gimple_code code = gimple_code(def_stmt);
102638 +
102639 + if (code == GIMPLE_ASM)
102640 + return NULL_TREE;
102641 +
102642 + gsi = gsi_for_stmt(def_stmt);
102643 + gsi_next(&gsi);
102644 +
102645 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
102646 + return NULL_TREE;
102647 + gcc_assert(!gsi_end_p(gsi));
102648 + next_stmt = gsi_stmt(gsi);
102649 +
102650 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
102651 + return NULL_TREE;
102652 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
102653 +
102654 + return get_lhs(next_stmt);
102655 +}
102656 +
102657 +static tree expand(struct pointer_set_t *visited, tree lhs)
102658 +{
102659 + gimple def_stmt;
102660 +
102661 + if (skip_types(lhs))
102662 + return NULL_TREE;
102663 +
102664 + def_stmt = get_def_stmt(lhs);
102665 +
102666 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102667 + return NULL_TREE;
102668 +
102669 + if (gimple_plf(def_stmt, MY_STMT))
102670 + return lhs;
102671 +
102672 + if (pointer_set_contains(visited, def_stmt))
102673 + return expand_visited(def_stmt);
102674 +
102675 + switch (gimple_code(def_stmt)) {
102676 + case GIMPLE_PHI:
102677 + return handle_phi(visited, lhs);
102678 + case GIMPLE_CALL:
102679 + case GIMPLE_ASM:
102680 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102681 + case GIMPLE_ASSIGN:
102682 + switch (gimple_num_ops(def_stmt)) {
102683 + case 2:
102684 + return handle_unary_ops(visited, def_stmt);
102685 + case 3:
102686 + return handle_binary_ops(visited, lhs);
102687 +#if BUILDING_GCC_VERSION >= 4007
102688 + case 4:
102689 + return handle_ternary_ops(visited, lhs);
102690 +#endif
102691 + }
102692 + default:
102693 + debug_gimple_stmt(def_stmt);
102694 + error("%s: unknown gimple code", __func__);
102695 + gcc_unreachable();
102696 + }
102697 +}
102698 +
102699 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
102700 +{
102701 + const_gimple assign;
102702 + tree orig_type = TREE_TYPE(orig_node);
102703 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102704 +
102705 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102706 + return gimple_get_lhs(assign);
102707 +}
102708 +
102709 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
102710 +{
102711 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
102712 + update_stmt(stmt);
102713 +}
102714 +
102715 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
102716 +{
102717 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
102718 + update_stmt(stmt);
102719 +}
102720 +
102721 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
102722 +{
102723 + tree arg;
102724 + const_tree origarg;
102725 +
102726 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
102727 + return true;
102728 +
102729 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
102730 + while (origarg && *argnum) {
102731 + (*argnum)--;
102732 + origarg = TREE_CHAIN(origarg);
102733 + }
102734 +
102735 + gcc_assert(*argnum == 0);
102736 +
102737 + gcc_assert(origarg != NULL_TREE);
102738 + *argnum = 0;
102739 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
102740 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
102741 + return true;
102742 + return false;
102743 +}
102744 +
102745 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
102746 +{
102747 + gimple phi = get_def_stmt(result);
102748 + unsigned int i, n = gimple_phi_num_args(phi);
102749 +
102750 + if (!phi)
102751 + return MARK_NO;
102752 +
102753 + pointer_set_insert(visited, phi);
102754 + for (i = 0; i < n; i++) {
102755 + enum mark marked;
102756 + const_tree arg = gimple_phi_arg_def(phi, i);
102757 + marked = pre_expand(visited, search_err_code, arg);
102758 + if (marked != MARK_NO)
102759 + return marked;
102760 + }
102761 + return MARK_NO;
102762 +}
102763 +
102764 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102765 +{
102766 + gimple def_stmt = get_def_stmt(lhs);
102767 + const_tree rhs;
102768 +
102769 + if (!def_stmt)
102770 + return MARK_NO;
102771 +
102772 + rhs = gimple_assign_rhs1(def_stmt);
102773 +
102774 + def_stmt = get_def_stmt(rhs);
102775 + if (is_gimple_constant(rhs))
102776 + search_err_code[FROM_CONST] = true;
102777 +
102778 + return pre_expand(visited, search_err_code, rhs);
102779 +}
102780 +
102781 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102782 +{
102783 + gimple def_stmt = get_def_stmt(lhs);
102784 + const_tree rhs1, rhs2;
102785 + enum mark marked;
102786 +
102787 + if (!def_stmt)
102788 + return MARK_NO;
102789 +
102790 + search_err_code[CAST_ONLY] = false;
102791 +
102792 + rhs1 = gimple_assign_rhs1(def_stmt);
102793 + rhs2 = gimple_assign_rhs2(def_stmt);
102794 + marked = pre_expand(visited, search_err_code, rhs1);
102795 + if (marked != MARK_NO)
102796 + return marked;
102797 + return pre_expand(visited, search_err_code, rhs2);
102798 +}
102799 +
102800 +static const_tree search_field_decl(const_tree comp_ref)
102801 +{
102802 + const_tree field = NULL_TREE;
102803 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
102804 +
102805 + for (i = 0; i < len; i++) {
102806 + field = TREE_OPERAND(comp_ref, i);
102807 + if (TREE_CODE(field) == FIELD_DECL)
102808 + break;
102809 + }
102810 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
102811 + return field;
102812 +}
102813 +
102814 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
102815 +{
102816 + const_tree attr, p;
102817 +
102818 + // 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);
102819 + if (fndecl == NULL_TREE)
102820 + return MARK_NO;
102821 +
102822 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
102823 + if (!attr || !TREE_VALUE(attr))
102824 + return MARK_NO;
102825 +
102826 + p = TREE_VALUE(attr);
102827 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
102828 + return MARK_TURN_OFF;
102829 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
102830 + return MARK_NOT_INTENTIONAL;
102831 + if (argnum == 0) {
102832 + gcc_assert(current_function_decl == fndecl);
102833 + return MARK_NO;
102834 + }
102835 +
102836 + do {
102837 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
102838 + return MARK_YES;
102839 + p = TREE_CHAIN(p);
102840 + } while (p);
102841 +
102842 + return MARK_NO;
102843 +}
102844 +
102845 +static void print_missing_msg(tree func, unsigned int argnum)
102846 +{
102847 + unsigned int new_hash;
102848 + size_t len;
102849 + unsigned char tree_codes[CODES_LIMIT];
102850 + location_t loc;
102851 + const char *curfunc;
102852 +
102853 + func = get_original_function_decl(func);
102854 + loc = DECL_SOURCE_LOCATION(func);
102855 + curfunc = get_asm_name(func);
102856 +
102857 + len = get_function_decl(func, tree_codes);
102858 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
102859 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
102860 +}
102861 +
102862 +static unsigned int search_missing_attribute(const_tree arg)
102863 +{
102864 + unsigned int argnum;
102865 + const struct size_overflow_hash *hash;
102866 + const_tree type = TREE_TYPE(arg);
102867 + tree func = get_original_function_decl(current_function_decl);
102868 +
102869 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
102870 +
102871 + if (TREE_CODE(type) == POINTER_TYPE)
102872 + return 0;
102873 +
102874 + argnum = find_arg_number(arg, func);
102875 + if (argnum == 0)
102876 + return 0;
102877 +
102878 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
102879 + return argnum;
102880 +
102881 + hash = get_function_hash(func);
102882 + if (!hash || !(hash->param & (1U << argnum))) {
102883 + print_missing_msg(func, argnum);
102884 + return 0;
102885 + }
102886 + return argnum;
102887 +}
102888 +
102889 +static enum mark is_already_marked(const_tree lhs)
102890 +{
102891 + unsigned int argnum;
102892 + const_tree fndecl;
102893 +
102894 + argnum = search_missing_attribute(lhs);
102895 + fndecl = get_original_function_decl(current_function_decl);
102896 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
102897 + return MARK_YES;
102898 + return MARK_NO;
102899 +}
102900 +
102901 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102902 +{
102903 + const_gimple def_stmt;
102904 +
102905 + if (skip_types(lhs))
102906 + return MARK_NO;
102907 +
102908 + if (TREE_CODE(lhs) == PARM_DECL)
102909 + return is_already_marked(lhs);
102910 +
102911 + if (TREE_CODE(lhs) == COMPONENT_REF) {
102912 + const_tree field, attr;
102913 +
102914 + field = search_field_decl(lhs);
102915 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
102916 + if (!attr || !TREE_VALUE(attr))
102917 + return MARK_NO;
102918 + return MARK_YES;
102919 + }
102920 +
102921 + def_stmt = get_def_stmt(lhs);
102922 +
102923 + if (!def_stmt)
102924 + return MARK_NO;
102925 +
102926 + if (pointer_set_contains(visited, def_stmt))
102927 + return MARK_NO;
102928 +
102929 + switch (gimple_code(def_stmt)) {
102930 + case GIMPLE_NOP:
102931 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
102932 + return is_already_marked(lhs);
102933 + return MARK_NO;
102934 + case GIMPLE_PHI:
102935 + return walk_phi(visited, search_err_code, lhs);
102936 + case GIMPLE_CALL:
102937 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
102938 + return MARK_TURN_OFF;
102939 + check_function_hash(def_stmt);
102940 + return MARK_NO;
102941 + case GIMPLE_ASM:
102942 + search_err_code[CAST_ONLY] = false;
102943 + return MARK_NO;
102944 + case GIMPLE_ASSIGN:
102945 + switch (gimple_num_ops(def_stmt)) {
102946 + case 2:
102947 + return walk_unary_ops(visited, search_err_code, lhs);
102948 + case 3:
102949 + return walk_binary_ops(visited, search_err_code, lhs);
102950 + }
102951 + default:
102952 + debug_gimple_stmt((gimple)def_stmt);
102953 + error("%s: unknown gimple code", __func__);
102954 + gcc_unreachable();
102955 + }
102956 +}
102957 +
102958 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
102959 +static bool skip_asm(const_tree arg)
102960 +{
102961 + gimple def_stmt = get_def_stmt(arg);
102962 +
102963 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102964 + return false;
102965 +
102966 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
102967 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
102968 +}
102969 +
102970 +/*
102971 +0</MARK_YES: no dup, search attributes (so, int)
102972 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
102973 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
102974 +*/
102975 +
102976 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
102977 +{
102978 + struct pointer_set_t *visited;
102979 + enum mark is_marked, is_found;
102980 + location_t loc;
102981 + bool search_err_code[2] = {true, false};
102982 +
102983 + is_marked = mark_status(current_function_decl, 0);
102984 + if (is_marked == MARK_TURN_OFF)
102985 + return true;
102986 +
102987 + is_marked = mark_status(fndecl, argnum + 1);
102988 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
102989 + return true;
102990 +
102991 + visited = pointer_set_create();
102992 + is_found = pre_expand(visited, search_err_code, arg);
102993 + pointer_set_destroy(visited);
102994 +
102995 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
102996 + return true;
102997 +
102998 + if (where == FROM_ARG && skip_asm(arg))
102999 + return true;
103000 +
103001 + if (is_found == MARK_TURN_OFF)
103002 + return true;
103003 +
103004 + if ((is_found == MARK_YES && is_marked == MARK_YES))
103005 + return true;
103006 +
103007 + if (is_found == MARK_YES) {
103008 + loc = DECL_SOURCE_LOCATION(fndecl);
103009 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
103010 + return true;
103011 + }
103012 + return false;
103013 +}
103014 +
103015 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
103016 +{
103017 + struct pointer_set_t *visited;
103018 + tree arg, new_arg;
103019 + bool match;
103020 +
103021 + if (argnum == 0)
103022 + return;
103023 +
103024 + argnum--;
103025 +
103026 + match = get_function_arg(&argnum, fndecl);
103027 + if (!match)
103028 + return;
103029 + gcc_assert(gimple_call_num_args(stmt) > argnum);
103030 + arg = gimple_call_arg(stmt, argnum);
103031 + if (arg == NULL_TREE)
103032 + return;
103033 +
103034 + if (skip_types(arg))
103035 + return;
103036 +
103037 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
103038 + return;
103039 +
103040 + visited = pointer_set_create();
103041 + new_arg = expand(visited, arg);
103042 + pointer_set_destroy(visited);
103043 +
103044 + if (new_arg == NULL_TREE)
103045 + return;
103046 +
103047 + change_function_arg(stmt, arg, argnum, new_arg);
103048 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
103049 +}
103050 +
103051 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
103052 +{
103053 + tree p = TREE_VALUE(attr);
103054 + do {
103055 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
103056 + p = TREE_CHAIN(p);
103057 + } while (p);
103058 +}
103059 +
103060 +static void handle_function_by_hash(gimple stmt, tree fndecl)
103061 +{
103062 + unsigned int num;
103063 + const struct size_overflow_hash *hash;
103064 +
103065 + hash = get_function_hash(fndecl);
103066 + if (!hash)
103067 + return;
103068 +
103069 + for (num = 0; num <= MAX_PARAM; num++)
103070 + if (hash->param & (1U << num))
103071 + handle_function_arg(stmt, fndecl, num);
103072 +}
103073 +
103074 +static bool check_return_value(void)
103075 +{
103076 + const struct size_overflow_hash *hash;
103077 +
103078 + hash = get_function_hash(current_function_decl);
103079 + if (!hash || !(hash->param & 1U << 0))
103080 + return false;
103081 +
103082 + return true;
103083 +}
103084 +
103085 +static void handle_return_value(gimple ret_stmt)
103086 +{
103087 + struct pointer_set_t *visited;
103088 + tree ret, new_ret;
103089 +
103090 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
103091 + return;
103092 +
103093 + ret = gimple_return_retval(ret_stmt);
103094 +
103095 + if (skip_types(ret))
103096 + return;
103097 +
103098 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
103099 + return;
103100 +
103101 + visited = pointer_set_create();
103102 + new_ret = expand(visited, ret);
103103 + pointer_set_destroy(visited);
103104 +
103105 + change_function_return(ret_stmt, ret, new_ret);
103106 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
103107 +}
103108 +
103109 +static void set_plf_false(void)
103110 +{
103111 + basic_block bb;
103112 +
103113 + FOR_ALL_BB(bb) {
103114 + gimple_stmt_iterator si;
103115 +
103116 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
103117 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103118 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
103119 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103120 + }
103121 +}
103122 +
103123 +static unsigned int handle_function(void)
103124 +{
103125 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
103126 + bool check_ret;
103127 +
103128 + set_plf_false();
103129 +
103130 + check_ret = check_return_value();
103131 +
103132 + do {
103133 + gimple_stmt_iterator gsi;
103134 + next = bb->next_bb;
103135 +
103136 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103137 + tree fndecl, attr;
103138 + gimple stmt = gsi_stmt(gsi);
103139 +
103140 + if (check_ret)
103141 + handle_return_value(stmt);
103142 +
103143 + if (!(is_gimple_call(stmt)))
103144 + continue;
103145 + fndecl = gimple_call_fndecl(stmt);
103146 + if (fndecl == NULL_TREE)
103147 + continue;
103148 + if (gimple_call_num_args(stmt) == 0)
103149 + continue;
103150 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
103151 + if (!attr || !TREE_VALUE(attr))
103152 + handle_function_by_hash(stmt, fndecl);
103153 + else
103154 + handle_function_by_attribute(stmt, attr, fndecl);
103155 + gsi = gsi_for_stmt(stmt);
103156 + next = gimple_bb(stmt)->next_bb;
103157 + }
103158 + bb = next;
103159 + } while (bb);
103160 + return 0;
103161 +}
103162 +
103163 +static struct gimple_opt_pass size_overflow_pass = {
103164 + .pass = {
103165 + .type = GIMPLE_PASS,
103166 + .name = "size_overflow",
103167 +#if BUILDING_GCC_VERSION >= 4008
103168 + .optinfo_flags = OPTGROUP_NONE,
103169 +#endif
103170 + .gate = NULL,
103171 + .execute = handle_function,
103172 + .sub = NULL,
103173 + .next = NULL,
103174 + .static_pass_number = 0,
103175 + .tv_id = TV_NONE,
103176 + .properties_required = PROP_cfg,
103177 + .properties_provided = 0,
103178 + .properties_destroyed = 0,
103179 + .todo_flags_start = 0,
103180 + .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
103181 + }
103182 +};
103183 +
103184 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
103185 +{
103186 + tree fntype;
103187 +
103188 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
103189 +
103190 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
103191 + fntype = build_function_type_list(void_type_node,
103192 + const_char_ptr_type_node,
103193 + unsigned_type_node,
103194 + const_char_ptr_type_node,
103195 + const_char_ptr_type_node,
103196 + NULL_TREE);
103197 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
103198 +
103199 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
103200 + TREE_PUBLIC(report_size_overflow_decl) = 1;
103201 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
103202 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
103203 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
103204 +}
103205 +
103206 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103207 +{
103208 + int i;
103209 + const char * const plugin_name = plugin_info->base_name;
103210 + const int argc = plugin_info->argc;
103211 + const struct plugin_argument * const argv = plugin_info->argv;
103212 + bool enable = true;
103213 +
103214 + struct register_pass_info size_overflow_pass_info = {
103215 + .pass = &size_overflow_pass.pass,
103216 + .reference_pass_name = "ssa",
103217 + .ref_pass_instance_number = 1,
103218 + .pos_op = PASS_POS_INSERT_AFTER
103219 + };
103220 +
103221 + if (!plugin_default_version_check(version, &gcc_version)) {
103222 + error(G_("incompatible gcc/plugin versions"));
103223 + return 1;
103224 + }
103225 +
103226 + for (i = 0; i < argc; ++i) {
103227 + if (!strcmp(argv[i].key, "no-size-overflow")) {
103228 + enable = false;
103229 + continue;
103230 + }
103231 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103232 + }
103233 +
103234 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
103235 + if (enable) {
103236 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103237 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
103238 + }
103239 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103240 +
103241 + return 0;
103242 +}
103243 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
103244 new file mode 100644
103245 index 0000000..ac2901e
103246 --- /dev/null
103247 +++ b/tools/gcc/stackleak_plugin.c
103248 @@ -0,0 +1,327 @@
103249 +/*
103250 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
103251 + * Licensed under the GPL v2
103252 + *
103253 + * Note: the choice of the license means that the compilation process is
103254 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103255 + * but for the kernel it doesn't matter since it doesn't link against
103256 + * any of the gcc libraries
103257 + *
103258 + * gcc plugin to help implement various PaX features
103259 + *
103260 + * - track lowest stack pointer
103261 + *
103262 + * TODO:
103263 + * - initialize all local variables
103264 + *
103265 + * BUGS:
103266 + * - none known
103267 + */
103268 +#include "gcc-plugin.h"
103269 +#include "config.h"
103270 +#include "system.h"
103271 +#include "coretypes.h"
103272 +#include "tree.h"
103273 +#include "tree-pass.h"
103274 +#include "flags.h"
103275 +#include "intl.h"
103276 +#include "toplev.h"
103277 +#include "plugin.h"
103278 +//#include "expr.h" where are you...
103279 +#include "diagnostic.h"
103280 +#include "plugin-version.h"
103281 +#include "tm.h"
103282 +#include "function.h"
103283 +#include "basic-block.h"
103284 +#include "gimple.h"
103285 +#include "rtl.h"
103286 +#include "emit-rtl.h"
103287 +
103288 +#if BUILDING_GCC_VERSION >= 4008
103289 +#define TODO_dump_func 0
103290 +#endif
103291 +
103292 +extern void print_gimple_stmt(FILE *, gimple, int, int);
103293 +
103294 +int plugin_is_GPL_compatible;
103295 +
103296 +static int track_frame_size = -1;
103297 +static const char track_function[] = "pax_track_stack";
103298 +static const char check_function[] = "pax_check_alloca";
103299 +static bool init_locals;
103300 +
103301 +static struct plugin_info stackleak_plugin_info = {
103302 + .version = "201302112000",
103303 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
103304 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
103305 +};
103306 +
103307 +static bool gate_stackleak_track_stack(void);
103308 +static unsigned int execute_stackleak_tree_instrument(void);
103309 +static unsigned int execute_stackleak_final(void);
103310 +
103311 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
103312 + .pass = {
103313 + .type = GIMPLE_PASS,
103314 + .name = "stackleak_tree_instrument",
103315 +#if BUILDING_GCC_VERSION >= 4008
103316 + .optinfo_flags = OPTGROUP_NONE,
103317 +#endif
103318 + .gate = gate_stackleak_track_stack,
103319 + .execute = execute_stackleak_tree_instrument,
103320 + .sub = NULL,
103321 + .next = NULL,
103322 + .static_pass_number = 0,
103323 + .tv_id = TV_NONE,
103324 + .properties_required = PROP_gimple_leh | PROP_cfg,
103325 + .properties_provided = 0,
103326 + .properties_destroyed = 0,
103327 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103328 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103329 + }
103330 +};
103331 +
103332 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
103333 + .pass = {
103334 + .type = RTL_PASS,
103335 + .name = "stackleak_final",
103336 +#if BUILDING_GCC_VERSION >= 4008
103337 + .optinfo_flags = OPTGROUP_NONE,
103338 +#endif
103339 + .gate = gate_stackleak_track_stack,
103340 + .execute = execute_stackleak_final,
103341 + .sub = NULL,
103342 + .next = NULL,
103343 + .static_pass_number = 0,
103344 + .tv_id = TV_NONE,
103345 + .properties_required = 0,
103346 + .properties_provided = 0,
103347 + .properties_destroyed = 0,
103348 + .todo_flags_start = 0,
103349 + .todo_flags_finish = TODO_dump_func
103350 + }
103351 +};
103352 +
103353 +static bool gate_stackleak_track_stack(void)
103354 +{
103355 + return track_frame_size >= 0;
103356 +}
103357 +
103358 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
103359 +{
103360 + gimple check_alloca;
103361 + tree fntype, fndecl, alloca_size;
103362 +
103363 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
103364 + fndecl = build_fn_decl(check_function, fntype);
103365 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103366 +
103367 + // insert call to void pax_check_alloca(unsigned long size)
103368 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
103369 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
103370 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
103371 +}
103372 +
103373 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
103374 +{
103375 + gimple track_stack;
103376 + tree fntype, fndecl;
103377 +
103378 + fntype = build_function_type_list(void_type_node, NULL_TREE);
103379 + fndecl = build_fn_decl(track_function, fntype);
103380 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103381 +
103382 + // insert call to void pax_track_stack(void)
103383 + track_stack = gimple_build_call(fndecl, 0);
103384 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
103385 +}
103386 +
103387 +#if BUILDING_GCC_VERSION == 4005
103388 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
103389 +{
103390 + tree fndecl;
103391 +
103392 + if (!is_gimple_call(stmt))
103393 + return false;
103394 + fndecl = gimple_call_fndecl(stmt);
103395 + if (!fndecl)
103396 + return false;
103397 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
103398 + return false;
103399 +// print_node(stderr, "pax", fndecl, 4);
103400 + return DECL_FUNCTION_CODE(fndecl) == code;
103401 +}
103402 +#endif
103403 +
103404 +static bool is_alloca(gimple stmt)
103405 +{
103406 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
103407 + return true;
103408 +
103409 +#if BUILDING_GCC_VERSION >= 4007
103410 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
103411 + return true;
103412 +#endif
103413 +
103414 + return false;
103415 +}
103416 +
103417 +static unsigned int execute_stackleak_tree_instrument(void)
103418 +{
103419 + basic_block bb, entry_bb;
103420 + bool prologue_instrumented = false, is_leaf = true;
103421 +
103422 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
103423 +
103424 + // 1. loop through BBs and GIMPLE statements
103425 + FOR_EACH_BB(bb) {
103426 + gimple_stmt_iterator gsi;
103427 +
103428 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103429 + gimple stmt;
103430 +
103431 + stmt = gsi_stmt(gsi);
103432 +
103433 + if (is_gimple_call(stmt))
103434 + is_leaf = false;
103435 +
103436 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
103437 + if (!is_alloca(stmt))
103438 + continue;
103439 +
103440 + // 2. insert stack overflow check before each __builtin_alloca call
103441 + stackleak_check_alloca(&gsi);
103442 +
103443 + // 3. insert track call after each __builtin_alloca call
103444 + stackleak_add_instrumentation(&gsi);
103445 + if (bb == entry_bb)
103446 + prologue_instrumented = true;
103447 + }
103448 + }
103449 +
103450 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
103451 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
103452 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
103453 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
103454 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
103455 + return 0;
103456 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
103457 + return 0;
103458 +
103459 + // 4. insert track call at the beginning
103460 + if (!prologue_instrumented) {
103461 + gimple_stmt_iterator gsi;
103462 +
103463 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103464 + if (dom_info_available_p(CDI_DOMINATORS))
103465 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103466 + gsi = gsi_start_bb(bb);
103467 + stackleak_add_instrumentation(&gsi);
103468 + }
103469 +
103470 + return 0;
103471 +}
103472 +
103473 +static unsigned int execute_stackleak_final(void)
103474 +{
103475 + rtx insn, next;
103476 +
103477 + if (cfun->calls_alloca)
103478 + return 0;
103479 +
103480 + // keep calls only if function frame is big enough
103481 + if (get_frame_size() >= track_frame_size)
103482 + return 0;
103483 +
103484 + // 1. find pax_track_stack calls
103485 + for (insn = get_insns(); insn; insn = next) {
103486 + // 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))
103487 + rtx body;
103488 +
103489 + next = NEXT_INSN(insn);
103490 + if (!CALL_P(insn))
103491 + continue;
103492 + body = PATTERN(insn);
103493 + if (GET_CODE(body) != CALL)
103494 + continue;
103495 + body = XEXP(body, 0);
103496 + if (GET_CODE(body) != MEM)
103497 + continue;
103498 + body = XEXP(body, 0);
103499 + if (GET_CODE(body) != SYMBOL_REF)
103500 + continue;
103501 + if (strcmp(XSTR(body, 0), track_function))
103502 + continue;
103503 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103504 + // 2. delete call
103505 + delete_insn_and_edges(insn);
103506 +#if BUILDING_GCC_VERSION >= 4007
103507 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
103508 + insn = next;
103509 + next = NEXT_INSN(insn);
103510 + delete_insn_and_edges(insn);
103511 + }
103512 +#endif
103513 + }
103514 +
103515 +// print_simple_rtl(stderr, get_insns());
103516 +// print_rtl(stderr, get_insns());
103517 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103518 +
103519 + return 0;
103520 +}
103521 +
103522 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103523 +{
103524 + const char * const plugin_name = plugin_info->base_name;
103525 + const int argc = plugin_info->argc;
103526 + const struct plugin_argument * const argv = plugin_info->argv;
103527 + int i;
103528 + struct register_pass_info stackleak_tree_instrument_pass_info = {
103529 + .pass = &stackleak_tree_instrument_pass.pass,
103530 +// .reference_pass_name = "tree_profile",
103531 + .reference_pass_name = "optimized",
103532 + .ref_pass_instance_number = 1,
103533 + .pos_op = PASS_POS_INSERT_BEFORE
103534 + };
103535 + struct register_pass_info stackleak_final_pass_info = {
103536 + .pass = &stackleak_final_rtl_opt_pass.pass,
103537 + .reference_pass_name = "final",
103538 + .ref_pass_instance_number = 1,
103539 + .pos_op = PASS_POS_INSERT_BEFORE
103540 + };
103541 +
103542 + if (!plugin_default_version_check(version, &gcc_version)) {
103543 + error(G_("incompatible gcc/plugin versions"));
103544 + return 1;
103545 + }
103546 +
103547 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
103548 +
103549 + for (i = 0; i < argc; ++i) {
103550 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
103551 + if (!argv[i].value) {
103552 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103553 + continue;
103554 + }
103555 + track_frame_size = atoi(argv[i].value);
103556 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
103557 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103558 + continue;
103559 + }
103560 + if (!strcmp(argv[i].key, "initialize-locals")) {
103561 + if (argv[i].value) {
103562 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103563 + continue;
103564 + }
103565 + init_locals = true;
103566 + continue;
103567 + }
103568 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103569 + }
103570 +
103571 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
103572 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
103573 +
103574 + return 0;
103575 +}
103576 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
103577 new file mode 100644
103578 index 0000000..41770fc
103579 --- /dev/null
103580 +++ b/tools/gcc/structleak_plugin.c
103581 @@ -0,0 +1,272 @@
103582 +/*
103583 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
103584 + * Licensed under the GPL v2
103585 + *
103586 + * Note: the choice of the license means that the compilation process is
103587 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103588 + * but for the kernel it doesn't matter since it doesn't link against
103589 + * any of the gcc libraries
103590 + *
103591 + * gcc plugin to forcibly initialize certain local variables that could
103592 + * otherwise leak kernel stack to userland if they aren't properly initialized
103593 + * by later code
103594 + *
103595 + * Homepage: http://pax.grsecurity.net/
103596 + *
103597 + * Usage:
103598 + * $ # for 4.5/4.6/C based 4.7
103599 + * $ gcc -I`gcc -print-file-name=plugin`/include -I`gcc -print-file-name=plugin`/include/c-family -fPIC -shared -O2 -o structleak_plugin.so structleak_plugin.c
103600 + * $ # for C++ based 4.7/4.8+
103601 + * $ g++ -I`g++ -print-file-name=plugin`/include -I`g++ -print-file-name=plugin`/include/c-family -fPIC -shared -O2 -o structleak_plugin.so structleak_plugin.c
103602 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
103603 + *
103604 + * TODO: eliminate redundant initializers
103605 + * increase type coverage
103606 + */
103607 +
103608 +#include "gcc-plugin.h"
103609 +#include "config.h"
103610 +#include "system.h"
103611 +#include "coretypes.h"
103612 +#include "tree.h"
103613 +#include "tree-pass.h"
103614 +#include "intl.h"
103615 +#include "plugin-version.h"
103616 +#include "tm.h"
103617 +#include "toplev.h"
103618 +#include "function.h"
103619 +#include "tree-flow.h"
103620 +#include "plugin.h"
103621 +#include "gimple.h"
103622 +#include "diagnostic.h"
103623 +#include "cfgloop.h"
103624 +#include "langhooks.h"
103625 +
103626 +#if BUILDING_GCC_VERSION >= 4008
103627 +#define TODO_dump_func 0
103628 +#endif
103629 +
103630 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
103631 +
103632 +// unused type flag in all versions 4.5-4.8
103633 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
103634 +
103635 +int plugin_is_GPL_compatible;
103636 +void debug_gimple_stmt(gimple gs);
103637 +
103638 +static struct plugin_info structleak_plugin_info = {
103639 + .version = "201304082245",
103640 + .help = "disable\tdo not activate plugin\n",
103641 +};
103642 +
103643 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103644 +{
103645 + *no_add_attrs = true;
103646 +
103647 + // check for types? for now accept everything linux has to offer
103648 + if (TREE_CODE(*node) != FIELD_DECL)
103649 + return NULL_TREE;
103650 +
103651 + *no_add_attrs = false;
103652 + return NULL_TREE;
103653 +}
103654 +
103655 +static struct attribute_spec user_attr = {
103656 + .name = "user",
103657 + .min_length = 0,
103658 + .max_length = 0,
103659 + .decl_required = false,
103660 + .type_required = false,
103661 + .function_type_required = false,
103662 + .handler = handle_user_attribute,
103663 +#if BUILDING_GCC_VERSION >= 4007
103664 + .affects_type_identity = true
103665 +#endif
103666 +};
103667 +
103668 +static void register_attributes(void *event_data, void *data)
103669 +{
103670 + register_attribute(&user_attr);
103671 +// register_attribute(&force_attr);
103672 +}
103673 +
103674 +static tree get_field_type(tree field)
103675 +{
103676 + return strip_array_types(TREE_TYPE(field));
103677 +}
103678 +
103679 +static bool is_userspace_type(tree type)
103680 +{
103681 + tree field;
103682 +
103683 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
103684 + tree fieldtype = get_field_type(field);
103685 + enum tree_code code = TREE_CODE(fieldtype);
103686 +
103687 + if (code == RECORD_TYPE || code == UNION_TYPE)
103688 + if (is_userspace_type(fieldtype))
103689 + return true;
103690 +
103691 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
103692 + return true;
103693 + }
103694 + return false;
103695 +}
103696 +
103697 +static void finish_type(void *event_data, void *data)
103698 +{
103699 + tree type = (tree)event_data;
103700 +
103701 + if (TYPE_USERSPACE(type))
103702 + return;
103703 +
103704 + if (is_userspace_type(type))
103705 + TYPE_USERSPACE(type) = 1;
103706 +}
103707 +
103708 +static void initialize(tree var)
103709 +{
103710 + basic_block bb;
103711 + gimple_stmt_iterator gsi;
103712 + tree initializer;
103713 + gimple init_stmt;
103714 +
103715 + // this is the original entry bb before the forced split
103716 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
103717 +
103718 + // first check if the variable is already initialized, warn otherwise
103719 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103720 + gimple stmt = gsi_stmt(gsi);
103721 + tree rhs1 = gimple_assign_rhs1(stmt);
103722 +
103723 + // we're looking for an assignment of a single rhs...
103724 + if (!gimple_assign_single_p(stmt))
103725 + continue;
103726 +#if BUILDING_GCC_VERSION >= 4007
103727 + // ... of a non-clobbering expression...
103728 + if (TREE_CLOBBER_P(rhs1))
103729 + continue;
103730 +#endif
103731 + // ... to our variable...
103732 + if (gimple_get_lhs(stmt) != var)
103733 + continue;
103734 + // if it's an initializer then we're good
103735 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
103736 + return;
103737 + }
103738 +
103739 + // build the initializer expression
103740 + initializer = build_constructor(TREE_TYPE(var), NULL);
103741 +
103742 + // build the initializer stmt
103743 + init_stmt = gimple_build_assign(var, initializer);
103744 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
103745 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
103746 + update_stmt(init_stmt);
103747 +}
103748 +
103749 +static unsigned int handle_function(void)
103750 +{
103751 + basic_block bb;
103752 + unsigned int ret = 0;
103753 + tree var;
103754 +
103755 +#if BUILDING_GCC_VERSION == 4005
103756 + tree vars;
103757 +#else
103758 + unsigned int i;
103759 +#endif
103760 +
103761 + // split the first bb where we can put the forced initializers
103762 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103763 + if (dom_info_available_p(CDI_DOMINATORS))
103764 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103765 +
103766 + // enumarate all local variables and forcibly initialize our targets
103767 +#if BUILDING_GCC_VERSION == 4005
103768 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
103769 + var = TREE_VALUE(vars);
103770 +#else
103771 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
103772 +#endif
103773 + tree type = TREE_TYPE(var);
103774 +
103775 + gcc_assert(DECL_P(var));
103776 + if (!auto_var_in_fn_p(var, current_function_decl))
103777 + continue;
103778 +
103779 + // only care about structure types
103780 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
103781 + continue;
103782 +
103783 + // if the type is of interest, examine the variable
103784 + if (TYPE_USERSPACE(type))
103785 + initialize(var);
103786 + }
103787 +
103788 + return ret;
103789 +}
103790 +
103791 +static struct gimple_opt_pass structleak_pass = {
103792 + .pass = {
103793 + .type = GIMPLE_PASS,
103794 + .name = "structleak",
103795 +#if BUILDING_GCC_VERSION >= 4008
103796 + .optinfo_flags = OPTGROUP_NONE,
103797 +#endif
103798 + .gate = NULL,
103799 + .execute = handle_function,
103800 + .sub = NULL,
103801 + .next = NULL,
103802 + .static_pass_number = 0,
103803 + .tv_id = TV_NONE,
103804 + .properties_required = PROP_cfg,
103805 + .properties_provided = 0,
103806 + .properties_destroyed = 0,
103807 + .todo_flags_start = 0,
103808 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa | TODO_ggc_collect | TODO_verify_flow
103809 + }
103810 +};
103811 +
103812 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103813 +{
103814 + int i;
103815 + const char * const plugin_name = plugin_info->base_name;
103816 + const int argc = plugin_info->argc;
103817 + const struct plugin_argument * const argv = plugin_info->argv;
103818 + bool enable = true;
103819 +
103820 + struct register_pass_info structleak_pass_info = {
103821 + .pass = &structleak_pass.pass,
103822 + .reference_pass_name = "ssa",
103823 + .ref_pass_instance_number = 1,
103824 + .pos_op = PASS_POS_INSERT_AFTER
103825 + };
103826 +
103827 + if (!plugin_default_version_check(version, &gcc_version)) {
103828 + error(G_("incompatible gcc/plugin versions"));
103829 + return 1;
103830 + }
103831 +
103832 + if (strcmp(lang_hooks.name, "GNU C")) {
103833 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
103834 + enable = false;
103835 + }
103836 +
103837 + for (i = 0; i < argc; ++i) {
103838 + if (!strcmp(argv[i].key, "disable")) {
103839 + enable = false;
103840 + continue;
103841 + }
103842 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103843 + }
103844 +
103845 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
103846 + if (enable) {
103847 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
103848 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
103849 + }
103850 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103851 +
103852 + return 0;
103853 +}
103854 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
103855 index 6789d78..4afd019e 100644
103856 --- a/tools/perf/util/include/asm/alternative-asm.h
103857 +++ b/tools/perf/util/include/asm/alternative-asm.h
103858 @@ -5,4 +5,7 @@
103859
103860 #define altinstruction_entry #
103861
103862 + .macro pax_force_retaddr rip=0, reload=0
103863 + .endm
103864 +
103865 #endif
103866 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
103867 index 96b919d..c49bb74 100644
103868 --- a/tools/perf/util/include/linux/compiler.h
103869 +++ b/tools/perf/util/include/linux/compiler.h
103870 @@ -18,4 +18,12 @@
103871 #define __force
103872 #endif
103873
103874 +#ifndef __size_overflow
103875 +# define __size_overflow(...)
103876 +#endif
103877 +
103878 +#ifndef __intentional_overflow
103879 +# define __intentional_overflow(...)
103880 +#endif
103881 +
103882 #endif
103883 diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
103884 index cfb7e4d..52058f0 100644
103885 --- a/virt/kvm/ioapic.c
103886 +++ b/virt/kvm/ioapic.c
103887 @@ -73,9 +73,12 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
103888 u32 redir_index = (ioapic->ioregsel - 0x10) >> 1;
103889 u64 redir_content;
103890
103891 - ASSERT(redir_index < IOAPIC_NUM_PINS);
103892 + if (redir_index < IOAPIC_NUM_PINS)
103893 + redir_content =
103894 + ioapic->redirtbl[redir_index].bits;
103895 + else
103896 + redir_content = ~0ULL;
103897
103898 - redir_content = ioapic->redirtbl[redir_index].bits;
103899 result = (ioapic->ioregsel & 0x1) ?
103900 (redir_content >> 32) & 0xffffffff :
103901 redir_content & 0xffffffff;
103902 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
103903 index 1cd693a..f4a7b20 100644
103904 --- a/virt/kvm/kvm_main.c
103905 +++ b/virt/kvm/kvm_main.c
103906 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
103907
103908 static cpumask_var_t cpus_hardware_enabled;
103909 static int kvm_usage_count = 0;
103910 -static atomic_t hardware_enable_failed;
103911 +static atomic_unchecked_t hardware_enable_failed;
103912
103913 struct kmem_cache *kvm_vcpu_cache;
103914 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
103915
103916 -static __read_mostly struct preempt_ops kvm_preempt_ops;
103917 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
103918 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
103919 +static struct preempt_ops kvm_preempt_ops = {
103920 + .sched_in = kvm_sched_in,
103921 + .sched_out = kvm_sched_out,
103922 +};
103923
103924 struct dentry *kvm_debugfs_dir;
103925
103926 @@ -731,7 +736,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
103927 /* We can read the guest memory with __xxx_user() later on. */
103928 if (user_alloc &&
103929 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
103930 - !access_ok(VERIFY_WRITE,
103931 + !__access_ok(VERIFY_WRITE,
103932 (void __user *)(unsigned long)mem->userspace_addr,
103933 mem->memory_size)))
103934 goto out;
103935 @@ -1783,7 +1788,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
103936 return 0;
103937 }
103938
103939 -static struct file_operations kvm_vcpu_fops = {
103940 +static file_operations_no_const kvm_vcpu_fops __read_only = {
103941 .release = kvm_vcpu_release,
103942 .unlocked_ioctl = kvm_vcpu_ioctl,
103943 #ifdef CONFIG_COMPAT
103944 @@ -2304,7 +2309,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
103945 return 0;
103946 }
103947
103948 -static struct file_operations kvm_vm_fops = {
103949 +static file_operations_no_const kvm_vm_fops __read_only = {
103950 .release = kvm_vm_release,
103951 .unlocked_ioctl = kvm_vm_ioctl,
103952 #ifdef CONFIG_COMPAT
103953 @@ -2402,7 +2407,7 @@ out:
103954 return r;
103955 }
103956
103957 -static struct file_operations kvm_chardev_ops = {
103958 +static file_operations_no_const kvm_chardev_ops __read_only = {
103959 .unlocked_ioctl = kvm_dev_ioctl,
103960 .compat_ioctl = kvm_dev_ioctl,
103961 .llseek = noop_llseek,
103962 @@ -2428,7 +2433,7 @@ static void hardware_enable_nolock(void *junk)
103963
103964 if (r) {
103965 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
103966 - atomic_inc(&hardware_enable_failed);
103967 + atomic_inc_unchecked(&hardware_enable_failed);
103968 printk(KERN_INFO "kvm: enabling virtualization on "
103969 "CPU%d failed\n", cpu);
103970 }
103971 @@ -2482,10 +2487,10 @@ static int hardware_enable_all(void)
103972
103973 kvm_usage_count++;
103974 if (kvm_usage_count == 1) {
103975 - atomic_set(&hardware_enable_failed, 0);
103976 + atomic_set_unchecked(&hardware_enable_failed, 0);
103977 on_each_cpu(hardware_enable_nolock, NULL, 1);
103978
103979 - if (atomic_read(&hardware_enable_failed)) {
103980 + if (atomic_read_unchecked(&hardware_enable_failed)) {
103981 hardware_disable_all_nolock();
103982 r = -EBUSY;
103983 }
103984 @@ -2843,7 +2848,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
103985 kvm_arch_vcpu_put(vcpu);
103986 }
103987
103988 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103989 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103990 struct module *module)
103991 {
103992 int r;
103993 @@ -2879,7 +2884,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
103994 if (!vcpu_align)
103995 vcpu_align = __alignof__(struct kvm_vcpu);
103996 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
103997 - 0, NULL);
103998 + SLAB_USERCOPY, NULL);
103999 if (!kvm_vcpu_cache) {
104000 r = -ENOMEM;
104001 goto out_free_3;
104002 @@ -2889,9 +2894,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104003 if (r)
104004 goto out_free;
104005
104006 + pax_open_kernel();
104007 kvm_chardev_ops.owner = module;
104008 kvm_vm_fops.owner = module;
104009 kvm_vcpu_fops.owner = module;
104010 + pax_close_kernel();
104011
104012 r = misc_register(&kvm_dev);
104013 if (r) {
104014 @@ -2901,9 +2908,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104015
104016 register_syscore_ops(&kvm_syscore_ops);
104017
104018 - kvm_preempt_ops.sched_in = kvm_sched_in;
104019 - kvm_preempt_ops.sched_out = kvm_sched_out;
104020 -
104021 r = kvm_init_debug();
104022 if (r) {
104023 printk(KERN_ERR "kvm: create debugfs files failed\n");